var browser;
var demoWin;
var urlI = "img/";
var qCounter = 1;
var pageStop = 0;
var qFlag = 1;
var oldID = "page01";
var productsPage = new Array (
	"wool.html",
	"carpet.html",
	"ceramic.html",
	"stone.html",
	"bhk.html",
	"wilsonart.html",
	"bamboo.html",
	"cork.html",
	"vinyl.html",
	"wood.html",
	"slate.html",
	"granite.html",
	"marble.html",
	"limestone.html",
	"flagstone.html",
	"travertine.html",
	"custom_carpet.html",
	"laminates.html");
	
var loadedImages = new Array (
	"btn_Home_on.gif",
	"btn_Products_on.gif",
	"btn_Instalation_on.gif",
	"btn_Specials_on.gif",
	"btn_ClientComments_on.gif",
	"btn_ContactUs_on.gif");

function preloadImages() {

	var xImages = new Array ();
                      
 		for (i=0; i < loadedImages.length; i++) {
			xImages[i] = new Image ();
			xImages[i].src = urlI + loadedImages[i];
		}
}

function doName(maxs,numb){
	snumb = ""+numb;	
	for (k=0; k < maxs-1; k++){if (snumb.length!=maxs) snumb = "0"+snumb;}	
	return snumb;	
}

function checkIt(nvalue) {
//	alert(nvalue);
	if (nvalue != -1) {
		document.location.href = productsPage[nvalue];
	}
}

function DoOver(iname) {	
	flag = (iname == undefined) ? 0 : 1;
	if(flag) nameButton = iname;
	document.images[nameButton].src = flag ? urlI+nameButton+"_on.gif" : urlI+nameButton+"_off.gif";
	if(!flag) nameButton = "";
}

function doPage (quant,flag,url) {
	qCounter = (flag) ? ++qCounter : --qCounter;
	
	if (!(qCounter<1) && !(qCounter>quant)) {
		id = "page"+doName(2,qCounter);
		document.getElementById(oldID).className = "page-off";
		document.getElementById(id).className = "page-on";
		oldID = id;
		
		if (qCounter+1>quant) {
			document.getElementById("nb-stop").className = "nb-on";
			pageStop = 1;
		}
		else if (pageStop == 1) {
			document.getElementById("nb-stop").className = "nb-off";
			pageStop = 0;
		}
		document.getElementById("nb-next").className = (qCounter+1>quant) ? "nb-off" : "nb-on";
//		document.getElementById("navi").className = (qCounter+1>quant) ? "navi-off" : "navi-on";
		
	}
	else if (qCounter<1) {parent.document.location.href=url}
}

function doPageZero() {
	qCounter = 1;
	id = "page"+doName(2,qCounter);
	document.getElementById(oldID).className = "page-off";
	document.getElementById(id).className = "page-on";
	document.getElementById("nb-stop").className = "nb-off";
	document.getElementById("nb-next").className = "nb-on";
	oldID = id;
}

function showRegPage() {
	qCounter = 2;
	id = "page"+doName(2,qCounter);
	document.getElementById(oldID).className = "page-off";
	document.getElementById(id).className = "page-on";
	document.getElementById("nb-next").className = "nb-on";
	document.getElementById("navi").className = "navi-on";
	oldID = id;
}

function doPage0 (quant,flag) {
	qCounter = (flag) ? ++qCounter : --qCounter;
	
	
	if (!(qCounter<1) && !(qCounter>quant)) {
		id = "page"+doName(2,qCounter);
		document.getElementById(oldID).className = "page-off";
		document.getElementById(id).className = "page-on";
		oldID = id;
		
		document.getElementById("nb-prev").className = (qCounter-1<1) ? "nb-off" : "nb-on";
		document.getElementById("nb-next").className = (qCounter+1>quant) ? "nb-off" : "nb-on";
		document.getElementById("navi").className = ((qCounter-1<1) || (qCounter+1>quant)) ? "navi-off" : "navi-on";
	}
}

function doPage2 (id) {
	document.getElementById(oldID).className = "page-off";
	document.getElementById(id).className = "page-on";
	oldID = id;
}

function multCarpet(){
	if ((document.calculator.width.value != null && document.calculator.width.value != 0) && (document.calculator.length.value != null && document.calculator.length.value != 0)) {
		document.calculator.product.value = document.calculator.width.value * document.calculator.length.value;
		document.calculator.yards.value = Math.round(((document.calculator.width.value * document.calculator.length.value)/9)*100)/100;
	}
}

function DoWin(namehtm,wwin,hwin) {
	if ((demoWin != null) && (!demoWin.closed)){demoWin.close()}
	eval("demoWin=window.open('"+namehtm+"', 'demonstrationWin', 'width="+wwin+",height="+hwin+",location=0,top=0')");
	demoWin.focus();	
}

function BrowserCheck(){
var b=navigator.appName;           
	if(b=="Netscape") browser="ns"                               
	else {
		if (navigator.userAgent.indexOf ("Opera") != -1) browser="opera";
		else if(b=="Microsoft Internet Explorer") browser="ie";		
	}                
}

var is=new BrowserCheck()

function doBookmark() {
var url = "http://www.renfloor.com/";
var title=document.title;
	if(browser=="ie") window.external.AddFavorite(url,title);
	if(browser=="opera") alert('Your browser requires that you\nPress Ctrl & T to Bookmark this page.'); 
	if(browser=="ns") alert('Your browser requires that you\nPress Ctrl & D to Bookmark this page.');   
}

/*<![CDATA[*/
var dom = (document.getElementById) ? true : false;
var moz = (dom && (navigator.appName=="Netscape")) ? true : false;

// Mozilla
function moveHintsN(e)
{
	xoff = window.pageXOffset + e.clientX +10;
	document.getElementById('hints').style.left = xoff + "px";
	document.getElementById('hints').style.top = window.pageYOffset + e.clientY + 10 + "px";
	document.getElementById('hints').style.visibility = "visible";
}

function hideHintsN(e)
{
	document.onmousemove = null;
	document.onmouseout = null;
    document.getElementById('hints').style.visibility = "hidden";
}

// IE
function moveHints()
{
	if (moz) return;
    xoff = 0;
    yoff = 0;
	xoff += window.event.clientX + document.documentElement.scrollLeft +10;
	yoff += window.event.clientY + document.documentElement.scrollTop + 10;
	document.getElementById('hints').style.left = xoff;
	document.getElementById('hints').style.top = yoff;
}

function hideHints()
{
	if (moz) return;
	document.getElementById('hints').style.visibility = "hidden";
}

function showHints(text)
{
	if (text == "") return;
	document.getElementById('hints').innerHTML = text;
	if (moz)
    { // for Mozilla
		document.onmousemove = moveHintsN;
		document.onmouseout = hideHintsN;
		return;
	}
    else
    { // for IE & Opera
		moveHints();
		document.getElementById('hints').style.visibility = "visible";
    }
}