//-------------------------------- Page Scroll --------------------------------------
function FindPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function ScrollTo(elementName)
{
		var el = document.all(elementName)
		if(el != null)
		{
			document.body.scrollTop = FindPosY(el)
		}
}

//------------------------------------ Open Window ----------------------------------

function OpenWindow(url,windowName,features)
{
	(window.open(url,windowName,features)).focus();
}

function OpenWindowNoFocus(url,windowName,features)
{
	window.open(url,windowName,features);
}

//-------------------------------------- Clock -------------------------------

function clock(counter)
{ 
	if (counter == 0)
		counter = 16;
  
	counter--;
	if (counter < 10)
		document.getElementById("spanClockCounter").innerHTML = "0" + counter;
	else	
		document.getElementById("spanClockCounter").innerHTML = counter;
		
	setTimeout("clock(" + counter + ")", 1000); 

}


//-------------------------------------- Text Blinking -------------------------------

function showText(iPauseTime, strTimeOutID, strElemID)
{
	document.getElementById(strElemID).style.visibility = "visible";
	document.getElementById(strTimeOutID).value = setTimeout("hideText(" + iPauseTime + ", '" + strTimeOutID + "', '" + strElemID + "')", iPauseTime);
}

function hideText(iPauseTime, strTimeOutID, strElemID)
{
	document.getElementById(strElemID).style.visibility = "hidden";
	document.getElementById(strTimeOutID).value = setTimeout("showText(" + iPauseTime + ", '" + strTimeOutID + "', '" + strElemID + "')", iPauseTime);
}

function stopBlinking(iPauseTime, strTimeOutID, strElemID)
{
	clearTimeout(document.getElementById(strTimeOutID).value);
	document.getElementById(strElemID).style.visibility = "visible";
}

function startBlinking(iPauseTime, strTimeOutID, strElemID)
{
	hideText(iPauseTime, strTimeOutID, strElemID);
}

//--------------------------------------- Css Class -------------------------------

function AddCssClass(id, className)
{
	var elem = document.getElementById(id); 	
	elem.className += " " + className;		
}

function RemoveCssClass(id, className)
{
	var elem = document.getElementById(id); 
	elem.className = elem.className.replace(" " + className, "");
}

//----------------------------------------- Image -----------------------------

function SwapImage(id, imagePath)
{
	var elem = document.getElementById(id); //image element
	elem.src = imagePath;
}

function SwapImage_TableCellBackground(id, imagePath)
{
	var elem = document.getElementById(id);
	elem.background = imagePath;
}

function setInnerHtml(id, str)
{
	var elem = document.getElementById(id); //image element
	elem.innerHTML = str;
}

function setValue(id, str)
{
	var elem = document.getElementById(id); //image element	
	elem.value=str;
}

//----------------------------------------- Window Page -----------------------------

function keyPressNumber(e)
{
	var keynum
	var keychar
	var numcheck
	if(window.event) // IE
		keynum = e.keyCode
	else if(e.which) // Netscape/Firefox/Opera
		keynum = e.which
	//alert(keynum);
	keychar = String.fromCharCode(keynum)
	numcheck = /\d/
	return (numcheck.test(keychar) || keynum==8 || keynum==undefined)

}

function changeImage(type,td)
{
	if(type=="type1")
	{
		SwapImage('windowImg','images/product/wind_SingleHung.jpg');
		setInnerHtml('divImgName','Single Hung Window');
		setValue('txtImgPath','images/product/wind_SingleHung.jpg');
		setValue('txtImgName','Single Hung Window');
		td.className = "colorOrange";
		
	}
	if(type=="type2")
	{
		SwapImage('windowImg','images/product/wind_2LiteSlider.jpg');
		setInnerHtml('divImgName','2 Lite Slider Window');					
		setValue('txtImgPath','images/product/wind_2LiteSlider.jpg');
		setValue('txtImgName','2 Lite Slider Window');
		td.className = "colorOrange";
	}
	if(type=="type3")
	{
		SwapImage('windowImg','images/product/wind_3LiteSlider.jpg');
		setInnerHtml('divImgName','3 Lite Slider Window');
		setValue('txtImgPath','images/product/wind_3LiteSlider.jpg');
		setValue('txtImgName','3 Lite Slider Window');
		td.className = "colorOrange";
	}
	if(type=="type4")
	{
		SwapImage('windowImg','images/product/wind_Picture.jpg');
		setInnerHtml('divImgName','Picture/Fixed Window');					
		setValue('txtImgPath','images/product/wind_Picture.jpg');
		setValue('txtImgName','Picture/Fixed Window');
		td.className = "colorOrange";
	}
	if(type=="type5")
	{
		SwapImage('windowImg','images/product/wind_FrenchDoor.jpg');
		setInnerHtml('divImgName','Patio Sliding Door');					
		setValue('txtImgPath','images/product/wind_FrenchDoor.jpg');
		setValue('txtImgName','Patio Sliding Door');
		td.className = "colorOrange";
	}
	
	
}

//--------------------------------------------------------------
function getScreenWidth()
{
	var screenW = 640;
	if (parseInt(navigator.appVersion)>3) {
	 screenW = screen.width;screenH = screen.height;
	}
	else if (navigator.appName == "Netscape" 
		&& parseInt(navigator.appVersion)==3
		&& navigator.javaEnabled()
	   ) 
	{
	 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
	 var jScreenSize = jToolkit.getScreenSize();
	 screenW = jScreenSize.width;
	 
	}
	return screenW;
}
//--------------------------------------------------------------
function getScreenHeight()
{
	var screenH = 480;
	if (parseInt(navigator.appVersion)>3) {
	 screenH = screen.height;
	}
	else if (navigator.appName == "Netscape" 
		&& parseInt(navigator.appVersion)==3
		&& navigator.javaEnabled()
	   ) 
	{
	 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
	 var jScreenSize = jToolkit.getScreenSize();
	 screenH = jScreenSize.height;
	}

	return screenH;
}

function showChatWindow()
{
	var screenW = getScreenWidth() -20-335;
	
	window.open('http://livechat.boldchat.com/aid/6298759397742012659/bc.chat?cwdid=5318077642110148986&amp;rdid=3203755654036797624&amp;vr=&amp;vn=&amp;vi=&amp;ve=&amp;vp=&amp;iq','_blank','width=320px,height=370px,left=' +screenW +',y=5px,resizable');
}
