// Evolve CMS Javascript Functions
// 09-20-2011

// Handles simple rollover functionality
function rOI(iid,isrc) {
	document.getElementById(iid).src=isrc; 
}
  
// Show and hide fields in URMS forms
function cms_showhide (did,sh) {
	document.getElementById(did).className = sh=="S"?"showcms":"hidecms";	
}
 
// Show and hide fields in URMS forms
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"; 
}

// Car Rotation
function setCarRotate() {

	if (document.getElementById("featured")) {
		var f=document.getElementById("featured");
		var dots=''; 
		if (maxCars>0) {
			for (var n=0; n<=maxCars; n++) {
				if (curCar==n) {
					dots+="<img src='/images/button-enabled.jpg'>&nbsp;";
				}
				else {
					dots+="<img src='/images/button-disabled.jpg'>&nbsp;";
				}
			}
		}
		
		var out="<div id='featuredimage'><img src='/modules/autos/images/thumbs/"+carImage[curCar]+"'></div>";
		out+="<div id='featuredtextheader'>Featured Autos</div><div id='featureddots'>"+dots+"</div>";
		out+="<div style='clear:both;'></div><div id='featuredtext'>"+carText[curCar]+"</div>";
		
		f.innerHTML=out;
		
		curCar++;
		if (curCar>maxCars) curCar=0; 
	}
}

// Show modal layer
function show_modal(c,w,h) {
	 if (document.getElementById("basic-modal-content")) {
		 document.body.removeChild(document.getElementById("basic-modal-content"));  
	 }
	 di = document.createElement("div"); 
	 di.setAttribute('id', "basic-modal-content");
	 di.style.width=w+"px";
	 di.style.height=h+"px";
	 di.innerHTML=c; 
	 di.style.display="none"; 
	 di.style.zIndex=5;
	 di.style.padding="5px";
	 di.style.color="white";
	 document.body.appendChild(di); 
	 $('#basic-modal-content').modal();
}

// In-built video function
VideoJS.setupAllWhenReady();

function evCMS_showVideo(vid,w,h,n) {
	
	$.get("/modules/video/vidserv.php",
		  {vid:vid},
		  function(data) {
				show_modal(data,w,h);
				var myPlayer = VideoJS.setup("modal-video");
				myPlayer.play();
		  },
		  "html"
	);
}
 
evCMS_noOnlExec=false; 
evCMS_onl=function() {};  
 
function evCMS_onlHandle() {
	if (evCMS_noOnlExec==false) {
		evCMS_onl();	
		if (typeof(urms_checkdeps_onload)=="function") {
		   	 urms_checkdeps_onload(); 
		}
		evCMS_noOnlExec=true;
	}
}

// This is the javascript boostrap, which delays the load for FF for the custom fonts
(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(){ 
	evCMS_onlHandle();
	s.parentNode && s.parentNode.removeChild(s); 
}
addEventListener('load',f,false);
setTimeout(f,3000);
}
else {
	window.onload=function() { evCMS_onlHandle(); };
}
})(); 
