﻿/* menu
------------------------------------------------------*/
var OnHiddenDivOver = false;
var t = null;
var LastDivId = 0;
var FontSizeAdd=0;
var MenuId=0;


$(document).ready(function() {
	  jQuery(".popUpDiv").hide();
	  //toggle the componenet with class msg_body
	  jQuery(".btnExpand").click(function()
	  {
		jQuery(this).next(".popUpDiv").slideToggle(500);
	  });					   
						
	MenuId=gup("menu");
	if(MenuId!="")
	{
		$("#menu ul li").attr('class','NonActive');
		$("#menu ul li")[MenuId-1].className='active';
	}
	else
	{
		$("#menu ul li")[0].className='active';
	}
	
	  /* HOME ANIMATION */
  function contentRotate(feature) {
	if (doAnimate) {  
	  feature.fadeOut("fast", function (feature) {
	    return function () {
		  $(".feature_content div").hide();
			
		  /* HIGHLIGHT RELEVANT CONTROL */
		  if ($(this).attr("id") == "feature1") {
		    $(".feature_nav .on").removeClass("on");
		    $(".home1").addClass("on");
		  }
		  else if ($(this).attr("id") == "feature2") {
		    $(".feature_nav .on").removeClass("on");
		    $(".home2").addClass("on");
		  }
		  else if ($(this).attr("id") == "feature3") {
		    $(".feature_nav .on").removeClass("on");
		    $(".home3").addClass("on");
		  }
		   else if ($(this).attr("id") == "feature4") {
		    $(".feature_nav .on").removeClass("on");
		    $(".home4").addClass("on");
		  }
		   else if ($(this).attr("id") == "feature5") {
		    $(".feature_nav .on").removeClass("on");
		    $(".home5").addClass("on");
		  }
		
		  /* FADE IN NEXT ITEM OR GO BACK TO FIRST */
		  feature.fadeIn("fast", function () {
		    if ($(this).attr("id") == "feature5") {
			  setTimeout(function () {
			    contentRotate($(".feature_content div:first"));
			  }, 4000);
		    }
		    else {
		      setTimeout(function () {
			    contentRotate($(feature.next()));
			  }, 4000);
		    }
		  });
	    };
	  }(feature));
	}
  }


  /* HOME FEATURES */
  $(".feature_nav a").hover(function() {
    var current = $(this).attr("title");
	$(".feature_nav .on").removeClass("on");
	$(this).addClass("on");
  });
  

  
  /*click doesn't work
  
  $(".feature_nav a").click(function() {
    return false;
  });
*/
  var doAnimate = true;

  contentRotate($(".feature_content div:first"));

  $(".home1").hover(function() {
	$("#feature1").show();
	$("#feature2").hide();
	$("#feature3").hide();
	$("#feature4").hide();
	$("#feature5").hide();
	doAnimate = false;
  });
  $(".home2").hover(function() {
	$("#feature1").hide();
	$("#feature2").show();
	$("#feature3").hide();
	$("#feature4").hide();
	$("#feature5").hide();
	doAnimate = false;
  });
  $(".home3").hover(function() {
	$("#feature1").hide();
	$("#feature2").hide();
	$("#feature3").show();
	$("#feature4").hide();
	$("#feature5").hide();
	doAnimate = false;
  });
   $(".home4").hover(function() {
	$("#feature1").hide();
	$("#feature2").hide();
	$("#feature3").hide();
	$("#feature4").show();
	$("#feature5").hide();
	doAnimate = false;
  });
   $(".home5").hover(function() {
	$("#feature1").hide();
	$("#feature2").hide();
	$("#feature3").hide();
	$("#feature4").hide();
	$("#feature5").show();
	doAnimate = false;
  });
  
});



function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function MouseOver(divId) {
    clearTimeout(t);
    $('#hiddenDiv' + divId).show();
    if (LastDivId != 0 && divId != LastDivId) {
        $('#hiddenDiv' + LastDivId).hide();
    }
    LastDivId = divId;

}

function MouseOut(id) {
    t = setTimeout("HideMenu("+id+")", 200)
}

function HideMenu(id) {
	
    if (!OnHiddenDivOver) {
        $('#hiddenDiv' + id).hide();
        LastDivId=0;
    }
}

/* CHANGE font size
------------------------------------------------------*/

function ChangeFontSize(size) {
	if(size!=FontSizeAdd){
		var SizeChange=0;
			SizeChange=size-FontSizeAdd;
			FontSizeAdd=size;

		var ClassNameArray = new Array();
			ClassNameArray[0] = "contentText"
			ClassNameArray[1] = "link"
			ClassNameArray[2] = "h1"
			ClassNameArray[3] = "h2"
			ClassNameArray[4] = "h3"
			ClassNameArray[5] = "h4"
			ClassNameArray[6] = "titleGrey"
			ClassNameArray[7] = "titleGrey2"
			ClassNameArray[8] = "boxBigText"
			
			
			

		for (var i = 0; i < ClassNameArray.length; i++) {

			var currentFontSize = $('.' + ClassNameArray[i]).css('font-size');
			var currentFontSizeNum = parseFloat(currentFontSize, 10);
			
			
			var currentFontSizeP = $('.' + ClassNameArray[i]+" p").css('font-size');
			var currentFontSizePNum = parseFloat(currentFontSizeP, 10);
			
			var newFontSize = currentFontSizeNum + SizeChange;
			$('.' + ClassNameArray[i]).css('font-size', newFontSize+"px");
			
			var newFontSizeP = currentFontSizePNum + SizeChange;
			$('.' + ClassNameArray[i]+" p").css('font-size', newFontSizeP+"px");
			
		}
	}

}

/* CHANGE CSS FILE
------------------------------------------------------*/

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

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

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
/*
------------------------------------------------------*/

/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}


/* image swap on click */
$(function(){   $(".img-swap").live('click', function() {     if ($(this).attr("class") == "img-swap") {       this.src = this.src.replace("_off","_on");     } else {       this.src = this.src.replace("_on","_off");     }     $(this).toggleClass("on");   }); }); 

/*date*/
var currentTime = new Date()

var weekday=new Array(7);
weekday[0]="Sunday"; weekday[1]="Monday"; weekday[2]="Tuesday"; weekday[3]="Wednesday"; weekday[4]="Thursday"; weekday[5]="Friday"; weekday[6]="Saturday";

var date=new Array(31);
date[0]="1st"; date[1]="2nd"; date[2]="3rd"; date[3]="4th"; date[4]="5th"; date[5]="6th"; date[6]="7th"; date[7]="8th"; date[8]="9th"; date[9]="10th"; date[10]="11th";
date[11]="12th"; date[12]="13th"; date[13]="14th"; date[14]="15th"; date[15]="16th"; date[16]="17th"; date[17]="18th"; date[18]="19th"; date[19]="20th"; date[20]="21st";
date[21]="22nd"; date[22]="23rd"; date[23]="24th"; date[24]="25th"; date[25]="26th"; date[26]="27th"; date[27]="28th"; date[28]="29th"; date[29]="30th";date[30]="31st";

var month=new Array(12);
month[0]="January"; month[1]="February"; month[2]="March"; month[3]="April"; month[4]="May"; month[5]="June"; month[6]="July"; month[7]="August"; month[8]="September";
month[9]="October"; month[10]="November"; month[11]="December";

var year = currentTime.getFullYear()

