// JavaScript Document
function rOI(iid,isrc) {
	document.getElementById(iid).src=isrc; 
}
  
function cms_showhide (did,sh) {
	document.getElementById(did).className = sh=="S"?"showcms":"hidecms";	
}
 
function show_hide_deps(obj,value,eid) {
	v=obj.value; 
	if (v == value || (v == '' && value == '!Urms!NaN!')) 
		document.getElementById(eid).className="showcms"; 
	else 
		document.getElementById(eid).className="hidecms"; 
}

function hn_blank_field() {
	document.searchform.evocms_search.value=''; 	
}

function setSplRotate() {

	if (document.getElementById("hn-spotlight")) {
		var f=document.getElementById("hn-spotlight");
		var dots=''; 
		if (maxSpl>0) {
			for (var n=0; n<=maxSpl; n++) {
				if (curSpl==n) {
					dots+="<img src='/images/homenew/button-enabled.jpg'>&nbsp;";
				}
				else {
					dots+="<img src='/images/homenew/button-disabled.jpg'>&nbsp;";
				}
			}
		}
		
		var out="<h1 class='special'>In The Spotlight</h1><div style='height:300px;width:604px;'>"+splText[curSpl]+"</div><div style='width:604px;text-align:right;'>"+dots+"</div>";
		
		f.innerHTML=out;
		
		curSpl++;
		if (curSpl>maxSpl) curSpl=0; 
	}
}

function getWidth() {
	wWidth=0;
	if( typeof(window.innerWidth) == 'number' ) {
		wWidth = window.innerWidth;
	}
	else if( document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			wWidth = document.documentElement.clientWidth;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		wWidth = document.body.clientWidth;
	}	
	return wWidth;
	
}

function getHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}


function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    scrOfY = window.pageYOffset;
  } 
  else if ( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    scrOfY = document.body.scrollTop;
  } 
  else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY;	
}

function shEmailFrm() {

	frm="<h1 style='margin-top:0px;'>Email This Page</h1>"; 
	frm+="<form name='emailToFrm' onsubmit='javascript:subEmailToFrm()'>"; 
	frm+="<table>";
	frm+="<tr><td>Your Name:</td><td><input type='text' name='emailYrName' size='30'></td></tr>"; 
	frm+="<tr><td>Friend's Email Address:</td><td><input type='text' name='emailFrName' size='45'></td></tr>";
	frm+="<tr><td colspan='2'>Send a Message:</td></tr>";
	frm+="<tr><td colspan='2'><textarea name='emailFrMsg' style='width:580px;height:250px;' rows='1' cols='1'></textarea></td></tr>"; 
	frm+="<tr><td colspan='2'><input type='submit' name='sub' value='Send To Friend'></td></tr>"; 
	frm+="</table>";
	frm+="</form>"; 
	
	shModal(frm,600,450);
}

function subEmailToFrm() {

   new Ajax.Request('/modules/evolvecms/emailFrdServ.php', 
   {
   		method:'post',
		parameters:'yn='+document.emailToFrm.emailYrName.value+'&fn='+document.emailToFrm.emailFrName.value+'&ym='+document.emailToFrm.emailFrMsg.value,
    	onComplete: function(transport){
      		var response = transport.responseText || "n";
			window.alert(transport.responseText);
   	  		if (response == "n") {
				window.alert("Error: the server did not respond. Please try again");
			}
			else if (response != "success") {
				window.alert("Error: "+response); 	
			}
			else {
				window.alert("Your message was sent successfully!");
				hdModal();
			}
    	},
    	onFailure: function(){ window.alert("Error: the server did not respond. Please try again."); }
   });

}


function shModal(cnt,w,h) {
	 
	 dIo=document.getElementById("modal");
     dIo.style.display = "block"; 
	 
	 document.getElementById("modal").style.height=h+"px";
	 document.getElementById("modalbackground").style.height=getHeight()+"px";
	 document.getElementById("modallayer").style.height=h+"px"; 
	 document.getElementById("modal").style.width=w+"px";
	 document.getElementById("modalbackground").style.width=getWidth()+"px";
	 document.getElementById("modallayer").style.width=w+"px";
	 document.getElementById("modalbox").style.top = getScrollY()+25+"px";
	 document.getElementById("modalbox").style.left=Math.round((getWidth()-480)/2)+"px";
	
	 document.getElementById("modalcontent").innerHTML=cnt; 
}

function hdModal(dI) {
	 document.getElementById("modal").innerHTML=""; 
	 document.getElementById("modal").style.display = "none";
}
  
function equalize() {}  
  
(function(){
// if firefox 3.5+, hide content till load (or 3 seconds)
var d = document, e = d.documentElement, s = d.createElement('style');
if (e.style.MozTransform === ''){ // gecko 1.9.1 inference
s.textContent = 'body{visibility:hidden}';
e.firstChild.appendChild(s);
function f(){ 
	s.parentNode && s.parentNode.removeChild(s); 
	equalize();	
	if (typeof(evCMS_google_maps)=="function") {
		evCMS_google_maps(); 	
	}
}
addEventListener('load',f,false);
setTimeout(f,3000);
}
else {
	window.onload=function() {  
		if (typeof(evCMS_google_maps)=="function") {
			evCMS_google_maps(); 	
		}
	}	
}
})(); 
