/***************************************************************
no frames
****************************************************************/
if (top.location != self.location) {
  top.location = self.location;
}
/***************************************************************
Popup window
****************************************************************/
var ChildWindow= null;
var popupSettings = "status=no,toolbar=no,scrollbars=yes,menubar=no,location=yes,resizable=yes";
function launchWindow(url, winheight, winwidth, popupSettings) 
{
	if( ChildWindow != null && !ChildWindow.closed)	{
		ChildWindow.close();
	}

	winleft = (screen.width / 2) - (winwidth / 2);
	wintop = (screen.height / 2) - (winheight / 2);

	var popup = "height=" + winheight + ",width=" + winwidth + ",";
    if(navigator.userAgent.indexOf("AOL") == -1)
    	 popup += "left=" + winleft + ",top=" + wintop + ",";
	
	if (popupSettings == null || popupSettings == ""){
		popup += "status=no,scrollbars=yes,toolbar=no,menubar=no,location=no,resizable=yes";
	}else {
		popup += popupSettings;
	}
	ChildWindow = window.open(url, null, popup);
	ChildWindow.opener = self;
}

/***************************************************************
Search and newsletter text box effects
****************************************************************/
function clearIt(theText) {
	if (theText.value == theText.defaultValue) theText.value = ""
}

function replacetext(theText){
	if (theText.value == "") theText.value = "Model Name"
}

/***************************************************************
Compare Items
****************************************************************/
function CompareItems(ItemsInGrid,theForm){
	var CompareIds = "";
	var ItemsToCompare = 0;
	if (ItemsInGrid < 1){return;}
	for (i=0;i<ItemsInGrid;i++){
		var bChecked = eval("theForm.chkCompare" + i + ".checked")
		if (bChecked == true){
			var CompareID = eval("theForm.ProdID" + i + ".value");
			CompareIds += CompareID + ",";
			ItemsToCompare +=1; 
			}
	}
	if (ItemsToCompare >= 2){
		CompareIds = CompareIds.substring(0, CompareIds.length - 1);
		window.location = "CompareItems.aspx?CompareItems=" + CompareIds;
	}
	else{
		alert("Please check at least 2 items you want to compare.");
	}
}


/***************************************************************
Q&A
****************************************************************/
function toggleQuestion(tName, qName, aName){
	var title = document.getElementById(tName);
	if (title == null) return;
	var ans = document.getElementById(aName);
	if (ans == null) return;
	var que = document.getElementById(qName);
	if (ans.style.display == '')
	{
		if (que != null) que.style.display = 'none';
		ans.style.display = 'none';
	}else{
		if (que != null) que.style.display = '';
		ans.style.display = '';
	}
}

function expandQuestion(tName, qName, aName){
	var title = document.getElementById(tName);
	if (title == null) return;
	var ans = document.getElementById(aName);
	if (ans == null) return;
	var que = document.getElementById(qName);
	if (que != null) que.style.display = '';
	ans.style.display = '';
}

function collapseQuestion(tName, qName, aName){
	var title = document.getElementById(tName);
	if (title == null) return;
	var ans = document.getElementById(aName);
	if (ans == null) return;
	var que = document.getElementById(qName);
	if (que != null) que.style.display = 'none';
	ans.style.display = 'none';
}

function PrintWindow() {
	bV = parseInt(navigator.appVersion);
	if (bV >= 4) {
		window.print();
	}else{
		alert("Your browser doesn't support this feature please select File->Print");
	}
}

/***************************************************************
handleEnter from a textbox 
****************************************************************/
function handleEnter (field, event) {
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) {
		var i;
		for (i = 0; i < field.form.elements.length; i++)
			if (field == field.form.elements[i])
				break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
	else
		return true;
}      

function extracheck(obj){return !obj.disabled;}

function getExpand(item){
	obj = document.getElementById(item);
	visible = (obj.style.display != "none");
	key = document.getElementById("x" + item);
	if (visible){
		obj.style.display = "none";
 	}else{
		obj.style.display = "block";
	}
}
