function pad(value, length) { 
        length = length || 2; 
        return "0000".substr(0,length - Math.min(String(value).length, length)) + value; 
};




sfHover = function() {
	var sfEls = document.getElementById("nav").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);



function mydivheight(){
if(!(document.getElementById("map_1"))){
	var viewportheight;
	if (typeof window.innerWidth != 'undefined')
	{
      	viewportheight = window.innerHeight
 	}
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 	else if (typeof document.documentElement != 'undefined'
     	&& typeof document.documentElement.clientWidth !=
     	'undefined' && document.documentElement.clientWidth != 0)
 	{
       	viewportheight = document.documentElement.clientHeight
 	}
 
 // older versions of IE
 
 	else
 	{
       	viewportheight = document.getElementsByTagName('body')[0].clientHeight
 	}


	if (document.getElementById("post_text_section"))
	{
		document.getElementById("spa_block_section").style.height = document.getElementById("post_text_section").offsetHeight+'px';
		var pageheight = document.getElementById("post_text_section").offsetHeight;
		pageheight = pageheight+330;
	}
	else
	{
		if (document.getElementById("main_block_page"))
		{
			var pageheight = document.getElementById("main_block_page").offsetHeight;
			if(document.getElementById("map"))
			{
				pageheight = pageheight+600;
			}
		}
		if (document.getElementById("main_block_news"))
		{
			var pageheight = document.getElementById("main_block_news").offsetHeight;
		}
		if (document.getElementById("main_block_index"))
		{
			var pageheight = document.getElementById("main_block_index").offsetHeight+160;
			
		}
	}

	if (document.getElementById("subnav_menu"))
	{
		var sidebarheight = document.getElementById("subnav_menu").getElementsByTagName("li").length;
		
		sidebarheight = sidebarheight*40;
		sidebarheight = sidebarheight+20;
	
	
		if (sidebarheight<pageheight && pageheight+268>viewportheight)
		{
			document.getElementById("sidebar_filler").style.height = (pageheight-sidebarheight)+'px';
			document.getElementById("content").style.height = (pageheight+40)+'px';
		}
		else {
			document.getElementById("content").style.height = (sidebarheight+40)+'px';
		}
	}
		if (( pageheight+268<viewportheight) )
		{
			if (document.getElementById("subnav_menu"))
			{
				document.getElementById("sidebar_filler").style.height = (viewportheight-sidebarheight-296)+'px';
			}
			document.getElementById("content").style.height = (viewportheight-236)+'px';
		}
		
	}
}
	

		



var nowOnload = window.onload; // Let's save the existing assignment, if any
function init() {
  // quit if this function has already been called
  if (arguments.callee.done) return;

  // flag this function so we don't do the same thing twice
  arguments.callee.done = true;

  // kill the timer
  
	Galleria.loadTheme('/js/galleria/themes/classic/galleria.classic.js');
	
	if (document.forms[0]){
		if (document.forms[0].date){
			document.forms[0].date.readOnly=true;
			document.forms[0].date.disabled=false;
		}
	}
	
 // mydivheight();

 
 


};

/* for Mozilla/Opera9 */
if (document.addEventListener) {
  document.addEventListener("DOMContentLoaded", init, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
  document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
  var script = document.getElementById("__ie_onload");
  script.onreadystatechange = function() {
    if (this.readyState == "complete") {
      init(); // call the onload handler
    }
  };
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
  var _timer = setInterval(function() {
    if (/loaded|complete/.test(document.readyState)) {
      init(); // call the onload handler
    }
  }, 10);
}

/* for other browsers */
window.onload = init;




jQuery().ready(function() {
	jQuery('.kwicks').kwicks({
		max : 250
	});
	
	
	
	jQuery('.mycarousel').cycle({
        fx: 'fade',
        speed:  2000,
        timeout: 6000
    });
    

	
});
			
		