/************* On Product Page, Opens up Large Image **********/
	function ProductPopUp() {
		$("product-detail-popup").style.display="block";
		$("black").style.height=$("doc2").scrollHeight + "px";
		$("black").style.display="block";
		IE6_IframeCtrl('OVER', $("product-detail-popup"))		
		//var tmpVar = (($("doc2").scrollHeight)-750)/2;
		//$("product-detail-popup").style.top=tmpVar + "px";
	}
	function closePopUpWindow() {
		$("product-detail-popup").style.display="none";
		$("black").style.display="none";
		IE6_IframeCtrl('OUT', $("product-detail-popup"))
	}
/*************************************************************/

/***********************  Swap Image *************************/
	function swapImage(DivID,whichAtt,colorName,img,src,lgimg,newMargin){
		DivIDgen = DivID.substring(0,DivID.length-1);
		var el=$(img);el.src=src;
		if(lgimg)el.setAttribute('largeImg',lgimg);
		el.style.margin=newMargin;
		if(document.getElementById('AvColorsCol'))document.getElementById('AvColorsCol').innerHTML=" ";
		if(document.getElementById('AdViewsCol'))document.getElementById('AdViewsCol').innerHTML=" ";
		if(document.getElementById('AcPopUp'))document.getElementById('AcPopUp').innerHTML=" ";
		if(document.getElementById('AvPopUp'))document.getElementById('AvPopUp').innerHTML=" ";		
		
		if(whichAtt=="MainColor")document.getElementById('AvColorsCol').innerHTML=" "+colorName;
		if(whichAtt=="MainAV")document.getElementById('AdViewsCol').innerHTML=" "+colorName;
		if(whichAtt=="ACPopUp")document.getElementById('AcPopUp').innerHTML=" "+colorName;
		if(whichAtt=="AvPopUp")document.getElementById('AvPopUp').innerHTML=" "+colorName;
			
		for(i=0; i<totalProdThumbs; i++) {
			var blab=(DivIDgen+i);
			if($(blab)!=null){
				$(blab).style.border="1px solid #8F8580";
			}
		}
		$(DivID).style.border="1px solid #c92127";
		
		}
	function open_win(urlpath,heightwidth){
		window.open(urlpath,null,heightwidth);
		}
		
/************************************************************/

/************ Update Sku Info on Prod Page ******************/
	function displaySkuInfo(selectBox, infoArray, PriceSpan) {
		if(selectBox.selectedIndex!=0) {
			var info = infoArray[selectBox.options[selectBox.selectedIndex].value];
			var strkAmt = "";
			if (eval(info.price) < eval(info.defprice)) {
				strkAmt = '<span class="strikethrough">$'+info.defprice+'</span>';
			}
			document.getElementById(PriceSpan).innerHTML = strkAmt + "<span class='ProdPagePrice'>$" + info.price + "</span>&nbsp;&nbsp;&nbsp;&nbsp;item # " + info.prodCode;
			if(PriceSpan=="DisplayPrice"){
				tmpStock = "Availability: ";
				tmpAvail = info.Availability;
				if (info.Availability!="INVAVL"){
					tmpStock = "Estimated Availability: ";
				}
				if (info.Availability!="INVAVL"){
					tmpAvail = "Uncertain - Get Notified Below";
					if(document.getElementById("AddButtonDiv")){
						document.getElementById("AddButtonDiv").style.display="none";
					}
					if(document.getElementById("ProdBtnRow")){
						document.getElementById("ProdBtnRow").style.display="none";
					}
					if(document.getElementById("AddToCompleteBtn")){
						document.getElementById("AddToCompleteBtn").style.display="none";
					}
					if(document.getElementById("frmNotifyMe")){
						document.getElementById("frmNotifyMe").style.display="block";
					}
				}
				if (info.Availability=="INVAVL"){
					tmpAvail = "<span style='color:green;'>In Stock</span>";
					if(document.getElementById("AddButtonDiv")){
						document.getElementById("AddButtonDiv").style.display="block";
					}
					if(document.getElementById("frmNotifyMe")){
						document.getElementById("frmNotifyMe").style.display="none";
					}
					if(document.getElementById("AddToCompleteBtn")){
						document.getElementById("AddToCompleteBtn").style.display="inline";
					}
					if(document.getElementById("ProdBtnRow")){
						document.getElementById("ProdBtnRow").style.display="block";
					}
				}
				if(document.getElementById('smallTextProdShipping')){
					document.getElementById('smallTextProdShipping').innerHTML = "<p><strong> " + tmpStock + "</strong>" + tmpAvail + "</p>"
				}
			}
		}
	}
/************************************************************/

/****************** Payment Type Selector *******************/

function swap_PayMethods(selValue) {
	hide_PayMethods();
	document.getElementById("type"+selValue).style.display="block";
}

function hide_PayMethods(){
	if(document.getElementById("typePMTCCD"))document.getElementById("typePMTCCD").style.display="none";
	if(document.getElementById("typePMTPOR"))document.getElementById("typePMTPOR").style.display="none";
	if(document.getElementById("typePMTWUN"))document.getElementById("typePMTWUN").style.display="none";
	if(document.getElementById("typePMTBML"))document.getElementById("typePMTBML").style.display="none";
	if(document.getElementById("typePMTPPL"))document.getElementById("typePMTPPL").style.display="none";
	if(document.getElementById("typePMTGVX"))document.getElementById("typePMTGVX").style.display="none";
	if(document.getElementById("typePMTMCR"))document.getElementById("typePMTMCR").style.display="none";
	if(document.getElementById("typePMTSGC"))document.getElementById("typePMTSGC").style.display="none";
	if(document.getElementById("typePMTCOD"))document.getElementById("typePMTCOD").style.display="none";
	if(document.getElementById("typePMTMOR"))document.getElementById("typePMTMOR").style.display="none";
}		

/************************************************************/
function validate_required(field,alerttxt) {
	with (field) {
		if (value==null||value=="") {
			alert(alerttxt);
			return false;
		} else {
			return true;
		}
	}
}

function validate_skuforms(thisform) {
	switch (thisform.name){
		case 'productSkuForm': {
			with (thisform) {
				for(i=0; i<elements.length; i++) {
					if (!validate_required(elements[i],"Error! Select a Size/Color")) {
						elements[i].focus();
						return false;	break;
					}
				}
			}
			return true; break;
		} case 'productBundleForm': {
			with (thisform) {
				for(i=0; i<elements.length; i++) {
					if (!validate_required(elements[i],"Error! Select a Size/Color")) {
						elements[i].focus();
						return false;	break;
					}
				}
			}
			return true; break;
		} default: {
			return true; break;
		}
	}
}

function displayProvinceDropDown(country_list,province_list,list) { 
	var country=""; 
	var pre_selected = list.value; country=country_list.value; 
	var provinces=null;
	for ( var i = 0; i < province_list.length; i++ ) { 
		if ( province_list[i].name==country ) { 
			provinces = province_list[i].provinces; break; 
		} 
	}
	list.innerHTML=""; 
	if (provinces==null || provinces.length == 0 ) { 
		list.style.visibility="hidden"; 
		$("state_label").style.visibility="hidden"; 
	} else { 
		list.style.visibility="visible"; 
		$("state_label").style.visibility="visible"; 
	}
	var o = document.createElement("option"); 
	o.innerHTML="Please Select A State/Province"; 
	list.appendChild(o);
	for ( var i = 0; i < provinces.length; i++ ) { 
		var province = provinces[i]; 
		var o = document.createElement("option"); 
		o.setAttribute("value", province.id); 
		o.innerHTML=province.name; 
		if ( province.id==pre_selected ) {
			o.setAttribute("selected", "selected"); 
		}
		list.appendChild(o); 
	} 
}

function CheckRightSku()
{
	if(document.getElementById('SKUSELECTION')){
		document.getElementById('formSkuID').value=document.getElementById('SKUSELECTION').value;
	}
}

function preload_HiddenImgs() {
	var arrObj = arrImgPreLoad.split(',');
	var execString =""
	for(i=1;i<arrObj.length;i++){
		var img = new Image(); img.src=arrObj[i];
	}
}