// National Ledger - JavaScript

/************** EMAIL ARTICLE SHOW/HIDE */
var email_array = new Array("email");
function displayEmail(the_email){
	 if (document.getElementById(the_email).style.display==""){
	   document.getElementById(the_email).style.display = "none";return
  }
  for (i=0;i<email_array.length;i++){
	   var my_email = document.getElementById(email_array[i]);
	   my_email.style.display = "none";
	 }
  document.getElementById(the_email).style.display = "";
}

/************** SHOW HIDE FAV BOX */

// define sections
var favoritesbox_array = new Array("favoritesboxone", "favoritesboxtwo", "favoritesboxthree");
var favoritesboxlink_array = new Array("favoritesboxonelink", "favoritesboxtwolink", "favoritesboxthreelink");

// show/hide
function displaySection(the_section, newclass, altclass, section_array){
  for (i=0;i<section_array.length;i++){
	var my_section = document.getElementById(section_array[i]);
    my_section.className = altclass;
  }
  document.getElementById(the_section).className = newclass;
}

// celebrity profile functions
function photoRollover(photoid, newphotoclass) {
	document.getElementById(photoid).setAttribute("class", newphotoclass);	
}
function showLargePhoto(photoid, newphotosrc) {
	// get ids
	var photoidsrc = photoid+"largephotosrc";
	
	// change src and href
	document.getElementById(photoidsrc).src=newphotosrc;
}

/************** SHOW DATE */
var months=new Array(13);
months[1]="January";
months[2]="February";
months[3]="March";
months[4]="April";
months[5]="May";
months[6]="June";
months[7]="July";
months[8]="August";
months[9]="September";
months[10]="October";
months[11]="November";
months[12]="December";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
if ((navigator.appName == "Microsoft Internet Explorer") && (year < 2000))
year="19" + year;
if (navigator.appName == "Netscape")
year=1900 + year;

function getTheDate() {
	document.getElementById('todaysdate').innerHTML = lmonth + " " + date + ", " + year;
}
window.onload = getTheDate;

/************** SLIDE OUT PROMO */
function slideOut() {
	if (checkCookie()) {
		if (c < 15) {
			c=c+1;
			t=setTimeout("slideOut()",1000);
			$('#slidebox').stop(true).animate({'right':'-430px'},100);
		} else {
			$('#slidebox').animate({'right':'0px'},1000);
			clearTimeout(t);
		}
	}
}
function closeSlideOut() {
    setCookie("close_slideout","yes", 365);
	$('#slidebox').animate({'right':'-430px'},1000);
}

/************** SLIDE OUT COOKIES */
function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value + "; path=/";
}
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}
function checkCookie() {
  var close_slideout=getCookie("close_slideout");
  if (close_slideout=="yes") { // do not show slideout
	return false;
  } else {
	return true;
  }
}

/************** LOAD FEATURED ELEMENTS */
// dates and prices load
function loadFeatureElement(file_name, container_id, no_load_message)
  {
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        document.getElementById(container_id).innerHTML = no_load_message;
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById(container_id).innerHTML=xmlHttp.responseText;
        }
      }
    xmlHttp.open("GET",file_name,true);
    xmlHttp.send(null);
  }
