/*Change font size*/

//Specify affected tags. Add or remove from list:
var tgs = new Array('p', 'h1', 'h2', 'td', 'div');
//var tgs = new Array('span', 'td', 'strong', 'a', 'li', 'div', 'p', 'h1', 'h2');
//Specify spectrum of different font sizes:
var szs = new Array('12px', '13px', '15px');
//var szs = new Array('x-small', 'small', 'medium');
//var szs = new Array('1em', '1.05em', '1.10em', '1.15em');
var startSz = sz = 0;

function getFontSize()
{	
	if (getCookie('fontSize') == null)
	{		
		startSz = 0;
	}
	else
	{ 
		startSz = getCookie('fontSize');
		if (startSz == "NaN")	startSz = 0;
	}	
	changeFontSize(startSz, true);
}

function changeFontSize(inc, start)
{
	if (!document.getElementById) return;
	var d = document,cEl = null,sz = eval(startSz),i,j,cTags;
	
	/*if (!start)
	{
		sz += inc;
		
		if ( sz < 0 ) sz = 0;
		if ( sz > (szs.length-1) ) sz = (szs.length-1);
		startSz = sz;
	}
	else
	{
		sz = inc;
	}*/
	
	sz = inc;
	
	cEl = d.getElementsByTagName('body')[0];
	cEl.style.fontSize = szs[ sz ];	
	if (document.getElementById("fontBtnSmall") && document.getElementById("fontBtnMedium") && document.getElementById("fontBtnLarge")){
		if(sz != 0) {
			document.getElementById("fontBtnSmall").setAttribute("class", "fontBtn smallFont");
			document.getElementById("fontBtnSmall").setAttribute("className", "fontBtn smallFont");
		} else {
			document.getElementById("fontBtnSmall").setAttribute("class", "fontBtn smallFontCurrent");
			document.getElementById("fontBtnSmall").setAttribute("className", "fontBtn smallFontCurrent");
		}
		if(sz != 1) {
			document.getElementById("fontBtnMedium").setAttribute("class", "fontBtn mediumFont");
			document.getElementById("fontBtnMedium").setAttribute("className", "fontBtn mediumFont");
		} else {
			document.getElementById("fontBtnMedium").setAttribute("class", "fontBtn mediumFontCurrent");
			document.getElementById("fontBtnMedium").setAttribute("className", "fontBtn mediumFontCurrent");
		}
		if(sz != 2) {
			document.getElementById("fontBtnLarge").setAttribute("class", "fontBtn largeFont");
			document.getElementById("fontBtnLarge").setAttribute("className", "fontBtn largeFont");
		} else {
			document.getElementById("fontBtnLarge").setAttribute("class", "fontBtn largeFontCurrent");
			document.getElementById("fontBtnLarge").setAttribute("className", "fontBtn largeFontCurrent");
		}
	}
	setCookie("fontSize", sz, nd, cpath, cdomain);

}

var nd= new Date();
nd.setTime(nd.getTime()+(365*24*60*60*1000));
//cdomain = (location.domain) ? location.domain : null;
var cdomain = (location.domain) ? location.domain : null;
var cpath = "/";

function setCookie(name, value, expires, path, domain, secure)
{
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");

  document.cookie = curCookie;
}

function getCookie(name)
{
	if (document.cookie.indexOf(name) < 0)
	{		
		return null;
	}
	else
	{	
		var startStr = document.cookie.indexOf(name) + name.length + 1;
		var endStr = document.cookie.indexOf(";", startStr);
		if (endStr == -1)	endStr = document.cookie.length;
		return unescape(document.cookie.substring(startStr, endStr));
	}
}


var totalMenu=4;
var currentMenu=-1;

function slideUpMenu(){
	for (i=1; i<totalMenu; i++){
		if (i!=currentMenu){
			//$("#"+i).slideUp("fast");
			$("#"+i).hide();
		}
	}
}

function hideMenu(){
	currentMenu=-1;
	setTimeout("slideUpMenu()",150);
}

function showMenu(menu){
	currentMenu=menu;
}

function showPanel(panelOrder, panelOver){
	hideMenu();
	document.getElementById(panelOver).style.top = (panelOrder *37)-20 +'px';
	$("#"+panelOver).fadeIn("slow");
}
function hidePanel(panelOver){
	$("#"+panelOver).fadeOut("normal");
}
function dropdownMenu(menuId){
	if(!$("#"+menuId).is(":animated")){
		if ($("#"+menuId).is(":hidden")) {	
			$("#"+menuId).slideDown("fast");
		 };
		 currentMenu=menuId;
		 setTimeout("slideUpMenu()",150);
	}
}

$(document).ready(function(){	 
//	 preloadTopMenu();
	 checkHorizontal();
//	 window.onresize = checkHorizontal;
	if (typeof initMenu!='undefined'){
		initMenu();
	}
});


/*function initMenu() {
	  $('#sideMenu ul').hide();
	  $('#sideMenu ul:eq(2)').show();
	  $('#sideMenu .bigCategory:eq(2)').addClass("current");

	  $('#sideMenu li a').click(
		function() {
		  var checkElement = $(this).next();
		  if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
			return false;
			}
		  if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
			$('#sideMenu ul:visible').slideUp('normal');
			checkElement.slideDown('normal');
			return false;
			}
		  }
		);
	  }
*/

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
};

function getViewpointWidth() {
 var myWidth = 0;
 if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
 return myWidth;
};

function checkHorizontal(){
	if (getViewpointWidth()<955){
		$("html").css("overflow-x","auto");
	} else {
		$("html").css("overflow-x","hidden");
	}
}