// JavaScript Document

	function getPosition(theElement){
		var positionX = 0;
		var positionY = 0;		
		
		while (theElement != null){
			positionX += theElement.offsetLeft;
			positionY += theElement.offsetTop;
			theElement = theElement.offsetParent;
		}
		
		return [positionX, positionY];
	}

	function trim(str){
		//function to trim leading and trailing white spaces
		 return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
	}
	
	function right(str, n){
		if (n <= 0)
			return "";
		else if (n > String(str).length)
			return str;
		else {
			var iLen = String(str).length;
			return String(str).substring(iLen, iLen - n);
		}
	}
	
	function left(str, n){
		if (n <= 0)
			return ""; 
		else if (n > String(str).length)
			return str;
		else
			return String(str).substring(0,n);
	}
	
	function addLoadEvent(func){
		//adds unlimited functions to onload event
		var oldonload = window.onload;
		if(typeof window.onload != 'function'){
			window.onload = func
		}else{
			window.onload = function(){oldonload();func();}
		}
	}	
	
	function createDiv(className, sContents){
	
		var nDiv = document.createElement("div");
		nDiv.className = className;
		nDiv.innerHTML = sContents;
		
		return nDiv;
	}
	
	function textCounter(Text, Count, maxText){
		/* inserts a text length count into Count */
		/* text length is limited to the allowed limit */
		var rText = document.getElementById(Text);
		var rCount = document.getElementById(Count);		
        if (rText.value.length > maxText){
        	rText.value = rText.value.substring(0, maxText);
            rCount.value = 0;
        }else{
            rCount.value = maxText - rText.value.length;
        }
    }
	
	function showBlock(elId){
		var elRef = document.getElementById(elId);
		elRef.style.display = "block";
		elRef.style.visibility = "visible";
	}
	
	function hideBlock(elId){
		var elRef = document.getElementById(elId);
		elRef.style.display = "none";
		elRef.style.visibility = "hidden"; 	
	}
	
	function setCookie(c_name,value,expiredays){
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+expiredays);
		document.cookie=c_name+ "=" +escape(value)+
		((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	}
	
	function getCookie(c_name){
		if (document.cookie.length>0){
		  c_start=document.cookie.indexOf(c_name + "=");
		  if (c_start!=-1){ 
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
			} 
		  }
		return "";
	}
	  
	  //from menu_left.asp
	  function toggDiv(tab,tab1) { 
			//reset all of the tabs first
		
		  //	if(tab=="suwa_tab"){
		  //
		  //		document.getElementById('del').style.display = "none";
		  //		//document.getElementById('tr_del').style.display = "";
		  //
		  //	}
		  //  else if(tab=="del"){
		  //
		  //		document.getElementById('suwa_tab').style.display = "none";
		  //		document.getElementById('tr_admin').style.display = "";
		  //	}
			
			with (document.getElementById(tab).style) { 
			if (display == "none") 
				display = "" 
			else 
			display = "none"; 
			}
			with (document.getElementById(tab1).style) { 
			if (display == "none") 
				display = "" 
			else 
				display = "none"; 
			}
		} 
	
	function chgBk(obj,cl,td) {
		obj.className=cl;
		var el = document.getElementById(td);
	
		if(cl=='nav_highlight'){
			el.style.color = "#FFFFFF";
		}
		else{
			el.style.color = "#046b9a";
		}
	}
	
		// to show map on contact us page
	function showBigMap(){		
		showBlock("bigMap");
		hideBlock("contactInfo");			
	}
	
	function hideBigMap(){
		hideBlock("bigMap");
		showBlock("contactInfo");					
	}
	
	function enableBigMap(){
		var rThumb = document.getElementById("thumbnail");
		Core.addEventListener(rThumb, "mouseover", showBigMap);
		Core.addEventListener(rThumb, "mouseout", hideBigMap);		
	}
	
	addLoadEvent(enableBigMap);
	//end map showing


	
	