/*TOP NAVIGATION*/

sfHover = function() {
	var sfEls = document.getElementById("navMain").getElementsByTagName("LI");
	
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
			
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			
		}
	}
}

sfHover2 = function() {
	var sfEls = document.getElementById("actHours").getElementsByTagName("LI");
	
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
			
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			
		}
	}
}

if (window.attachEvent) {
	window.attachEvent("onload", sfHover);
	window.attachEvent("onload", sfHover2);
}

//////////////////////////////////////////////////////////



var timeout         = 500;

var closetimer                = 0;

var ddmenuitem      = 0;

 

function jsddm_open()

{           jsddm_canceltimer();

            jsddm_close();

            ddmenuitem = jQuery(this).find('ul').eq(0).css('visibility', 'visible');}

 

function jsddm_close()

{           if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

 

function jsddm_timer()

{           closetimer = window.setTimeout(jsddm_close, timeout);}

 

function jsddm_canceltimer()

{           if(closetimer)

            {           window.clearTimeout(closetimer);

                        closetimer = null;}}

 
jQuery(document).ready(function()
{     
        
	jQuery('#jsddm > li').bind('mouseover', jsddm_open);
	jQuery('#jsddm > li').bind('mouseout',  jsddm_timer);
	
	
	jQuery('.nav-menu li').removeClass('open');
    jQuery('.nav-menu li a').removeClass('open');
    jQuery('ul.level-2').addClass('close');
	jQuery('ul.level-3').addClass('close');
    jQuery('li.selected').parents('ul').removeClass('close');
	jQuery('li.selected').parents('ul').addClass('open');
	jQuery('li.selected').parents('li').addClass('current');
	jQuery('li.selected').children('ul').removeClass('close');
	jQuery('li.selected').children('ul').addClass('open');
	
	
	jQuery('.bottom_links_container').masonry({
		singleMode: false,
		columnWidth: 80,
		itemSelector: '.bottom_links_unit_container'
	});
	
	/*
	if(jQuery('li.selected').children('ul') != ""){
		jQuery('li.selected').children('ul').addClass('open');
		
	}*/

	
	
	/*	Jquery Google Analytics	
	
	jQuery("a[target='_blank']").click(function(){
		alert(jQuery(this).attr('href'));
 		pageTracker._trackPageview('/outgoing/'+ jQuery(this).attr('href'));
	});*/
});

document.onclick = jsddm_close;





function bookmark_us(url, title){
	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);
	}
	else { //chrome for now, but have to find Safari soln
		alert("Press CTRL+D (Chrome) or Command+D (Safari) to bookmark thia page");
	}
			
}

function increaseFontSize() {
	var contentid = document.getElementById('content');
	var leftnavi = document.getElementById('layout-column_column-leftNavi');
	
   var max = 14;
   var h2_max = 20
   
   // temp var to hold size
   var s = 11;
	
	//parse for all p tags, remove "px", increase size by 1 and replace px
   var p = contentid.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         s = 11;
      }
      if(s < max) {
         s++;
		 p[i].style.fontSize = s+"px";
      }      
   }
   
   var leftnavigation = leftnavi.getElementsByTagName('li');
   for(i=0;i<leftnavigation.length;i++) {
      if(leftnavigation[i].style.fontSize) {
         var s = parseInt(leftnavigation[i].style.fontSize.replace("px",""));
      } else {
         s = 11;
      }
      if(s < max) {
         s++;
		 leftnavigation[i].style.fontSize = s+"px";
      }      
   }
   
   var li = contentid.getElementsByTagName('li');
   for(i=0;i<li.length;i++) {
      if(li[i].style.fontSize) {
         var s = parseInt(li[i].style.fontSize.replace("px",""));
      } else {
         s = 11;
      }
      if(s < max) {
         s++;
		 li[i].style.fontSize = s+"px";
      }      
   }
   
   var td = contentid.getElementsByTagName('td');
   for(i=0;i<td.length;i++) {
      if(td[i].style.fontSize) {
         s = parseInt(td[i].style.fontSize.replace("px",""));
      } else {
         var s = 11;
      }
      if(s < max) {
         s++;
      }
      td[i].style.fontSize = s+"px";
   }
   
   var su = contentid.getElementsByTagName('sup');
   for(i=0;i<su.length;i++) {
      if(su[i].style.fontSize) {
         var s = parseInt(su[i].style.fontSize.replace("px",""));
      } else {
         var s = 11;
      }
      if(s < max) {
         s++;
      }
      su[i].style.fontSize = s6+"px";
   }
   
   var h2 = contentid.getElementsByTagName('h2');
   for(i=0;i<h2.length;i++) {
      if(h2[i].style.fontSize) {
         var s5 = parseInt(h2[i].style.fontSize.replace("px",""));
      } else {
         var s5 = 16;
      }
      if(s5 <= h2_max) {
         s5 = s5 + 2;
		 h2[i].style.fontSize = s5+"px";
      }
      
   }      
}


function decreaseFontSize() {
	var contentid = document.getElementById('content');
	var leftnavi = document.getElementById('layout-column_column-leftNavi');
	
   var min = 10;
   var h2_min = 14;
	
   var p = contentid.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s1 = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s1 = 11;
      }
      if(s1 > min) {
         s1 = s1 - 1;
      }
      p[i].style.fontSize = s1+"px";
   }
   
   var leftnavigation = leftnavi.getElementsByTagName('li');
   for(i=0;i<leftnavigation.length;i++) {
      if(leftnavigation[i].style.fontSize) {
         var s1 = parseInt(leftnavigation[i].style.fontSize.replace("px",""));
      } else {
         var s1 = 11;
      }
      if(s1 > min) {
         s1 = s1 - 1;
      }
      leftnavigation[i].style.fontSize = s1+"px";
   }
   
   var li = contentid.getElementsByTagName('li');
   for(i=0;i<li.length;i++) {
      if(li[i].style.fontSize) {
         var s1 = parseInt(li[i].style.fontSize.replace("px",""));
      } else {
         var s1 = 11;
      }
      if(s1 > min) {
         s1 = s1 - 1;
      }
      li[i].style.fontSize = s1+"px";
   }     
   

var td = contentid.getElementsByTagName('td');
   for(i=0;i<td.length;i++) {
      if(td[i].style.fontSize) {
         var s4 = parseInt(td[i].style.fontSize.replace("px",""));
      } else {
         var s4 = 11;
      }
      if(s4 > min) {
         s4--;
      }
      td[i].style.fontSize = s4+"px";
   }
   
   var su = contentid.getElementsByTagName('sup');
   for(i=0;i<su.length;i++) {
      if(su[i].style.fontSize) {
         var s6 = parseInt(su[i].style.fontSize.replace("px",""));
      } else {
         var s6 = 11;
      }
      if(s6 > min) {
         s6--;
      }
      su[i].style.fontSize = s6+"px";
   }
   
   var h2 = contentid.getElementsByTagName('h2');
   for(i=0;i<h2.length;i++) {
      if(h2[i].style.fontSize) {
         var s5 = parseInt(h2[i].style.fontSize.replace("px",""));
      } else {
         var s5= 16;
      }
      if(s5 >= h2_min) {
         s5 = s5 - 2;
      }
      h2[i].style.fontSize = s5+"px";
   }
         
}

function printContent(id){
	
	var str=document.getElementById(id).innerHTML
	//var strobj = jQuery("#content").html();
	//var getStr = str.match(/Liferay.*\)/g);
	var getStr = str.match(/<!\[.*\]>/gi);
	//alert(getStr);
	for (i=0;i<=getStr.length;i++){
		str = str.replace(getStr[i],'');
	//	alert("str: "+str)	;	
	}

	newwin=window.open('','printwin','left=100,top=100,width=740,height=600,scrollBars=1')
	newwin.document.write('<HTML>\n<HEAD>\n')
	newwin.document.write('<TITLE>Print Page</TITLE>\n')
	newwin.document.write('<script>\n')
//	newwin.document.write('getStr = str.match(/<!\[.*\]>/gi);for (i=0;i<=getStr.length;i++){ str = str.replace(getStr[i],'derr');}\n')
	newwin.document.write('function chkstate(){\n')
	newwin.document.write('if(document.readyState=="complete"){\n')
	//newwin.document.write('window.close()\n')
	newwin.document.write('}\n')
	newwin.document.write('else{\n')
	newwin.document.write('setTimeout("chkstate()",2000)\n')
	newwin.document.write('}\n')
	newwin.document.write('}\n')
	newwin.document.write('function print_win(){\n')
	newwin.document.write('window.print();\n')
	newwin.document.write('chkstate();\n')
	newwin.document.write('}\n')
	newwin.document.write('<\/script>\n')
	/*newwin.document.write('<script type="text/javascript" src="/html/js/liferay/portlet.js"><\/script>\n')
	newwin.document.write('<script type="text/javascript" src="/html/js/liferay/liferay.js"><\/script>\n')
	newwin.document.write('<script type="text/javascript" src="/html/js/jquery/cookie.js"><\/script>\n')
	newwin.document.write('<script type="text/javascript" src="/html/js/jquery/jquery.js"><\/script>\n')
	newwin.document.write('<script type="text/javascript" src="/html/js/jquery/jquery.js"><\/script>\n')
	newwin.document.write('<script type="text/javascript" src="/html/js/jquery/jquery.js"><\/script>\n')
	newwin.document.write('<script type="text/javascript" src="/html/js/jquery/jquery.js"><\/script>\n')
	newwin.document.write('<script type="text/javascript" src="/html/js/jquery/jquery.js"><\/script>\n')
	newwin.document.write('<script type="text/javascript" src="/html/js/jquery/jquery.js"><\/script>\n')
	newwin.document.write('<script type="text/javascript" src="/html/js/jquery/jquery.js"><\/script>\n')
	newwin.document.write('<script type="text/javascript" src="/html/js/jquery/jquery.js"><\/script>\n')
	newwin.document.write('<script type="text/javascript" src="/html/js/jquery/jquery.js"><\/script>\n')
	newwin.document.write('<script type="text/javascript" src="/html/js/jquery/jquery.js"><\/script>\n')
	newwin.document.write('<script type="text/javascript" src="/html/js/jquery/jquery.js"><\/script>\n')
	newwin.document.write('<script type="text/javascript" src="/html/js/jquery/jquery.js"><\/script>\n')
	newwin.document.write('<script type="text/javascript" src="/html/js/jquery/jquery.js"><\/script>\n')
	newwin.document.write('<script type="text/javascript" src="/html/js/jquery/jquery.js"><\/script>\n')
	newwin.document.write('<script type="text/javascript" src="/html/js/jquery/jquery.js"><\/script>\n')
	newwin.document.write('<script type="text/javascript" src="/html/js/jquery/jquery.js"><\/script>\n')*/
	newwin.document.write('<link rel="stylesheet" type="text/css" href="/caTheme-theme/css/style.css" \/>\n')
	newwin.document.write('<style>\n')
	newwin.document.write('body {background:#fff;margin:10px;}\n')	
	newwin.document.write('#contentContainer { display: block; width: auto; clear: both; border: none; margin: 20px 0; padding: 0; background: none }\n')
	newwin.document.write('<\/style>\n')
	newwin.document.write('</HEAD>\n')
	newwin.document.write('<BODY bgcolor="#ffffff" onload="print_win()" >\n')
	newwin.document.write('<div id="contentContainer">\n')
	newwin.document.write('<div id="content">\n')
	newwin.document.write(str)
	newwin.document.write('<\/div>\n')
	newwin.document.write('<\/div>\n')
	newwin.document.write('</BODY>\n')
	newwin.document.write('</HTML>\n')
	newwin.document.close()
}


function printActivity(id){
	
	var strAct=document.getElementById(id).innerHTML
	
	newwin=window.open('','printwin','left=100,top=100,width=740,height=600,scrollBars=1')
	newwin.document.write('<HTML>\n<HEAD>\n')
	newwin.document.write('<TITLE>Print Page</TITLE>\n')
	newwin.document.write('<script>\n')
	newwin.document.write('function chkstate(){\n')
	newwin.document.write('if(document.readyState=="complete"){\n')
	//newwin.document.write('window.close()\n')
	newwin.document.write('}\n')
	newwin.document.write('else{\n')
	newwin.document.write('setTimeout("chkstate()",2000)\n')
	newwin.document.write('}\n')
	newwin.document.write('}\n')
	newwin.document.write('function print_win(){\n')
	newwin.document.write('window.print();\n')
	newwin.document.write('chkstate();\n')
	newwin.document.write('}\n')
	newwin.document.write('<\/script>\n')
	newwin.document.write('<link rel="stylesheet" type="text/css" href="/caTheme-theme/css/style.css" \/>\n')
	newwin.document.write('<style>\n')
	newwin.document.write('body {background:#fff;margin:10px;}\n')	
	newwin.document.write('#contentContainer { display: block; width: auto; clear: both; border: none; margin: 20px 0; padding: 0; background: none }\n')
	newwin.document.write('<\/style>\n')
	newwin.document.write('</HEAD>\n')
	newwin.document.write('<BODY bgcolor="#ffffff" onload="print_win()" >\n')
	newwin.document.write('<div id="contentContainer">\n')
	newwin.document.write('<div id="content">\n')
	newwin.document.write(strAct)
	newwin.document.write('<\/div>\n')
	newwin.document.write('<\/div>\n')
	newwin.document.write('</BODY>\n')
	newwin.document.write('</HTML>\n')
	newwin.document.close()
}
