/////////////////// JavaScript Document //////////////////////////////////

function goThere(urlfrag){ // redirects
	window.location=urlfrag;
}

///////////////////// Rotate testimonials (lower left, index.php)//////////////////////////

var tesCount = 6;
var tesDelay = 8000;
var tesCurrent = 0;
var tesTimeout = null;

function nextTestimonial() {
	showTestimonial(tesCurrent+1);
}

function prevTestimonial() {
	showTestimonial(tesCurrent-1);
}

function showTestimonial(count) {
	if(tesTimeout != null) {
		window.clearTimeout(tesTimeout);
		tesTimeout = null;
	}
	
	if(count > tesCount) {
		count = 1;	
	} else if (count < 1) {
		count = tesCount;
	}
	
	tesCurrent = count;
	
	for ( var i = 1; i <= tesCount; i++ ) {
		var z = "tes_" + i
		var aTes = document.getElementById(z)
		if(i == count) {
			aTes.style.visibility = "visible"
		} else {
			aTes.style.visibility = "hidden"
		}
	}

	tesTimeout = window.setTimeout(function() { showTestimonial(tesCurrent + 1); }, tesDelay);
}


//////////////// old function from content.php /////////////////

	function Maximize() 
	{
		window.innerWidth = screen.availWidth;
		window.innerHeight = screen.availHeight;
		window.screenX = 0;
		window.screenY = 0;
		alwaysLowered = false;
	}

////////////////////// Controls side menu on content.php ////////////////////////////////////


function disp(event,namo) {
// Side menu bar - display the floating menu 
	document.getElementById(namo).style.position = "absolute";
	document.getElementById(namo).style.visibility = "visible";
	document.getElementById(namo).style.zIndex = "1";
} // end function

function goaway(namo){
// Side menu bar - hide the floating menu
	document.getElementById(namo).style.visibility = "hidden";
} // end function

function goThere(URL){
// Links - redirects
	
	if ( URL.length > 0 ){
		window.location = URL;
	}

} // end function

function getAnchor(){
// Links - finds anchor to which you want to jump and focuses on it	onLoad();
	var gotAnc = location.search
	if ( (gotAnc.length > 0) && (gotAnc.indexOf("anchor") != -1 ) ){
		start = gotAnc.lastIndexOf("anchor=")
		fin = gotAnc.lastIndexOf("&")
		gotAnc = gotAnc.substring(start,fin)
		gotAnc = gotAnc.replace("anchor=","")
		document.getElementById(gotAnc).focus(); 
	}
}// end function


////////////////////// positions video player //////////////////////

/*function rsPlayer(){
	if ( document.getElementById("fpBackdrop") ){
	//get elements
		var fpBackdrop = document.getElementById("fpBackdrop");
		var fpFrame = document.getElementById("fpFrame");
		var fpVideo = document.getElementById("fpVideo");
	//available screen	
		screenW = $(window).width();
		screenH = $(window).height();
	//resize fpBackdrop 
		if (screenW < 912){
			backdropW = "912px";
		} else {
		 	backdropW = "100%";	
		}
		fpBackdrop.style.width = backdropW;
	//place fpFrame in center, write FrameW, frameH values using PHP from d/b fp_Movies
		var frameW = 480;
		var frameH = 360;
		var frameL = (screenW - frameW) * 0.5;
		var frameT = (screenH - frameH) * 0.5;
		fpFrame.style.left = frameL+"px";
		fpFrame.style.top = frameT+"px";
	}
}//end function*/


////////////////////// LoadIndex loads all functions when index.php loads//////////////////////

function loadIndex(){ 
	showTestimonial(1);
	//rsPlayer();
}