/* Custom javascript functions */
var newwindow;
function custpoptastic1(url)
{
        
	newwindow=window.open(url,'name','height=768,width=1024,scrollbars=yes');
	if (window.focus) {
		newwindow.focus()
	}	
}

function updateColors() {
	alert('ABC 1234');
}

function changeAvailColors123() {
	alert('Change Avail Color 12345');
}

function showpopupad1() {
	showpopupad('images/lr_invit.jpg');
}
function showpopupad(url)
{
       
	var source = '<div style="position:relative; overlay: hidden; left: 0; top: 0;padding: 0px; margin-left: auto; margin-right: auto; margin-top: auto; margin-bottom:auto;">';
	source = source + '<iframe src="' + url + '" width="551" height="600" frameborder="0" scrolling="no" name="manufacturerWebsite"></iframe>';
	source = source + '</div><div><input type="button" onClick="$.modal.close();" value="Close" style="position: absolute; left:500px; top: 6px; z-index:9999;"/></div>'; 
		
	$.modal(source);
}

function custpoptastic(url)
{
        
	var source = '<div style="position:absolute;left:-50px; top: -310px; overlay: hidden; padding: 5px">';
	source = source + '<iframe src="' + url + '" width="680" height="780" frameborder="0" scrolling="no" name="manufacturerWebsite"></iframe>';
	source = source + '</div><div><input type="button" onClick="$.modal.close();" value="Close" style="position: absolute; left:570px; top: 5px; z-index:9999;"/></div>'; //<div style="float:right;"><input type="button" value="Close"/></div>
		
	$.modal(source);
}

function custpoptastic_tall(url)
{
        
	var source = '<div style="position:absolute;left:-50px; top: -310px; overlay: hidden; padding: 5px">';
	source = source + '<iframe src="' + url + '" width="680" height="1024" frameborder="0" scrolling="no" name="manufacturerWebsite"></iframe>';
	source = source + '</div><div><input type="button" onClick="$.modal.close();" value="Close" style="position: absolute; left:570px; top: 5px; z-index:9999;"/></div>'; //<div style="float:right;"><input type="button" value="Close"/></div>
		
	$.modal(source);
}

function cust_popuptopicwh(title,topic,w,h,scrollbars)
	{
	window.open('popup.aspx?title=' + title + '&topic=' + topic,'CustPopup41372','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + scrollbars + ',resizable=no,copyhistory=no,width=' + w + ',height=' + h + ',left=0,top=0');
	return (true);
	}

function custSelectColor(colorCode, colorSKU, styleCode) {
	if (document.getElementById("mainColor") != null) {
		document.getElementById("mainColor").value = colorCode;
	}
	if (document.getElementById("yawahIframe") != null) {
		document.getElementById("yawahIframe").src="http://www.dessy.com/yawah/lela.aspx?&ys=2&stylecode=" + styleCode + "&pcode=" + colorSKU +"&scode=";
	}
	$('.overlay').hide();
	if($('.pp-colors').length > 0) {
		$('.pp-colors').hide();
	}
}

function custSelectAccessoryColor(colorCode, colorSKU, styleCode) {
	
	if (document.getElementById("accessoryColor") != null) {
		document.getElementById("accessoryColor").value = colorCode;
	}
	
	var selectAccessoryColor = colorCode.substr(colorCode.indexOf(",") + 1);
	var newUrl = document.getElementById("yawahIframe").src.substr(0,document.getElementById("yawahIframe").src.indexOf("&scode"));
	//alert(newUrl);
	
	if (document.getElementById("yawahIframe") != null) {
		document.getElementById("yawahIframe").src=newUrl +"&scode=" + selectAccessoryColor;
	}
	if (document.getElementById("TextOption") != null) {
		document.getElementById("TextOption").value = colorCode;
	}
	$('.overlay').hide();
	if($('.pp-colors').length > 0) {
		$('.pp-colors').hide();
	}
}

function custUpdateImgMainColor() {
   if (document.getElementById("mainColor") != null &&
   	document.getElementById("ProductSKU") != null &&
   	document.getElementById("yawahIframe") != null) {
   	
   	var selectedColor = document.getElementById("mainColor").options[document.getElementById("mainColor").selectedIndex].value;
   	if (selectedColor.indexOf(",") >0) {
   	    var colorCode = selectedColor.substr(selectedColor.indexOf(",") + 1);
   	    var defaultAccessoryCode = "";
   	    if (document.getElementById("defaultAccessoryColor") != null) {
   	    	defaultAccessoryCode = document.getElementById("defaultAccessoryColor").value;
   	    }   	    
   	    document.getElementById("yawahIframe").src="http://www.dessy.com/yawah/lela.aspx?&ys=2&stylecode=" + document.getElementById("ProductSKU").value + "&pcode=" + colorCode +"&scode=" + defaultAccessoryCode;
   	}
   }
}

function custUpdateImgAccessoryColor() {
   if (document.getElementById("mainColor") != null &&
   	document.getElementById("ProductSKU") != null &&
   	document.getElementById("yawahIframe") != null) {
   	
   	var selectedColor = document.getElementById("mainColor").options[document.getElementById("mainColor").selectedIndex].value;
   	if (selectedColor.indexOf(",") >0) {
   	    var colorCode = selectedColor.substr(selectedColor.indexOf(",") + 1);
   	    var defaultAccessoryCode = "";
   	    var selectedAccessoryColor = document.getElementById("accessoryColor").options[document.getElementById("accessoryColor").selectedIndex].value;
   	    if (document.getElementById("TextOption") != null) {
	    		document.getElementById("TextOption").value = selectedAccessoryColor;
	    }
   	    if (selectedAccessoryColor.indexOf(",") >0) {
   	    	defaultAccessoryCode = selectedAccessoryColor.substr(selectedAccessoryColor.indexOf(",") + 1);
   	    	
   	    } else {
   	    	if (document.getElementById("defaultAccessoryColor") != null) {
   	    		defaultAccessoryCode = document.getElementById("defaultAccessoryColor").value;
   	    	}
   	    }
   	    document.getElementById("yawahIframe").src="http://www.dessy.com/yawah/lela.aspx?&ys=2&stylecode=" + document.getElementById("ProductSKU").value +"&scode=" + defaultAccessoryCode + "&pcode=" + colorCode ;   	    
   	}
   }
}



function testPopupCenter() {
	var w = 600;
	var h = 400;
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	var targetWin = window.open ('http://www.theweddinglibrarystore.com/bridesmaid/images/promo032011.jpg', 'ABC', 'width='+(w + 10) +', height='+(h+10)+', top='+top+', left='+left + ',status=no,toolbar=no,menubar=no');
}

function PopupCenter(pageURL, title,w,h) {
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+ w +', height='+h+', top='+top+', left='+left);
}

