// ===================================================================
// Author: Peter Dirickson
// WWW: 
//

function validate_max()
{
	var formObj = document.compareForm;
	var formLen = formObj.length;
	var maxChecksAllowed = formObj.maxChecksAllowed.value;
	var countChecked = 0;
	var sav_index = 0;
	var cmpStr = document.change_page.cmpstr.value;
	var arCmpStr = cmpStr.split(",");
	var countChecked = arCmpStr.length - 1;
	var index;
	for(i=0; i< formLen; i++)
	{
		if(formObj.elements[i].type=="hidden" && formObj.elements[i].name=="iscompare")
		{
			sav_index = i;
		}
		if(formObj.elements[i].type=="checkbox" && formObj.elements[i].checked){
			index= cmpStr.indexOf(formObj.elements[i].value);
			if(index == -1){
				countChecked++;
			}
		}
	}
		if (countChecked > maxChecksAllowed)
		{
			alert("Please select 5 or fewer items to compare.");
		}
		else
		{
			formObj.cmpstr.value = document.change_page.cmpstr.value;
			formObj.elements[sav_index].value="YES";
			//formObj.submit();
			document.change_page.submit();
		}
}

function add_remove_value(cmpValue)
{
	var str = document.change_page.cmpstr.value;
	var cmpValueLen = cmpValue.length;
	var newStr = "";
	var index = str.indexOf(cmpValue + ",");
	var strLen = str.length;
	if(index != -1){
		newStr = str.substr(0,index) + str.substr(index+cmpValueLen+1);
		//alert("1: " + newStr);
		//alert(index + "|" + eval(cmpValueLen+1));
	}
	else
	{
		if(str.length == 0){
			newStr = cmpValue + ",";
			//alert("2: " + newStr);
		}
		else{
			if(str.substr(strLen-1) != ","){
				newStr = str + ","  + cmpValue + ",";
				//alert("3: " + newStr);
			}
			else{
				newStr = str + cmpValue + ",";
				//alert("4: " + newStr);
			}
		}
	}
	document.change_page.cmpstr.value = newStr;
}

function popup(url) {
	window.open(url,'popupdemo','width=815,height=600,toolbar=no,resizable=yes,location=no,menubar=no,statusbar=no');
}

function truelook_popup(url) {
	window.open(url,'popuptruelookdemo','width=910,height=852,toolbar=no,resizable=yes,location=no,menubar=no,statusbar=no');
}

function enlarge(name, image) {
	window.open('enlarge.aspx?name=' + name + '&image=' + image,'popup_enlarge','width=455,height=370,toolbar=no,resizable=no,location=no,menubar=no,statusbar=no');
}

function enlarge2(name, image, width, height, width_popup, height_popup) {
	window.open('enlarge2.aspx?name=' + name + '&image=' + image + '&width=' + width + '&height=' + height,'popup_enlarge2','width=' + width_popup + ',height=' + height_popup + ',toolbar=no,resizable=no,location=no,menubar=no,statusbar=no');
}

function sendtoafriend() {
	window.open('email_friend.aspx','popup_sendtoafriend','width=255,height=260,toolbar=no,resizable=no,location=no,menubar=no');
}

function MM_openBrWindow(theURL,winName,features) { /*v2.0*/
	window.open(theURL,winName,features);
}
function highLight( who, x, y, w, h ) { } 
function highLightOff() { }
function bookMark(){
	if(window.external) { 
		external.AddFavorite( location.href, document.getElementsByTagName('TITLE')[0].innerHTML ); 
	}
}
