// JavaScript Document
var currentURL = '/' + window.location.href.toString().split("/")[3] + '/';

// Load the left and right nav
jQuery(document).ready(function()  {
	jQuery('div#nav>ul>li>a').each(function()  {
    		if (jQuery(this).attr('href') == currentURL) {
    			jQuery(this).addClass('selected');
   		}
	});
		
	  jQuery('#nav>ul').fancymenu({
	    animateduration: {over: 1, out: 1}, //duration of slide in/ out animation, in milliseconds
	    arrowimages:false,
	    vertical_mode: false,
	    menuleft: 0
	  });
		  
	  jQuery('#sideNav>ul').fancymenu({
	    animateduration: {over: 1, out: 1}, //duration of slide in/ out animation, in milliseconds
	    arrowimages:false,
	    vertical_mode: true,
	    menuleft: 144
	  });
		  
		 
		  
}); 


//Newsletter Subscription Management
function HandleCheckBox (obj) {
	if (obj	 == 1) {
		if (document.newsForm1.NewsletterSignUp[1].checked == true ) {
			document.newsForm1.NewsletterSignUp[0].checked = false		
		}		
	}	else if (obj == 8) {
		if (document.newsForm1.NewsletterSignUp[0].checked == true ) {
			document.newsForm1.NewsletterSignUp[1].checked = false		
		}
	} 		
}
	
function getCalSelection() {
	document.newsForm1.NAVSubscription.value = 0;
	
	var HowMany;
	var count;
	HowMany = (document.newsForm1.NewsletterSignUp.length - 1);
	
	for (count = 0; count <= HowMany;count++) {
		if (document.newsForm1.NewsletterSignUp[count].checked == true) {
			document.newsForm1.NAVSubscription.value = parseInt(document.newsForm1.NAVSubscription.value) + parseInt(document.newsForm1.NewsletterSignUp[count].value);	
		}
	}
		
	if (document.newsForm1.Email.value == 'Your Email Here' || document.newsForm1.Email.value == '') {
		alert('Please enter your email address in order to subscribe.');
		return false;
	} else {
		return true;
	}
}

//handle adding items to favorites/bookmarks	
function addFav() {
	if (window.sidebar) { 		
		window.sidebar.addPanel(document.title, this.location.href,''); 
	} else if (window.external) {
		window.external.AddFavorite(this.location.href,document.title);
	} else {
		alert('Your web browser does not appear to support the automatic bookmarking of pages.');
	}
}
	
// Write our ads
function writeSWFHTML(divID, swfID, swfSrc, imgSrc, width, height, params)   {
		
		var adHTML = '';
		adHTML += '<object type="application/x-shockwave-flash" '; 
		adHTML += ' width="' + width + '" height="' + height + '" ';
		adHTML += ' id="' + swfID + '" name="' + swfID + '" data="' + swfSrc + '">';
		adHTML += ' <param name="movie" value="' + swfSrc + '" />';
		adHTML += ' <param name="wmode" value="transparent" />';
		adHTML += ' <param name="allowScriptAccess" value="sameDomain" />';
		if (params != '') adHTML += params;
		adHTML += ' <img src="' + imgSrc + '" alt="" height="' + height + '" width="' + width + '" border="0" hspace="0" vspace="0" align="left" />';
		adHTML += "</object>";
		
        //insert the HTML to the page
		if (document.getElementById(divID)) {
		    var divToSet = document.getElementById(divID);
		    divToSet.innerHTML = adHTML;
		}
}

function pagePeel() {
	this.linkUrl = '';
	this.smallSWF = '';
	this.smallImg = '';
	this.bigSWF = '';
	this.bigImg = '';
	this.trackImgTag = '';
	
	this.writeDiv = funcWriteDiv;
}

function sizeup987(){
	document.getElementById('jcornerBig').style.top = '0px';
	document.getElementById('jcornerSmall').style.top = '-1000px';
}

function sizedown987(){
	document.getElementById("jcornerSmall").style.top = "0px";
	document.getElementById("jcornerBig").style.top = "-1000px";
}

function funcWriteDiv() {	var smallParams = 'ico=' + this.smallImg;	var bigParams = 'big=' + this.bigImg + '&ad_url=' + this.linkUrl;	
	// <jcornerSmall>
	document.write('<div id="jcornerSmall" style="position:absolute;width:100px;height:100px;z-index:9999;right:0px;top:0px;">');
	// object
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"');
	document.write(' id="jcornerSmallObject" width="100" height="100">');
	// object params
	document.write(' <param name="allowScriptAccess" value="always"/> ');
	document.write(' <param name="movie" value="'+ this.smallSWF +'?' + smallParams + '"/>');
	document.write(' <param name="wmode" value="transparent" />');
	document.write(' <param name="quality" value="high" /> ');
	document.write(' <param name="FlashVars" value="' + smallParams + '"/>');
	// embed
	document.write('<embed src="' + this.smallSWF + '?' + smallParams + '" name="jcornerSmallObject" wmode="transparent" quality="high" width="100" height="100" flashvars="' + smallParams + '" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>');
	document.write('</object>');	if (this.trackImgTag != '') {
		document.write(this.trackImgTag);
	}	document.write('</div>');
	// </jcornerSmall>
	// <jcornerBig>
	document.write('<div id="jcornerBig" style="position:absolute;width:650px;height:650px;z-index:9999;right:0px;top:0px;">');
	// object
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"');
	document.write(' id="jcornerBigObject" width="650" height="650">');
	// object params
	document.write(' <param name="allowScriptAccess" value="always"/> ');
	document.write(' <param name="movie" value="' + this.bigSWF + '?'+ bigParams +'"/>');
	document.write(' <param name="wmode" value="transparent"/>');
	document.write(' <param name="quality" value="high" /> ');
	document.write(' <param name="FlashVars" value="' + bigParams + '"/>');
	// embed
	document.write('<embed src="'+ this.bigSWF + '?' + bigParams +'" id="jcornerBigEmbed" name="jcornerBigObject" wmode="transparent" quality="high" width="650" height="650" flashvars="' + bigParams + '" swliveconnect="true" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>');
	document.write('</object></div>');
	// </jcornerBig>
	setTimeout('document.getElementById("jcornerBig").style.top = "-1000px";',1000);
}
