function setActiveStyleSheet(name) 
{
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel") && a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == name) a.disabled = false;
    }
  }
}

function changeStyleSheet(name,value)
{
	setProfileCookie(name,value);
	setActiveStyleSheet(value);
}


function setProfileCookie(name,value) 
{
  	var expiration_date = new Date("January 1, 2010");
 	expiration_date = expiration_date.toGMTString();
	setCookie(name, value, expiration_date);
}

function setCookie(name, value, expires)
{
	 document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") + "; path=/" ;	
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}


function addBookmark(url,title) {
if (window.sidebar) {
window.sidebar.addPanel(title, url,"");
} else if( document.all ) {
 window.external.AddFavorite( url, title);
 } else if( window.opera && window.print ) {
 return true;
}
}

function openPicture(url, width, height)
{
	var str 	= "height=" + (height+30) + ",innerHeight=" + height + ",width=" + (width+30) + ",innerWidth=" + width + ",statusbar=no,scrollbars=yes";
	var xpos	= (screen.availWidth-width)/2;
	var ypos	= (screen.availHeight-height)/2;
	newWindow 	= window.open(url,"pic",str);
	newWindow.focus();
	return newWindow;
}

function openURL(url, name, width, height)
{
	var str 	= "height=" + height + ",innerHeight=" + height + ",width=" + width + ",innerWidth=" + width + ",statusbar=no,scrollbars=no";
	var xpos	= (screen.availWidth-width)/2;
	var ypos	= (screen.availHeight-height)/2;
	newWindow 	= window.open(url,"pic",str);
	newWindow.focus();
	return newWindow;
	
}

function checkDay()
{
	var month 		= document.getElementById("mm").value;
	var dsel 		= document.getElementById("dd");
	var selval		= document.getElementById("dd").value;
	var year 		= document.getElementById("yy").value;
	var leapyear 	= false;
	if (year % 4 == 0) leapyear = true;
	var monthlength = 30;
    switch (parseInt(month))
	{
		case 1: monthlength=31; break;
		case 2: monthlength=(leapyear?29:28); break;
		case 3: monthlength=31; break;
		case 4: monthlength=30; break;
		case 5: monthlength=31; break;
		case 6: monthlength=30; break;
		case 7: monthlength=31; break;
		case 8: monthlength=31; break;
		case 9: monthlength=30; break;
		case 10: monthlength=31; break;
		case 11: monthlength=30; break;
		case 12: monthlength=31; break;
	}
	dsel.options.length 	= monthlength;
	for (i = 0; i < dsel.options.length; i++)
	{
		dsel.options[i].value 	= (i+1);
		dsel.options[i].text 	= (i+1);
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

Window.onDomReady(activatePage.bind(this));

function activatePage()
{
	footnoteLinks('content_inner','footer');	
	/*var objTitle				= $('dyntitle');
	var objTitleCoor			= objTitle.getCoordinates();
	objTitle.setStyles({
   								border: '1px solid #000'
						});
	*/
	
}
