﻿var CurrentPageNo;
var TotalTestPages = 600;

CurrentPageNo = get_Testimonials_cookie("TestlsPg");
if (CurrentPageNo == ""){
	CurrentPageNo = 1;
	document.cookie="TestlsPg=" + CurrentPageNo;
}else{
CurrentPageNo = parseInt(CurrentPageNo) + 1;
document.cookie="TestlsPg=" + CurrentPageNo;

}

function GetScreenSizeTestimonials() {
    TestimonialsScreenWidth = 640;
    TestimonialsScreenHeight = 480;

 if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    TestimonialsScreenWidth = window.innerWidth;
    TestimonialsScreenHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    TestimonialsScreenWidth = document.documentElement.clientWidth;
    TestimonialsScreenHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    TestimonialsScreenWidth = document.body.clientWidth;
    TestimonialsScreenHeight = document.body.clientHeight;
  }
}

//Specify iframe to display. Change src and other attributes except "position" and "left/top":
var iframetag='<iframe id="masterdiv" src="/collection/TestimonialsiFrame.asp?page=' + CurrentPageNo + '" width="1200px" height="110px" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="1" scrolling="yes" style="position: absolute; left: -500px; top: -500px;"></iframe>'

//specify x coordinates of iframe ("right" for right corner, or a pixel number (ie: "20px")):
var masterdivleft="1px"

//specify y coordinates of iframe ("bottom" for bottom of page, or a pixel number (ie: "20px")):
var masterdivtop="bottom"

var ie=(document.all || window.opera) && document.getElementById
var iebody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body

if (ie)
document.write(iframetag)

function positionit(){
GetScreenSizeTestimonials();
	if ( TestimonialsScreenHeight > 700) {
		window.attachEvent("onresize", positionit);
		window.attachEvent("onscroll", hideit);
		masterdivobj=document.getElementById("masterdiv")
		var window_width=ie && !window.opera? iebody.clientWidth : window.innerWidth-20
		window_height=ie && !window.opera? iebody.clientHeight : window.innerHeight
		var dsocleft=ie? iebody.scrollLeft : pageXOffset
		var masterdivwidth=masterdivobj.width
		masterdivheight=masterdivobj.height
		masterdivobj.style.left=(masterdivleft=="right")? window_width-masterdivwidth-20 : masterdivleft
		masterdivobj.style.width = TestimonialsScreenWidth + 'px'
		repositionitstart = setInterval("repositionit()", 5);
		refreshitstart = setInterval("refreshit()", 15000);
	}
	else{
	
	}
}

function repositionit(){
if (ie){
dsoctop=ie? iebody.scrollTop : pageYOffset
masterdivobj.style.top=(masterdivtop=="bottom")? window_height-masterdivheight-1+dsoctop : parseInt(masterdivtop)+dsoctop
if (masterdivobj.style.display== "none"){
	clearInterval(repositionitstart);
	clearInterval(refreshitstart);
	document.cookie="DTestls=yes";
}
}
}
function refreshit(){
	if (ie){
		dsoctop=ie? iebody.scrollTop : pageYOffset
		masterdivobj.style.top=(masterdivtop=="bottom")? window_height-masterdivheight-1+dsoctop : parseInt(masterdivtop)+dsoctop
		if (masterdivobj.style.zIndex== 999){
			clearInterval(refreshitstart);
		}
		else
		{
			if (CurrentPageNo < TotalTestPages){
			CurrentPageNo = parseInt(CurrentPageNo) + 1;
			}else
			{
			CurrentPageNo = 1;
			}
			masterdivobj.src = "/collection/TestimonialsiFrame.asp?page=" + CurrentPageNo;
			document.cookie="TestlsPg=" + CurrentPageNo;
		}
	}
}



if (window.attachEvent && get_Testimonials_cookie("DTestls")=="" ){
window.attachEvent("onload", positionit);

}
function hideit(){
clearInterval(repositionitstart);
clearInterval(refreshitstart);
masterdivobj.style.display= "none";
}


function get_Testimonials_cookie(Name) {
var search = Name + "="
var returnvalue = ""
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset)
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

