function openAvail (search,c,s) {
	var x = window.open (search+'?Style='+s+'&ColorAvl='+c,'availability','width=525,height=450,dependent=1,resizable=1,scrollbars=1,screenX=125,screenY=165,left=125,top=165');
}

function mailPop(search,s) {
	var myLink = location.href;
	var t = window.open (search+'?Notify=friend&Style='+s,'mail_popup', 'width=490,height=340,dependent=1,resizable=1,screenX=125,screenY=165,left=125,top=165');
}


function productPop (search,s) {
	window.open (search+'?Notify=product&Style='+s,'prd_notification_popup','width=525,height=480,dependent=1,resizable=1,screenX=125,screenY=165,left=125,top=165');
}

function productSpecificPop (search,s,p) {
	window.open (search+'?Notify=product&Style='+s+'&CWS_pulldown='+p,'prd_notification_popup','width=525,height=480,dependent=1,resizable=1,screenX=125,screenY=165,left=125,top=165');
}


function brandPop (search,s) {
	var z = window.open (search+'?Notify=brand&Style='+s,'brd_notification_popup','width=480,height=450,dependent=1,resizable=1,screenX=125,screenY=165,left=125,top=165');
}


function addtowebsitePop (url) {
	var z = window.open (url,'addtowebsite_popup','width=480,height=275,dependent=1,resizable=1,screenX=125,screenY=165,left=125,top=165');
}

function sizeChartPop (s) {
	window.open (s,'availability','width=475,height=400,dependent=1,scrollbars=1,resizable=1,screenX=125,screenY=165,left=125,top=165');
}

function switchColorImage(cid) {
	colorId = cid;
	if (colorId == "") {
		 return;
	} else {
		var multiCnt = multiCntMap[colorId];
		var label = '';
		if ((multiCnt & 1) > 0) label = 'View Larger Image & More Image Views';
		else if (multiCnt > 0) label = 'More Image Views';
		else if (zoomImageMaps[colorId] != null) label = 'View Larger Image';

		if (imageMaps[colorId] == null){
			document.viewImage.src = imgbase + imageMaps['DEFAULT'];
		} else {
			document.viewImage.src = imgbase + imageMaps[colorId];
		}

		var zoomlink = document.getElementById("zoomlink");
		if (zoomlink != null) {
			var thisobj = zoomlink.firstChild;
			if (thisobj != null) zoomlink.firstChild.nodeValue = label;
			else {
				var txt = document.createTextNode(label);
				zoomlink.appendChild(txt);
			}
		}

		var imagecolorobj = document.viewColorImage.imageColors;
		if (imagecolorobj != null) {
			var selectedindex = imagecolorobj.selectedIndex;
			var ctext = imagecolorobj.options[selectedindex].text;

			var viewedColor = document.getElementById("viewedColor");
			if (viewedColor != null) {
				var obj = viewedColor.firstChild;
				if (obj != null) viewedColor.firstChild.nodeValue = ctext;
				else {
					var ntxt = document.createTextNode(ctext);
					viewedColor.appendChild(ntxt);
				}
			}

			var viewedColor2 = document.getElementById("viewedColor2");
			if (viewedColor2 != null) {
				var obj2 = viewedColor2.firstChild;
				if (obj2 != null) viewedColor2.firstChild.nodeValue = ctext;
				else {
					var ntxt2 = document.createTextNode(ctext);
					viewedColor.appendChild(ntxt2);
				}
			}
		}

		if (document.getElementById("multiviews") != null) {
		if (multiCnt != null && multiCnt > 0) {
			var newselected = 0;
			showLayer("multiviews", 0);
			var p = 15;
			var inc = 35;
			for (var i = 1; i <= maxImg; i++) {
				if ((multiCnt & Math.pow(2, i - 1)) > 0) {
					if (newselected == 0) newselected = i;
					eval("document.thumb" + i + ".src=\'" + mcfileroot + colorId + "_dt" + i + ".jpg\';");
					eval("document.thumb" + i + ".width=\'30\';");
					eval("document.thumb" + i + ".height=\'30\';");
					showLayer("thumb" + i, p);
					p += inc;
				}
				else {
					eval("document.thumb" + i + ".src=\'\';");
					eval("document.thumb" + i + ".width=\'0\';");
					eval("document.thumb" + i + ".height=\'0\';");
					eval("document.thumb" + i + ".border=\'0\';");
					hideLayer("thumb" + i, 300);
				}
			}
			switchThumb(newselected);
			loadImage(colorId);
		}
		else {
			hideLayer("multiviews", 0);
			for (var i = 1; i <= maxImg; i++) {
				eval("document.thumb" + i + ".src=\'\';");
				eval("document.thumb" + i + ".width=\'0\';");
				eval("document.thumb" + i + ".height=\'0\';");
				eval("document.thumb" + i + ".border=\'0\';");
			}
			if (imageMaps[colorId] == null)
				document.viewImage.src = imgbase + imageMaps["DEFAULT"];
			else
				document.viewImage.src = imgbase + imageMaps[colorId];
		}
		}
	}
}

function switchThumb(o) {
	 eval("document.thumb" + selected + ".border=0;");
	 selected = o;
	 eval("document.thumb" + selected + ".border=1;");
	 document.viewImage.src = mcfileroot + colorId + "_lg" + selected + ".jpg";
}

function loadImage(cid) {
	if (myimages[cid] != null) return;
	var cnt = multiCntMap[cid];
	if (cnt > 0) {
		myimages[cid] = new Array();
		for (var j = 1; j <= maxImg; j++) {
			if ((cnt & Math.pow(2, j - 1)) > 0) {
				myimages[cid][j] = new Image();
				myimages[cid][j].src = mcfileroot + cid + "_lg" + j + ".jpg";
			}
		}
	}
	else {
		myimages[cid] = new Image();
		myimages[cid].src = imgbase + imageMaps[cid];
	}
}

function showLayer(o, p) {
	var layer = document.getElementById(o);
	var one = null;
	if (layer != null) one = layer.style;
	if (one != null) {
		one.visibility = "visible";
		one.display = "block";
		one.left = "" + p + "px";
	}
}

function hideLayer(o, p) {
	var layer = document.getElementById(o);
	var one = null;
	if (layer != null) one = layer.style;
	if (one != null) {
		one.visibility = "hidden";
		one.display = "none";
		one.left = "" + p + "px";
	}
}

//moved from detail.jsp -01/05/09 by nl

var newwindow;
function poptastic(url) {
   newwindow=window.open(url,'name','height=380,width=520,left=90,top=90,scrollbars=1');
   //newwindow=window.open("getCustomerImages.jsp",'name','height=220,width=260,left=90,top=90,scrollbars=1');
   if(window.focus){newwindow.focus()}
}

function popup(url, height, width) { 
   height = (height == null) ? 600 : height;
   width = (width == null) ? 525 : width;
        window.open(url, 'window','width=' + width + ',height=' + height + ',scrollbars=yes,resizable=1');
        return false;
}

//--Shahzad--
function newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
//alert(a_str_windowURL);
	if (parseInt(navigator.appVersion) >= 4) {
	  obj_window.window.focus();
	}
}

//used to sort color in buybox dropdown
function sortbytext(a,b){return a.text < b.text ? -1 : a.text > b.text ? 1 : 0;}
