 //BEGIN USER EDIT TEXT////////////////////////////////////////////////////////
var myCost = "Cost";
var myItem = "Items";
var oneSide = "1 Side";
var twoSides = "2 Sides";
var price_text = "Price";
var text_design_ID = "Design ID";
var text_design_name = "Design Name";
var text_email = "Email";
var alert_saved_design1 = 'Design is blank. Cannot save blank designs!';
var alert_design_error1 = 'Design has errors - object is too wide or too tall';
var alert_name_error = 'Invalid Name - No special characters allowed alpha-nums only.';
var alert_invalid_email = 'Invalid Email Address';
var alert_failed_connection = 'Failed Connection';
var alert_question_submitted = 'Your question has been sent to us';
var alert_quote_submitted = 'Your request for a quote has been submitted.';
var alert_invalid_size = 'The current size is invalid for the selected product.';
var alert_invalid_size2 = 'Invalid Size for selected color.';
var alert_empty_lines = 'No empty lines allowed.';
var alert_empty_lines2 = 'Empty line has been removed.';
var alert_image_type = 'Incorrect image file type. File must be jpg, gif, bmp or png.';
var alert_leave_warn1 = 'Warning!';
var alert_leave_warn2 = 'You will lose any unsaved edits! Do you want to leave without saving?';
var alert_products_added = 'Product added to cart.';
var alert_delete1 = "Do you want to Delete the selected item?";
var alert_delete2 = "Deletion Warning";
var instant_quote_text = 'Can not provide instant pricing if design includes an image. Save your design and then request a quote.';
var setup_charges_text = 'Setup Charges:';
var max_colors_text = 'Max. Number of Colors:';
var button_no = 'No';
var button_yes = 'Yes';
var fontSizeMax = 200;
var fontSizeMin = 12;
var fontSizeDefault = 20;
 //END USER EDIT TEXT/////////////////////////////////////////////////////////
//LAYOUT MODULES JS
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } 
  else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
addLoadEvent(function() {
  document.getElementById('WEP_fogDiv').style.display = "none";
}); 
YAHOO.util.Event.onDOMReady(function() {
	MSB.$('WEP_fsedit').value = fontSizeDefault;
	var prodConfigLoad = MSB.$('WEP_prodConfigLoad').value;
	var root = loadMyXML('./includes/shop-defaults.xml?a='+Math.floor(Math.random()*10000));
	MSB.$('WEP_shopemail').value = root.getElementsByTagName('shopEmail')[0].childNodes[0].nodeValue;
	MSB.$('WEP_shopdomain').value = root.getElementsByTagName('shopDomain')[0].childNodes[0].nodeValue;
	MSB.$('WEP_moneySymbol').value = root.getElementsByTagName('moneySymbol')[0].childNodes[0].nodeValue;
	MSB.$('WEP_zencart').value = root.getElementsByTagName('zenCart')[0].childNodes[0].nodeValue;
	var XoffA = root.getElementsByTagName('Xoffset');
	var YoffA = root.getElementsByTagName('Yoffset');
	var x1 = parseInt(window.screen.width) - 1024;
	var Xoff = parseInt(MSB.$('WEP_designtool').offsetLeft) + x1; 
	var y1 = parseInt(window.screen.height) - 728;
	var Yoff = parseInt(MSB.$('WEP_designtool').offsetTop) + y1; 
	var root; 
	if (MSB.$('WEP_prodConfigLoad').value == 'default') {
		root = loadMyXML('./includes/wep-tool-config.xml?a='+Math.floor(Math.random()*10000));
	}
	else {
		root = loadMyXML('./configs/'+MSB.$('WEP_prodConfigLoad').value+'/includes/wep-tool-config.xml?a='+Math.floor(Math.random()*10000));
		YAHOO.util.Event.onAvailable('WEP_productitem', function () {
		MSB.$('WEP_productitem').style.backgroundImage = 'url("./configs/'+MSB.$('WEP_prodConfigLoad').value+'/products/products.jpg")';});
	} 
	var showDprice = root.getElementsByTagName('dynamicPricing')[0].childNodes[0].nodeValue;
	//var showQcart = root.getElementsByTagName('showQuickCart')[0].childNodes[0].nodeValue;
	//var showCKbutton = root.getElementsByTagName('showCheckoutButton')[0].childNodes[0].nodeValue;
	var showQsubmit = root.getElementsByTagName('showQuoteSubmission')[0].childNodes[0].nodeValue;
	var showAddCart = root.getElementsByTagName('showAddtoCart')[0].childNodes[0].nodeValue;
	var showPriceSheet = root.getElementsByTagName('showPriceSheet')[0].childNodes[0].nodeValue;
	var showOurDesigns = root.getElementsByTagName('showOurDesigns')[0].childNodes[0].nodeValue;
	var instantQuote = root.getElementsByTagName('instantQuote')[0].childNodes[0].nodeValue;
	var x,y; 
	if (showDprice.toLowerCase() != 'yes') {
		MSB.$('WEP_priceDiv').style.display = 'none';
	}
	if (showOurDesigns.toLowerCase() != 'yes') {
		MSB.$('WEP_launchSDbox').style.display = 'none';
	}
	if (showOurDesigns.toLowerCase() == 'yes') {
		loadourdesigns();
	} 
	YAHOO.namespace("example.container");
	YAHOO.example.container.panel8 = new YAHOO.widget.Panel("WEP_savedesignoverlay", { context:["WEP_savedesignbox", "tl", "bl"], width:"300px", visible: false, zIndex: 700, close: true } );
	YAHOO.example.container.panel8.render();
	YAHOO.example.container.panel9 = new YAHOO.widget.Panel("WEP_opendesignoverlay", { context:["WEP_opendesignbox", "tl", "bl"], width:"300px", visible: false, zIndex: 600, close: true } );
	YAHOO.util.Event.addListener("WEP_opendesignbox", "click", YAHOO.example.container.panel9.show, YAHOO.example.container.panel9, true);
	YAHOO.example.container.panel9.render();
	YAHOO.example.container.panel15 = new YAHOO.widget.Panel("WEP_searchdesignsoverlay", { context:["WEP_searchdesignbox", "tl", "bl"], visible: false, zIndex: 600, close: true} );
	YAHOO.util.Event.addListener("WEP_searchdesignbox", "click", YAHOO.example.container.panel15.show, YAHOO.example.container.panel15, true);
	YAHOO.example.container.panel15.render();
	//Product Selector
	YAHOO.example.container.panel4 = new YAHOO.widget.Panel("WEP_productsoverlay", { context:["WEP_showProductsbox", "tl", "bl"], width:"150px", height:"250px", visible: false, zIndex: 690, close: true } );
	YAHOO.util.Event.addListener("WEP_showProductsbox", "click", YAHOO.example.container.panel4.show, YAHOO.example.container.panel4, true);
	YAHOO.example.container.panel4.render();
	//Product Color Picker
	YAHOO.example.container.panel5 = new YAHOO.widget.Panel("WEP_productcolorsoverlay", { context:["WEP_showProductColorsbox", "tl", "bl"], width:"200px", height:"200px", visible: false, zIndex: 691, close: true } );
	YAHOO.util.Event.addListener("WEP_showProductColorsbox", "click", YAHOO.example.container.panel5.show, YAHOO.example.container.panel5, true);
	YAHOO.example.container.panel5.render();
	//COLOR PICKER
	YAHOO.example.container.panel1 = new YAHOO.widget.Panel("WEP_textboxoverlay", { context:["WEP_showtextbox", "tl", "bl"], width:"300px", visible: false, zIndex: 600,  close: true} );
	YAHOO.example.container.panel1.render(); 
	YAHOO.example.container.panel3 = new YAHOO.widget.Panel("WEP_fontboxoverlay", { context:["WEP_fontsmenubox", "tl", "bl"], width:"180px", visible: false, zIndex: 600, close: true } );
	YAHOO.util.Event.addListener("WEP_fontsmenubox", "click", YAHOO.example.container.panel3.show, YAHOO.example.container.panel3, true);
	YAHOO.example.container.panel3.render();
	YAHOO.example.container.panel2 = new YAHOO.widget.Panel("WEP_textcoloroverlay", { context:["WEP_showCPbox", "tl", "bl"], width:"200px", visible: false, zIndex: 600, close: true } );
	YAHOO.util.Event.addListener("WEP_showCPbox", "click", YAHOO.example.container.panel2.show, YAHOO.example.container.panel2, true);
	YAHOO.example.container.panel2.render();
	//stroke color
	YAHOO.example.container.panel2a = new YAHOO.widget.Panel("WEP_strokecoloroverlay", { context:["WEP_strokeBox", "tl", "bl"], width:"200px", visible: false, zIndex: 600, close: true } );
	YAHOO.util.Event.addListener("WEP_strokeBox", "click", YAHOO.example.container.panel2a.show, YAHOO.example.container.panel2a, true);
	YAHOO.example.container.panel2a.render();
	//FONTS LIST
	//OPEN SYMBOLS GALLERY
	YAHOO.example.container.panel6 = new YAHOO.widget.Panel("WEP_symoverlay", { context:["WEP_headerDiv", "tr", "br"], width:"240px", visible: false, zIndex: 600, close: true } );
	YAHOO.util.Event.addListener("WEP_launchsymbox", "click", YAHOO.example.container.panel6.show, YAHOO.example.container.panel6, true);
	YAHOO.example.container.panel6.render();
	//Custom Image Gallery Overlay
	YAHOO.example.container.panel7 = new YAHOO.widget.Panel("WEP_imagegalleryoverlay", { context:["WEP_headerDiv", "tr", "br"], width:"250px", visible: false, zIndex: 600, close: true } );
	YAHOO.util.Event.addListener("WEP_launchIGbox", "click", YAHOO.example.container.panel7.show, YAHOO.example.container.panel7, true);
	YAHOO.example.container.panel7.render();
	//Saved Design Complete Overlay
	YAHOO.example.container.panel10 = new YAHOO.widget.Panel("WEP_savecompleteoverlay", { fixedcenter: true, width:"600px", visible: false, zIndex: 901, close: false} );
	YAHOO.example.container.panel10.render(); 
	if (showAddCart.toLowerCase() == 'yes') {
		YAHOO.example.container.panel20 = new YAHOO.widget.Panel("WEP_addtocartoverlay", { fixedcenter: true, width:"400px", visible: false, zIndex: 902, close: true} );
		YAHOO.example.container.panel20.render();
	} 
	else {
		MSB.$('WEP_addtocartoverlay').style.display = 'none';
		MSB.$('WEP_SbuydesignBox').style.display = 'none';
		MSB.$('WEP_WbuydesignBox').style.display = 'none';
	} 

	if (showQsubmit.toLowerCase() == 'yes') {
		YAHOO.example.container.panel28 = new YAHOO.widget.Panel("WEP_quoteformoverlay", { xy:[250+Xoff,100+Yoff], width:"400px", visible: false, zIndex: 902, close: true} );
		YAHOO.example.container.panel28.render();
	//	var oButton = new YAHOO.widget.Button("WEP_SandQButton", {label: "Get My Quote"});
	//	YAHOO.example.container.panel29 = new YAHOO.widget.Panel("WEP_quoteintrooverlay", { xy:[250+Xoff,100+Yoff], width:"500px", visible: false, zIndex: 902, close: true} );
	//	YAHOO.util.Event.addListener("WEP_SandQDiv", "click", YAHOO.example.container.panel29.show, YAHOO.example.container.panel29, true);
	//	YAHOO.example.container.panel29.render();
	} 
	else {
	//	MSB.$('WEP_quoteintrooverlay').style.display = 'none';
		MSB.$('WEP_quoteformoverlay').style.display = 'none';
		MSB.$('WEP_SquotedesignBox').style.display = 'none';
		MSB.$('WEP_WquotedesignBox').style.display = 'none';
	//	MSB.$('WEP_SandQDiv').style.display = 'none';
	} 
	YAHOO.example.container.panel13 = new YAHOO.widget.Panel("WEP_savewaitoverlay", { fixedcenter: true, width:"400px", visible: false, zIndex: 990, close: true} );
	YAHOO.example.container.panel13.render();
	//ALERT - open design
	YAHOO.example.container.panel14 = new YAHOO.widget.Panel("WEP_opendesignAlert", { fixedcenter: true, width:"450px", height:"150px", visible: false, zIndex: 950, close: false} );
	YAHOO.example.container.panel14.render();
	YAHOO.example.container.panel132 = new YAHOO.widget.Panel("WEP_opendesignAlert2", { fixedcenter: true, width:"450px", height:"150px", visible: false, zIndex: 950, close: false} );
	YAHOO.example.container.panel132.render();
	//search designs overlay
	YAHOO.example.container.panel18 = new YAHOO.widget.Panel("WEP_productdescoverlay", { xy:[10+Xoff,65+Yoff], width:"110px", visible: false, zIndex: 690, close: true} );
	YAHOO.example.container.panel18.render();
	YAHOO.example.container.panel21 = new YAHOO.widget.Panel("WEP_welcomeoverlay", { xy:[100+Xoff,0+Yoff], width:"500px", visible: false, zIndex: 901, close: false} );
	YAHOO.example.container.panel21.render();
	YAHOO.example.container.panel22 = new YAHOO.widget.Panel("WEP_designreviewoverlay", { fixedcenter: true, width:"500px", visible: false, zIndex: 902, close: true} );
	YAHOO.example.container.panel22.render();
	YAHOO.example.container.panel23 = new YAHOO.widget.Panel("WEP_rotateoverlay", { xy:[10+Xoff,80+Yoff], width:"200px", visible: false, zIndex: 630, close: true} );
	YAHOO.util.Event.addListener("WEP_rotateBox", "click", YAHOO.example.container.panel23.show, YAHOO.example.container.panel23, true);
	YAHOO.example.container.panel23.render();
	YAHOO.example.container.panel24 = new YAHOO.widget.Panel("WEP_archoverlay", { xy:[0+Xoff,100+Yoff], width:"120px", visible: false, zIndex: 630, close: true} );
	YAHOO.util.Event.addListener("WEP_launchTpathbox", "click", YAHOO.example.container.panel24.show, YAHOO.example.container.panel24, true);
	YAHOO.example.container.panel24.render();
	YAHOO.example.container.panel25 = new YAHOO.widget.Panel("WEP_helpoverlay", { context:["WEP_helpiconbox", "tl", "bl"], width:"400px", visible: false, zIndex: 690, close: true} );
	YAHOO.util.Event.addListener("WEP_helpiconbox", "click", YAHOO.example.container.panel25.show, YAHOO.example.container.panel25, true);
	YAHOO.example.container.panel25.render();
	YAHOO.example.container.panel26 = new YAHOO.widget.Panel("WEP_contactusoverlay", { context:["WEP_emailiconbox", "tl", "bl"], width:"400px", visible: false, zIndex: 800, close: true} );
	YAHOO.util.Event.addListener("WEP_emailiconbox", "click", YAHOO.example.container.panel26.show, YAHOO.example.container.panel26, true);
	YAHOO.example.container.panel26.render(); 
	if (showPriceSheet.toLowerCase() == 'yes') {
		YAHOO.example.container.panel27 = new YAHOO.widget.Panel("WEP_pricesheetoverlay", { context:["WEP_showpriceshDiv", "tl", "bl"], width:"500px", visible: false, zIndex: 800, close: true} );
		YAHOO.util.Event.addListener("WEP_showpriceshDiv", "click", YAHOO.example.container.panel27.show, YAHOO.example.container.panel27, true);
		YAHOO.example.container.panel27.render();
	}
	else {
		MSB.$('WEP_pricesheetoverlay').style.display = 'none';
		MSB.$('WEP_showpriceshDiv').style.display = 'none';
	} 
	YAHOO.example.container.panel30 = new YAHOO.widget.Panel("WEP_stockoverlay", { context:["WEP_headerDiv", "tr", "br"], width:"200px", visible: false, zIndex: 801, close: true} );
	YAHOO.util.Event.addListener("WEP_launchSIGbox", "click", YAHOO.example.container.panel30.show, YAHOO.example.container.panel30, true);
	YAHOO.example.container.panel30.render();
	YAHOO.example.container.panel31 = new YAHOO.widget.Panel("WEP_shopdesignsoverlay", { context:["WEP_headerDiv", "tr", "br"], width:"400px", visible: false, zIndex: 802, close: true} );
	YAHOO.util.Event.addListener("WEP_launchSDbox", "click", YAHOO.example.container.panel31.show, YAHOO.example.container.panel31, true);
	YAHOO.example.container.panel31.render();
	//TEXT INPUT OVERLAY
	YAHOO.example.container.panel34 = new YAHOO.widget.Panel("WEP_TB2Div", { xy:[10+Xoff,300+Yoff], width:"120px", visible: true, zIndex: 620, close: false} );
	YAHOO.example.container.panel34.render(); 
	if (instantQuote.toLowerCase() == 'yes') {
		YAHOO.example.container.panel33 = new YAHOO.widget.Panel("WEP_IQpricingDiv", { xy:[10+Xoff,110+Yoff], width:"200px", visible: true, zIndex: 610, close: false} );
		YAHOO.example.container.panel33.render();
		MSB.$('WEP_colorCalc').value = 'yes';
	//	MSB.$('WEP_priceDiv2').display = 'none';
	//	var oButton = new YAHOO.widget.Button("WEP_DesignToCartButton", {label: "Add Design To Cart"});
	//	YAHOO.util.Event.on("WEP_DesignToCartButton", "click", addDesigntoCart);
	}
	else {
		MSB.$('WEP_IQpricingDiv').style.display = 'none';
	} 
	YAHOO.util.Event.addListener("WEP_showtextbox", "click", YAHOO.example.container.panel1.show, YAHOO.example.container.panel1, true);
	YAHOO.util.Event.on("WEP_savedesignbox", "click", designerrorcheck);
	YAHOO.util.Event.on("WEP_fontUp", "click", fsIncrease);
	YAHOO.util.Event.on("WEP_fontDown", "click", fsDecrease);
	YAHOO.util.Event.on("WEP_stkUp", "click", stkIncrease);
	YAHOO.util.Event.on("WEP_stkDown", "click", stkDecrease);
	YAHOO.util.Event.on("WEP_archUp", "click", function () {archadjust('up')});
	YAHOO.util.Event.on("WEP_archDown", "click", function () {archadjust('down')});
	YAHOO.util.Event.on("WEP_sel-F", "click", function () {changeproductloc('F')});
	YAHOO.util.Event.on("WEP_sel-B", "click", function () {changeproductloc('B')});
	YAHOO.util.Event.on("WEP_savedesignBox2", "click", savedesign);
	YAHOO.util.Event.on("WEP_opendesignBox2", "click", openwarn);
	YAHOO.util.Event.on("WEP_opendesignYesBox", "click", function () {opendesign('fromopen')});
	YAHOO.util.Event.on("WEP_opendesignNoBox", "click", cancelopen);
	YAHOO.util.Event.on("WEP_opendesignYesBox2", "click", function () {opendesign('fromstock')});
	YAHOO.util.Event.on("WEP_opendesignNoBox2", "click", cancelopen);
	YAHOO.util.Event.on("WEP_leftjustBox", "click", leftjustline);
	YAHOO.util.Event.on("WEP_rightjustBox", "click", rightjustline);
	YAHOO.util.Event.on("WEP_centerjustBox", "click", centerjustline);
	YAHOO.util.Event.on("WEP_deletelineBox", "click", dellinecheck);
	YAHOO.util.Event.on("WEP_moveforwardBox", "click", moveforward);
	YAHOO.util.Event.on("WEP_movebackBox", "click", moveback);
	YAHOO.util.Event.on("WEP_ObuydesignBox", "click", function () {fillcartBox2('O')});
	YAHOO.util.Event.on("WEP_SbuydesignBox", "click", fillcartBox1);
	YAHOO.util.Event.on("WEP_SnewdesignBox", "click", newdesign);
	YAHOO.util.Event.on("WEP_SeditdesignBox", "click", editdesign);	
//	YAHOO.util.Event.on("WEP_SeditdesignBox", "click", function () {opendesign('fromedit')});	
	YAHOO.util.Event.on("WEP_WbuydesignBox", "click", function () {fillcartBox2('W')});
	YAHOO.util.Event.on("WEP_WnewdesignBox", "click", Wnewdesign);
	YAHOO.util.Event.on("WEP_WeditdesignBox", "click", Weditdesign);
	YAHOO.util.Event.on("WEP_WsearchdesignBox", "click", Wsearchdesign);
//	YAHOO.util.Event.on("WEP_updatedebugBox", "click", updatedebug);
	YAHOO.util.Event.on("WEP_searchdesignsBox2", "click", showsearchresults);
	YAHOO.util.Event.on("WEP_StocartBox", "click", addtoCart);
	YAHOO.util.Event.on("WEP_WimageViewDiv", "click", function () {previewThumb('W')});
	YAHOO.util.Event.on("WEP_OimageViewBox", "click", function () {previewThumb('O')});
	YAHOO.util.Event.on("WEP_homeBox", "click", function () {leaveWarn('home')});
	YAHOO.util.Event.on("WEP_checkoutBox", "click", function () {leaveWarn('checkout')});
	YAHOO.util.Event.on("WEP_flipVBox", "click", function () {flip1('V')});
	YAHOO.util.Event.on("WEP_flipHBox", "click", function () {flip1('H')});
	YAHOO.util.Event.on("WEP_rotateBoxCCW", "click", function () {rotate('CCW')});
	YAHOO.util.Event.on("WEP_rotateBoxCW", "click", function () {rotate('CW')});
	YAHOO.util.Event.on("WEP_removearchBox", "click", function () {archadjust('X')});
	YAHOO.util.Event.on("WEP_CFsubmitbox", "click", CFsubmit);
	YAHOO.util.Event.on("WEP_QFsubmitbox", "click", QFsubmit);
	YAHOO.util.Event.on("WEP_SquotedesignBox", "click", function () {QFformload('S')}); 
	YAHOO.util.Event.on("WEP_refreshPriceDiv", "click", function () {getInstantQuote('wrk')}); 
	//CREATE BUTTONS
	var oButton = new YAHOO.widget.Button("WEP_savedesignButton");
	var oButton = new YAHOO.widget.Button("WEP_savedesignButton2");
	var oButton = new YAHOO.widget.Button("WEP_searchdesignsButton2")
	var oButton = new YAHOO.widget.Button("WEP_opendesignButton");
	var oButton = new YAHOO.widget.Button("WEP_opendesignButton2");
	var oButton = new YAHOO.widget.Button("WEP_opendesignYesButton");
	var oButton = new YAHOO.widget.Button("WEP_opendesignNoButton");
	var oButton = new YAHOO.widget.Button("WEP_opendesignYesButton2");
	var oButton = new YAHOO.widget.Button("WEP_opendesignNoButton2");
	var oButton = new YAHOO.widget.Button("WEP_searchdesignButton");
	var oButton = new YAHOO.widget.Button("WEP_showproductsButton");
	var oButton = new YAHOO.widget.Button("WEP_showProductColorsButton");
	var oButton = new YAHOO.widget.Button("WEP_fontsmenuButton");
	var oButton = new YAHOO.widget.Button("WEP_showtextButton");
	var oButton = new YAHOO.widget.Button("WEP_showCPButton");
	var oButton = new YAHOO.widget.Button("WEP_strokeButton");
	var oButton = new YAHOO.widget.Button("WEP_launchIGButton");
	var oButton = new YAHOO.widget.Button("WEP_launchSIGButton");
	var oButton = new YAHOO.widget.Button("WEP_launchsymButton");
	var oButton = new YAHOO.widget.Button("WEP_launchSDButton");
	var oButton = new YAHOO.widget.Button("WEP_imagegalformAddButton");
	var oButton = new YAHOO.widget.Button("WEP_leftjustButton");
	var oButton = new YAHOO.widget.Button("WEP_rightjustButton");
	var oButton = new YAHOO.widget.Button("WEP_centerjustButton");
	var oButton = new YAHOO.widget.Button("WEP_deletelineButton");
	var oButton = new YAHOO.widget.Button("WEP_moveforwardButton");
	var oButton = new YAHOO.widget.Button("WEP_movebackButton");
	var oButton = new YAHOO.widget.Button("WEP_newtextButton");
	var oButton = new YAHOO.widget.Button("WEP_replacetextButton");
	var oButton = new YAHOO.widget.Button("WEP_ObuydesignButton");
	var oButton = new YAHOO.widget.Button("WEP_opendesignButton2");
	var oButton = new YAHOO.widget.Button("WEP_SbuydesignButton");
	var oButton = new YAHOO.widget.Button("WEP_SquotedesignButton");
	var oButton = new YAHOO.widget.Button("WEP_WquotedesignButton");
	var oButton = new YAHOO.widget.Button("WEP_SnewdesignButton");
	var oButton = new YAHOO.widget.Button("WEP_SeditdesignButton");
	var oButton = new YAHOO.widget.Button("WEP_WbuydesignButton");
	var oButton = new YAHOO.widget.Button("WEP_WnewdesignButton");
	var oButton = new YAHOO.widget.Button("WEP_WeditdesignButton");
	var oButton = new YAHOO.widget.Button("WEP_WsearchdesignButton");
	var oButton = new YAHOO.widget.Button("WEP_StocartButton");
	var oButton = new YAHOO.widget.Button("WEP_sel-Fbutton");
	var oButton = new YAHOO.widget.Button("WEP_sel-Bbutton");
//	var oButton = new YAHOO.widget.Button("WEP_homeButton");
	var oButton = new YAHOO.widget.Button("WEP_helpButton");
	var oButton = new YAHOO.widget.Button("WEP_emailButton");
	var oButton = new YAHOO.widget.Button("WEP_priceSHButton");
	var oButton = new YAHOO.widget.Button("WEP_CFsubmitButton");
	var oButton = new YAHOO.widget.Button("WEP_QFsubmitButton");
	var oButton = new YAHOO.widget.Button("WEP_buydesignButton");
	var oButton = new YAHOO.widget.Button("WEP_WimageViewButton");
	var oButton = new YAHOO.widget.Button("WEP_OimageViewButton");
	var oButton = new YAHOO.widget.Button("WEP_rotateButton");
	var oButton = new YAHOO.widget.Button("WEP_flipVButton");
	var oButton = new YAHOO.widget.Button("WEP_flipHButton");
	var oButton = new YAHOO.widget.Button("WEP_launchTpathButton");
	var oButton = new YAHOO.widget.Button("WEP_rotateButtonCCW");
	var oButton = new YAHOO.widget.Button("WEP_rotateButtonCW");
	var oButton = new YAHOO.widget.Button("WEP_removearchButton");
});
function Wnewdesign() {
	YAHOO.example.container.panel21.hide();
}
function Weditdesign() {
	YAHOO.example.container.panel21.hide();
	MSB.$('WEP_open-design-id').value = MSB.$('WEP_Wopen-design-id').value;
	opendesign('fromopen');
}
function Wsearchdesign() {
	YAHOO.example.container.panel21.hide();
	YAHOO.example.container.panel15.show();
}
/*YAHOO.util.Event.onDOMReady(function() {
	YAHOO.namespace("example.container");
	if(7 > parseFloat(navigator.appVersion.split("MSIE")[1])) {
		YAHOO.example.container.panel23 = new YAHOO.widget.Panel("WEP_IEwarnDiv", { xy:[200,20], width:"500px", height:"300px", visible: false, zIndex: 906, close: true} );
		YAHOO.example.container.panel23.render();
		YAHOO.example.container.panel23.show();
	}
	previewThumb('W');
									 }); */
function previewThumb(from) {
	if (from == 'W') {
		var ID = MSB.$('WEP_Wopen-design-id').value;
	}
	if (from == 'O') {
		var ID = MSB.$('WEP_open-design-id').value;
	}
	if (ID.length > 0) {
		var root = loadMyXML("./saveddesigns/"+ID+"/"+ID+".xml");
		var numlinesFA = root.getElementsByTagName('numlinesfront');
		var numlinesF = numlinesFA[0].childNodes[0].nodeValue;
		var numlinesBA = root.getElementsByTagName('numlinesback');
		var numlinesB = numlinesBA[0].childNodes[0].nodeValue;
		var HTML = "";
		var HTML2 = "";
		var myDiv = MSB.$('WEP_WimageDiv');
		if (numlinesF > 0) {
			HTML = HTML + '<img src="./saveddesigns/'+ID+'/'+ID+'-thumbF.png" />&nbsp;&nbsp;';
			HTML2 = HTML2 + '<img src="./saveddesigns/'+ID+'/'+ID+'-F.png" /><br /><br />';
		}
		if (numlinesB > 0) {
			HTML = HTML + '<img src="./saveddesigns/'+ID+'/'+ID+'-thumbB.png" /><br />';
			HTML2 = HTML2 + '<img src="./saveddesigns/'+ID+'/'+ID+'-B.png" /><br />';
		}
		if (from == 'W') {
			myDiv.innerHTML = HTML;
			YAHOO.example.container.panel22.show();
		}
		if (from == 'O') {
			YAHOO.example.container.panel22.show();
		}
		var myDiv = MSB.$('WEP_designreviewDiv');
		myDiv.innerHTML = HTML2;
	}
}
function myTime() {
	var mydate = new Date();
	var myhours = mydate.getHours();
	var mymins = mydate.getMinutes();
	var mysecs = mydate.getSeconds();
	var mymilli = mydate.getMilliseconds();
	var totaltime = myhours+mymins+mysecs+mymilli;
	return totaltime;
}
function pngMSIE(source,height,width,i) {
	var view = MSB.$('WEP_actloc').value;
	if (MSB.$('WEP_currentFMT').value == 'text' || MSB.$('WEP_currentFMT').value == 'symbol') {
		MSB.$('WEP_divimg'+i).style.backgroundImage = 'url("' + source + '")';
	}
	if (MSB.$('WEP_currentFMT').value == 'image' || MSB.$('WEP_currentFMT').value == 'stock') {
		var newChild = document.createElement('IMG');
		var parent = MSB.$('WEP_divimg'+i);
		var newID = 'WEP_divimI'+i;
		newChild.setAttribute('id',newID);
		newChild.setAttribute('src',source);
		newChild.setAttribute('height',height);
		newChild.setAttribute('width',width);
		parent.appendChild(newChild);
		var newheight = height+"px";
		var newwidth = width+"px";
		YAHOO.util.Event.on(newID, "click", divdown);
		YAHOO.util.Event.on(newID, "mouseup", function() {divup(MSB.$('WEP_currentFMT').value);});
	}
}
//handle ondown of each line of text
function divdown(e) {
	if (MSB.$('WEP_actline').value != 'none') {
		var actline = MSB.$('WEP_actline').value;
		var actindex = actline.substring(6);
		MSB.$('WEP_divimg' + actindex).style.border = "none";
	} 
	var elTarget = YAHOO.util.Event.getTarget(e);	
	elTarget = elTarget.id;
	var mydiv = "WEP_divimg"+elTarget.substring(10);
	MSB.$(mydiv).style.border = "dashed 1px #ffff00";
	var textind = "WEP_tx" + elTarget.substring(10);
	var ind = elTarget.substring(10);
	var mytext = MSB.$(textind).value;
	if (MSB.$('WEP_format' + ind).value == 'text') {
		MSB.$('WEP_currentFMT').value = 'text';
		MSB.$('WEP_edittextbox').value = mytext;
		MSB.$('WEP_fsedit').value = MSB.$("WEP_fs" + ind).value;
		MSB.$('WEP_stkedit').value = MSB.$("WEP_stkw" + ind).value;
	}
	if (MSB.$('WEP_format' + ind).value == 'symbol') {
		MSB.$('WEP_currentFMT').value = 'symbol';
		MSB.$('WEP_edittextbox').value = '';
		MSB.$('WEP_curSymCode').value = mytext;
		MSB.$('WEP_curSymFT').value = MSB.$('WEP_ft'+ind).value;
	}
	if (MSB.$('WEP_format' + ind).value == 'image') {
		MSB.$('WEP_currentFMT').value = 'image';
		MSB.$('WEP_edittextbox').value = '';
	}
	if (MSB.$('WEP_format' + ind).value == 'stock') {
		MSB.$('WEP_currentFMT').value = 'stock';
		MSB.$('WEP_edittextbox').value = '';
	}
	MSB.$('WEP_actline').value = textind;
}
function divup(who) {
	var format = MSB.$('WEP_currentFMT').value;
	var loc = MSB.$('WEP_actloc').value;
	var actindex = MSB.$('WEP_actline').value.substring(6);
	var newleft = parseInt(MSB.$('WEP_divimg'+actindex).style.left);
	var newtop = parseInt(MSB.$('WEP_divimg'+actindex).style.top);
	var height = parseInt(MSB.$('WEP_divimg'+actindex).style.height);
	var width = parseInt(MSB.$('WEP_divimg'+actindex).style.width);
	var heightPX = height + "px";
	var widthPX = width + "px";
	MSB.$('WEP_left'+actindex).value = newleft;
	MSB.$('WEP_top'+actindex).value = newtop;
	if (format == 'image' || format == 'stock') {
		var myimg = MSB.$('WEP_divimI'+actindex);
		myimg.style.height = heightPX;
		myimg.style.width = widthPX;
		MSB.$('WEP_Himg'+actindex).value = height;
		MSB.$('WEP_Wimg'+actindex).value = width;	
	}
	checkboundaries();
}
function divup2(who) {
	var updatesize = 0;
	var actindex = MSB.$('WEP_actline').value.substring(6);
	var oldWidth = MSB.$('WEP_Wimg'+actindex).value;
	var newleft = parseInt(MSB.$('WEP_divimg'+actindex).style.left);
	var newtop = parseInt(MSB.$('WEP_divimg'+actindex).style.top);
	var height = parseInt(MSB.$('WEP_divimg'+actindex).style.height);
	var width = parseInt(MSB.$('WEP_divimg'+actindex).style.width);
	if (oldWidth != width) {
		MSB.$('WEP_Wimg'+actindex).value = width;
		updatesize = 1;
	}
	if (updatesize == 1) {
		MSB.$('WEP_fs' + actindex).value = width;
		editsymbol('WEP_fromeditfs');
	}
	MSB.$('WEP_left'+actindex).value = newleft;
	MSB.$('WEP_top'+actindex).value = newtop;
	checkboundaries();
}
function turnoffBorders() {
	var loc = MSB.$('WEP_actloc').value;
	var parent = MSB.$('WEP_printArea'+loc);
	var imgs = parent.getElementsByTagName('DIV');
	for (var i=0;i < parent.childNodes.length;i++) {
		MSB.$(imgs[i]).style.border = 'none';
	}
}		
function deletetext() {
	var lineindex = MSB.$('WEP_actline').value.substring(6);
	var loc = MSB.$('WEP_actloc').value;
	if (MSB.$('WEP_numlines' + loc ).value != 0) {
		document.getElementById("WEP_tx" + lineindex).value = "";
		var newnumlines = parseInt(MSB.$('WEP_numlines' + loc ).value) - 1;
		MSB.$('WEP_numlines' + loc).value = newnumlines;
		MSB.$('WEP_actline').value = 'none';
		MSB.$('WEP_edittextbox').value = '';
		var mydiv = MSB.$('WEP_divimg' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('WEP_tx' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('WEP_loc' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('WEP_format' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('WEP_ft' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('WEP_fc' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('WEP_fs' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('WEP_left' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('WEP_top' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('WEP_Wimg' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('WEP_Himg' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('WEP_Zind' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('WEP_flipV' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('WEP_flipH' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		mydiv = MSB.$('WEP_rot' + lineindex);
		mydiv.parentNode.removeChild(mydiv);
		if (MSB.$('WEP_stkc' + lineindex)) {
			mydiv = MSB.$('WEP_stkc' + lineindex);
			mydiv.parentNode.removeChild(mydiv);
		}
		if (MSB.$('WEP_stkw' + lineindex)) {
			mydiv = MSB.$('WEP_stkw' + lineindex);
			mydiv.parentNode.removeChild(mydiv);
		}
		if (MSB.$('WEP_arch' + lineindex)) {
			mydiv = MSB.$('WEP_arch' + lineindex);
			mydiv.parentNode.removeChild(mydiv);
		}
	}
}
function flip1(dir) {
	var ID = MSB.$('WEP_design_id').value;
	var lineindex = MSB.$('WEP_actline').value.substring(6);
    var fmt = MSB.$('WEP_format'+lineindex).value;
    var flipbool = MSB.$('WEP_flip'+dir+lineindex).value;
	if (flipbool == 'no') {
		MSB.$('WEP_flip'+dir+lineindex).value = 'yes';
	}
	else {
		MSB.$('WEP_flip'+dir+lineindex).value = 'no';
	}
    var wimg = MSB.$('WEP_Wimg'+lineindex).value;
    var himg = MSB.$('WEP_Himg'+lineindex).value;
    var ext = MSB.$('WEP_fs'+lineindex).value;
	var junk=myTime();
	if (fmt == 'text' || fmt == 'symbol') {
		var ind = lineindex;
	}
	if (fmt == 'image') {
		var ind = MSB.$('WEP_tx'+lineindex).value;
	}
	if (fmt == 'stock') {
		var indA = MSB.$('WEP_tx'+lineindex).value.split('.');
		var ind = indA[0];
		ext = indA[1];
	}
    var img = new Image();
    img.source = './encrypted/flip.php?fmt='+fmt+'&wimg='+wimg+'&himg='+himg+'&ind='+ind+'&F='+dir+'&ext='+ext+'&j='+junk+'&ID='+ID;
   	if (fmt == 'text' || fmt == 'symbol') {
		pngMSIE(img.source,himg,wimg,ind);
	}
	if (fmt == 'image' || fmt == 'stock') {
		MSB.$('WEP_divimI'+lineindex).src = img.source;
	}
}
function rotate(dir) {
	var ID = MSB.$('WEP_design_id').value;
	var lineindex = MSB.$('WEP_actline').value.substring(6);
   	var fmt = MSB.$('WEP_format'+lineindex).value;
	if (fmt == 'text') {
		var rot = Math.abs(parseInt(MSB.$('WEP_rotedit').value));
	}
	else {
		var rot = 90;
	}
	if (dir == "CCW") {
		rot = "-"+rot;
		rot = parseInt(rot);
	}
	if (fmt == 'text') {
		var rot = parseInt(MSB.$('WEP_rot'+lineindex).value) + rot;
		if (Math.abs(rot) == 360) {
			rot = 0;
		}
		MSB.$('WEP_rot'+lineindex).value = rot;
		edittext('fromupdate');
	}
	if (fmt == 'symbol') {
		var rot = parseInt(MSB.$('WEP_rot'+lineindex).value) + rot;
		if (Math.abs(rot) == 360) {
			rot = 0;
		}
		MSB.$('WEP_rot'+lineindex).value = rot;
		editsymbol('fromeditrot');
	}    
	if (fmt == 'image' || fmt == 'stock') {
		if (Math.abs(parseInt(MSB.$('WEP_rot'+lineindex).value) + rot) == 360) {
			MSB.$('WEP_rot'+lineindex).value = '0';
		}
		else {
			MSB.$('WEP_rot'+lineindex).value = parseInt(MSB.$('WEP_rot'+lineindex).value) + rot;
		}
		var junk=myTime();
		var myimg = MSB.$('WEP_divimI'+lineindex);
		var ind = MSB.$('WEP_tx'+lineindex).value;
		var ext = MSB.$('WEP_fs'+lineindex).value;
		if (fmt == 'stock') {
			var indA = MSB.$('WEP_tx'+lineindex).value.split('.');
			var ind = indA[0];
			var ext = indA[1];
		}
		var oldH = MSB.$("WEP_Himg" + lineindex).value;
		var oldW = MSB.$("WEP_Wimg" + lineindex).value;
		var img = new Image();
		img.source = './encrypted/rotate.php?ind='+ind+'&F='+dir+'&ext='+ext+'&j='+junk+'&rot='+rot+'&ID='+ID+'&fmt='+fmt;
		myimg.src = img.source;
		myimg.style.height = oldW + "px";
		myimg.style.width = oldH + "px";
		MSB.$("WEP_divimg" + lineindex).style.height = oldW + "px";
		MSB.$("WEP_divimg" + lineindex).style.width = oldH + "px";
		MSB.$("WEP_Himg" + lineindex).value = oldW;
		MSB.$("WEP_Wimg" + lineindex).value = oldH;
	} 
}
function archadjust(dir) {
	var cancel = false;
	var ID = MSB.$('WEP_design_id').value;
	var lineindex = MSB.$('WEP_actline').value.substring(6);
   	var fmt = MSB.$('WEP_format'+lineindex).value;
	if (fmt == 'text') {
		var junk=myTime();
		if (dir == 'X') {
			MSB.$('WEP_arch'+lineindex).value = '0';
			var arch = '0';
			var img = new Image();
			//img.source = './images/'+ID+'/tx'+lineindex+'.png';
			var W = MSB.$('WEP_Wimg'+lineindex).value;
			var H = MSB.$('WEP_Himg'+lineindex).value;
			img.source = './encrypted/gettx.php?ID='+ID+'&ind='+lineindex+'&j='+junk;
			MSB.$('WEP_divimg'+lineindex).style.height = H + "px";
			pngMSIE(img.source,H,W,lineindex);
		}
		else {	
			var H1 = parseInt(MSB.$('WEP_Himg'+lineindex).value)*.20;
			H1 = Math.round(H1);
			if (dir == 'up') {
				var arch = parseInt(MSB.$('WEP_arch'+lineindex).value) - H1;
				if (arch == 0) {
					cancel = true;
				}
				MSB.$('WEP_arch'+lineindex).value = arch;
			}
			else {
				var arch = parseInt(MSB.$('WEP_arch'+lineindex).value) + H1;
				if (arch == 0) {
					cancel = true;
				}
				MSB.$('WEP_arch'+lineindex).value = arch;
			}
			if (cancel === true) {
				MSB.$('WEP_arch'+lineindex).value = '0';
				var arch = '0';
				var img = new Image();
				//img.source = './images/'+ID+'/tx'+lineindex+'.png';
				var W = MSB.$('WEP_Wimg'+lineindex).value;
				var H = MSB.$('WEP_Himg'+lineindex).value;
				img.source = './encrypted/gettx.php?ID='+ID+'&ind='+lineindex+'&j='+junk;
				MSB.$('WEP_divimg'+lineindex).style.height = H + "px";
				pngMSIE(img.source,H,W,lineindex);
			}
			else {
				var W = MSB.$('WEP_Wimg'+lineindex).value;
				var W2 = Math.round(2*W);
				var H = parseInt(MSB.$('WEP_Himg'+lineindex).value)+Math.abs(arch);
				//MSB.$('Himg'+lineindex).value = H;
				MSB.$('WEP_divimg'+lineindex).style.height = H + "px";
				var img = new Image();
				img.source = './encrypted/arch.php?ar='+arch+'&W='+W2+'&ind='+lineindex+'&j='+junk+'&ID='+ID;
				pngMSIE(img.source,H,W,lineindex);
				//MSB.$("divimg" + lineindex).style.backgroundPosition = "0px 5px";
			}
		}
	}
}
//add event trigers for text editing buttons
YAHOO.util.Event.on("WEP_replacetextButtonDiv", "click", updatetext);
YAHOO.util.Event.on("WEP_delB", "click", deletetext);
YAHOO.util.Event.on("WEP_newtextButtonDiv", "click", addnewtext);
YAHOO.util.Event.on("WEP_imagegalformAddBox", "click", togallery);
function makedragable() {
	var myDiv = "WEP_divimg" + MSB.$('WEP_actline').value.substring(6);
	var dd = new YAHOO.util.DD(myDiv);
}
/*function leaveWarn(mylink) {
	mySimpleDialog = new YAHOO.widget.SimpleDialog("WEP_leaveWarnOverlay", { 
	fixedcenter:true,
	modal:false,
    visible:false,
	draggable:false,
	zIndex:1001
	});
	mySimpleDialog.setHeader(alert_leave_warn1);
	mySimpleDialog.setBody(alert_leave_warn2);
	mySimpleDialog.cfg.setProperty("icon",YAHOO.widget.SimpleDialog.ICON_WARN);
	var handleYes = function() {
		this.hide();
	 	switch (mylink) {
			case 'home':
			window.location= './php/go-home.php';
			break;
			case 'checkout':
			window.location ='./php/go-cart.php';
			break;
		}
	}
	var handleNo = function() {
	 this.hide();
	}
	var myButtons = [ {text: button_no, 
						handler:handleNo,
						isDefault:true },
						{text: button_yes, 
						handler:handleYes,
						isDefault:false }];
	mySimpleDialog.cfg.queueProperty("buttons", myButtons);
	mySimpleDialog.render(MSB.$('WEP_designtool'));
	mySimpleDialog.show();
} */
function designerrorcheck() {
	var error = false;
	if (MSB.$('WEP_numlinesF').value == '0' && MSB.$('WEP_numlinesB').value == '0') {
		alert(alert_saved_design1);
		return;
	}
	error = checktextwidthErr();
	if (error === true) {
		alert(alert_design_error1);
	}
	if (MSB.$('WEP_colorCalc').value == 'yes') {
		error = checkmaxcolors();
		if (error === true) {
			alert(alert_max_numcolors);
		}
	}
	if (error === false) {
		YAHOO.example.container.panel8.show();
	}
}
function checktextwidthErr() {
	var err = false;
	var list = MSB.$('WEP_designParList');
	var elements = list.getElementsByTagName('INPUT');
	for (var i=0;i < elements.length;i++) {
		var par = elements.item(i).getAttribute('id');
		var par2 = par.substring(4,4);
		if (par2 == 'Wimg') {
			var W = parseInt(MSB.$(par).value);
			var loc = MSB.$('WEP_loc'+par.substring(8)).value;
			if (W > MSB.$('WEP_printarea'+loc+'W').value) {
				err = true;
			}
		}
		if (par2 == 'Himg') {
			var H = parseInt(MSB.$(par).value);
			var loc = MSB.$('WEP_loc'+par.substring(8)).value;
			if (H > MSB.$('WEP_printarea'+loc+'H').value) {
				err = true;
			}
		}
	}
	return err;
}
function checkmaxcolors() {
	calcNumColors();
	if (MSB.$('WEP_numcolorsF').value > MSB.$('WEP_maxNumColors').value || MSB.$('WEP_numcolorsB').value > MSB.$('WEP_maxNumColors').value) {
		return true;
	}
	else {
		return false;
	}
}
function savedesign() {
	if (MSB.$('WEP_colorCalc').value == 'yes') {
		calcNumColors();
		//check for max color 
	}
	else {
		savedesignA();
	}
}
function savedesignA() {
	if (MSB.$('WEP_colorCalc').value == 'yes') {MSB.$('WEP_fs' + lineindex).value = newfs;
			edittext('fromeditfs');
		getInstantQuote('S');
	}
	//cleanup design
	var isvalid = true;
	isvalid = WAValidateAN(document.WEP_formSaveDesign.WEP_design_name,document.WEP_formSaveDesign.WEP_design_name.value,alert_name_error,true,true,true,true,'',document.WEP_formSaveDesign.WEP_design_name,1,true);
	if (isvalid == false) {
		alert(alert_name_error);
	}
	if (isvalid == true) {
		isvalid = WAValidateEM(document.WEP_formSaveDesign.WEP_emailadd,document.WEP_formSaveDesign.WEP_emailadd.value,alert_invalid_email,document.WEP_formSaveDesign.WEP_emailadd,1,true);
		if (isvalid == false) {
			alert(alert_invalid_email);
		}
		if (isvalid == true) {
			YAHOO.example.container.panel13.show();
			MSB.$('WEP_prodFW').value = MSB.$('WEP_printareaFW').value;
			MSB.$('WEP_prodFH').value = MSB.$('WEP_printareaFH').value;
			MSB.$('WEP_prodBW').value = MSB.$('WEP_printareaBW').value;
			MSB.$('WEP_prodBH').value = MSB.$('WEP_printareaBH').value;
			var successHandler = function(o) {
				var status = o.responseText;
			//	alert(status);
				var myDiv = MSB.$('WEP_savedinfoBox');
				var HTML = text_design_ID+": "+ MSB.$('WEP_design_id').value + '<br />'+text_design_name+': ' + MSB.$('WEP_design_name').value + '<br />'+text_email+': '+MSB.$('WEP_emailadd').value + '<br />';
				if (MSB.$('WEP_numlinesF').value > 0) {
					HTML = HTML + '<img src="./saveddesigns/'+MSB.$('WEP_design_id').value+'/'+MSB.$('WEP_design_id').value+'-thumbF.png" />&nbsp;&nbsp;';
				}
				if (MSB.$('WEP_numlinesB').value > 0) {
					HTML = HTML + '<img src="./saveddesigns/'+MSB.$('WEP_design_id').value+'/'+MSB.$('WEP_design_id').value+'-thumbB.png" /><br />';
				}
				myDiv.innerHTML = HTML
			//	MSB.$('fogDiv').style.visibility = "visible";
				YAHOO.example.container.panel13.hide();
				YAHOO.example.container.panel8.hide();
				YAHOO.example.container.panel10.show();
			//	getprodSizes();
			}
			var failureHandler = function(o) {
				alert (alert_failed_connection)
			}
			var callback = {
				success: successHandler,
				failure: failureHandler
			}
			YAHOO.util.Connect.setForm("WEP_formSaveDesign");
			var cObj = YAHOO.util.Connect.asyncRequest('POST', './save-dataSQL.php', callback);
		}
	}
}
function CFsubmit() {
	MSB.$('WEP_CFshopemail').value = MSB.$('WEP_shopemail').value;
	MSB.$('WEP_CFshopdomain').value = MSB.$('WEP_shopdomain').value;
	MSB.$('WEP_CFdesignID').value = MSB.$('WEP_design_id').value;
	var isvalid = true;
	isvalid = WAValidateAN(document.WEP_contactForm.WEP_CFname,document.WEP_contactForm.WEP_CFname.value,alert_name_error,true,true,true,true,'',document.WEP_contactForm.WEP_CFname,1,true);
	if (isvalid == false) {
		alert(alert_name_error);
	}
	if (isvalid == true) {
		isvalid = WAValidateEM(document.WEP_contactForm.WEP_CFemail,document.WEP_contactForm.WEP_CFemail.value,alert_invalid_email,document.WEP_contactForm.WEP_CFemail,1,true);
		if (isvalid == false) {
			alert(alert_invalid_email);
		}
		if (isvalid == true) {
			var successHandler = function(o) {
				var status = o.responseText;
				YAHOO.example.container.panel26.hide();
				alert(alert_question_submitted);
			}
			var failureHandler = function(o) {
				alert (alert_failed_connection)
			}
			var callback = {
				success: successHandler,
				failure: failureHandler
			}
			YAHOO.util.Connect.setForm("WEP_contactForm");
			var cObj = YAHOO.util.Connect.asyncRequest('POST', './WA_Universal_Email/contact-us.php', callback);
		}
	}
}
function quoteformsave() {
	YAHOO.example.container.panel29.hide();
	YAHOO.example.container.panel8.show();
}
function showquoteform() {
	YAHOO.example.container.panel29.hide();
	QFformload('S');
}
function QFformload(from) {
	if (from == 'S') {
		MSB.$('WEP_QFdesignIDDiv').innerHTML = text_design_ID+": "+MSB.$('WEP_design_id').value;
		MSB.$('WEP_QFdesignnameDiv').innerHTML = text_design_name+": "+MSB.$('WEP_design_name').value;
		MSB.$('WEP_QFemail').value = MSB.$('WEP_emailadd').value;
		MSB.$('WEP_QFdesignID').value = MSB.$('WEP_design_id').value;
		MSB.$('WEP_QFdesignname').value = MSB.$('WEP_design_name').value;
	}
	YAHOO.example.container.panel28.show();
}
function QFsubmit() {
	MSB.$('WEP_QFshopemail').value = MSB.$('WEP_shopemail').value;
	MSB.$('WEP_QFshopdomain').value = MSB.$('WEP_shopdomain').value;
	MSB.$('WEP_QFmyFQDN').value = MSB.$('WEP_myFQDN').value;
	MSB.$('WEP_QFnumlinesF').value = MSB.$('WEP_numlinesF').value;
	MSB.$('WEP_QFnumlinesB').value = MSB.$('WEP_numlinesB').value;
	var isvalid = true;
	isvalid = WAValidateAN(document.WEP_quoteForm.WEP_QFname,document.WEP_quoteForm.WEP_QFname.value,alert_name_error,true,true,true,true,'',document.WEP_contactForm.WEP_CFname,1,true);
	if (isvalid == false) {
		alert(alert_name_error);
	}
	if (isvalid == true) {
		isvalid = WAValidateEM(document.WEP_quoteForm.WEP_QFemail,document.WEP_quoteForm.WEP_QFemail.value,alert_invalid_email,document.WEP_contactForm.WEP_CFemail,1,true);
		if (isvalid == false) {
			alert(alert_invalid_email);
		}
		if (isvalid == true) {
			var successHandler = function(o) {
				var status = o.responseText;
				YAHOO.example.container.panel28.hide();
				alert(alert_quote_submitted);
			}
			var failureHandler = function(o) {
				alert (alert_failed_connection)
			}
			var callback = {
				success: successHandler,
				failure: failureHandler
			}
			YAHOO.util.Connect.setForm("WEP_quoteForm");
			var cObj = YAHOO.util.Connect.asyncRequest('POST', './WA_Universal_Email/quote-design.php', callback);
		}
	}
}
function fillcartBox1() {
	var HTML = "";
	MSB.$('WEP_productColor2').value = MSB.$('WEP_productColor').value;
	MSB.$('WEP_productSize2').value = MSB.$('WEP_productSize').value;
	MSB.$('WEP_actprod2').value = MSB.$('WEP_actprod').value;
	MSB.$('WEP_design_name2').value = MSB.$('WEP_design_name').value;
	MSB.$('WEP_design_id2').value = MSB.$('WEP_design_id').value;
	MSB.$('WEP_productPrice2').value = MSB.$('WEP_productPrice').value;
	MSB.$('WEP_numlinesF2').value = MSB.$('WEP_numlinesF').value;
	MSB.$('WEP_numlinesB2').value = MSB.$('WEP_numlinesB').value;
	MSB.$('WEP_numcolorsF2').value = MSB.$('WEP_numcolorsF').value;
	MSB.$('WEP_numcolorsB2').value = MSB.$('WEP_numcolorsB').value;
	var myDiv = MSB.$('WEP_cartimageDiv1');
	if (MSB.$('WEP_numlinesF').value > 0) {
		HTML = HTML + '<img src="./saveddesigns/'+MSB.$('WEP_design_id').value+'/'+MSB.$('WEP_design_id').value+'-thumbF.png" />&nbsp;&nbsp;';
	}
	if (MSB.$('WEP_numlinesB').value > 0) {
		HTML = HTML + '<img src="./saveddesigns/'+MSB.$('WEP_design_id').value+'/'+MSB.$('WEP_design_id').value+'-thumbB.png" /><br />';
	}
	myDiv.innerHTML = HTML
	if (MSB.$('WEP_colorCalc').value == 'yes') {
		getInstantQuote('S');
	}
	getprodSizes();
	YAHOO.example.container.panel20.show();
}
function fillcartBox2(from) {
	if (from == 'O') {
		var ID = MSB.$('WEP_open-design-id').value;
		MSB.$('WEP_design_id2').value = ID;
	}
	if (from == 'W') {
		var ID = MSB.$('WEP_Wopen-design-id').value;
		MSB.$('WEP_design_id2').value = ID;
	}
	var root = loadMyXML("./saveddesigns/"+ID+"/"+ID+".xml");
	var emailA = root.getElementsByTagName('email');
	var email = emailA[0].childNodes[0].nodeValue;
	var designNameA = root.getElementsByTagName('designname');
	var designName = designNameA[0].childNodes[0].nodeValue;
	MSB.$('WEP_design_name2').value = designName;
	var productTypeA = root.getElementsByTagName('producttype');
	var productType = productTypeA[0].childNodes[0].nodeValue;
	MSB.$('WEP_actprod2').value = productType;
	var productColorA = root.getElementsByTagName('productcolor');
	var productColor = productColorA[0].childNodes[0].nodeValue;
	MSB.$('WEP_productColor2').value = productColor;
	var productSizeA = root.getElementsByTagName('productsize');
	var productSize = productSizeA[0].childNodes[0].nodeValue;
	MSB.$('WEP_productSize2').value = productSize;	
	var numlinesFA = root.getElementsByTagName('numlinesfront');
	var numlinesF = numlinesFA[0].childNodes[0].nodeValue;
	MSB.$('WEP_numlinesF2').value = numlinesF;	
	var numlinesBA = root.getElementsByTagName('numlinesback');
	var numlinesB = numlinesBA[0].childNodes[0].nodeValue;
	MSB.$('WEP_numlinesB2').value = numlinesB;
	var numcolorsFA = root.getElementsByTagName('numcolorsfront');
	if (numcolorsFA.length > 0) {
		MSB.$('WEP_numcolorsF2').value = numcolorsFA[0].childNodes[0].nodeValue;
	}
	var numcolorsBA = root.getElementsByTagName('numcolorsback');
	if (numcolorsBA.length > 0) {
		MSB.$('WEP_numcolorsB2').value = numcolorsBA[0].childNodes[0].nodeValue;
	}
	var HTML = "";
	var myDiv = MSB.$('WEP_cartimageDiv1');
	if (MSB.$('WEP_numlinesF2').value > 0) {
		HTML = HTML + '<img src="./saveddesigns/'+ID+'/'+ID+'-thumbF.png" />&nbsp;&nbsp;';
	}
	if (MSB.$('WEP_numlinesB2').value > 0) {
		HTML = HTML + '<img src="./saveddesigns/'+ID+'/'+ID+'-thumbB.png" /><br />';
	}
	myDiv.innerHTML = HTML
	if (MSB.$('WEP_colorCalc').value == 'yes') {
		getInstantQuote('S');
	}
	getprodSizes();
	YAHOO.example.container.panel20.show();
}
function addtoCart() {
	MSB.$('WEP_Quantity_Add2').value = MSB.$('WEP_qtytoAdd').value;
	var successHandler = function(o) {
		alert(alert_products_added);
	}
	var failureHandler = function(o) {
		alert (alert_failed_connection)
	}
	var callback = {
		success: successHandler,
		failure: failureHandler
	}
	YAHOO.util.Connect.setForm("WEP_formSaveDesign2");
	var zc = MSB.$('WEP_zencart').value;
	if (MSB.$('WEP_colorCalc').value == 'yes') {
		var cObj = YAHOO.util.Connect.asyncRequest('POST', 'wep_addcart_IQ.php', callback);
	}
	else {
		var cObj = YAHOO.util.Connect.asyncRequest('POST', 'wep_addcart.php', callback);
	}
}
function getprodSizes() {
	var Event = YAHOO.util.Event;
	var color = MSB.$('WEP_productColor2').value;
	var picker3 = MSB.$('WEP_sizeOpts2');
	var product = MSB.$('WEP_actprod2').value;
	var curSize =  MSB.$('WEP_productSize2').value;
	var numlinesF =  MSB.$('WEP_numlinesF2').value;
	var numlinesB =  MSB.$('WEP_numlinesB2').value;
	picker3.innerHTML = '';
	var root = loadMyXML("./products/"+product+".xml?a="+Math.floor(Math.random()*10000));
	var mycolors = root.getElementsByTagName('color');
	for (var i=0;i<mycolors.length;i++) {
		if (mycolors[i].getAttribute('name') == color) {
			var sizestring = mycolors[i].getElementsByTagName('sizes')[0].childNodes[0].nodeValue;
		} 
	} 
	var html2 = '';
	var sizes = sizestring.split(" ");
	var textsizes = new Object();
	textsizes.sizeData = {};
	var clickstring;
	for (var q=0;q<sizes.length;q++) {
		textsizes.sizeData[sizes[q]] = sizes[q];
	}	
	for (var i in textsizes.sizeData) {
		html2 += '<a id="WEP_sel-siz2-'+product+'-'+i+'">' + i + '</a>';
		YAHOO.util.Event.on("WEP_sel-siz2-"+product+'-'+i, "click", changeproductsize2);
	}
	picker3.innerHTML = html2; 
	MSB.$('WEP_sel-siz2-'+product+'-'+curSize).style.backgroundColor = "#ff9999";
	var price = pricechange(MSB.$('WEP_actprod2').value,MSB.$('WEP_productColor2').value,curSize,numlinesF,numlinesB);
	if (MSB.$('WEP_colorCalc').value.toLowerCase() == 'yes') {
		price = '0';
	}
	else {
		MSB.$('WEP_priceDiv2').innerHTML = price_text+MSB.$('WEP_moneySymbol').value+price;
	}
	MSB.$('WEP_productPrice2').value = price;
}
function changeproductsize2(e) {
	var elTarget = YAHOO.util.Event.getTarget(e);
	elTarget = elTarget.id; 
	var mysplit = elTarget.split("-");
	var index = mysplit.length - 1;
	var size = mysplit[index];
	var oldSize = MSB.$('WEP_productSize2').value;
	var product = MSB.$('WEP_actprod2').value;
	var numlinesF = MSB.$('WEP_numlinesF2').value;
	var numlinesB = MSB.$('WEP_numlinesB2').value;
	if (oldSize != size) {
		MSB.$('WEP_sel-siz2-'+product+'-'+oldSize).style.backgroundColor = "#eeeeee";
		MSB.$('WEP_productSize2').value = size;
		MSB.$('WEP_sel-siz2-'+product+'-'+size).style.backgroundColor = "#ff9999";
		var price = pricechange(MSB.$('WEP_actprod2').value,MSB.$('WEP_productColor2').value,size,numlinesF,numlinesB);
		MSB.$('WEP_productPrice2').value = price;
		if (MSB.$('WEP_colorCalc').value.toLowerCase() != 'yes') {
			MSB.$('WEP_priceDiv2').innerHTML = price_text+MSB.$('WEP_moneySymbol').value+price;
		}
	}
}
function checkboundaries() {
	//the xy coords are relative to the printarea box
	var loc = MSB.$('WEP_actloc').value;
	var myI = MSB.$('WEP_actline').value.substring(6);
	var curX = parseInt(MSB.$('WEP_divimg'+myI).style.left);
	var curY = parseInt(MSB.$('WEP_divimg'+myI).style.top);
	var curW = parseInt(MSB.$('WEP_divimg'+myI).style.width);
	var curH = parseInt(MSB.$('WEP_divimg'+myI).style.height);
	var minX = 0;
	var maxX = MSB.$('WEP_printarea'+loc+'W').value;
	var minY = 0;
	var maxY = MSB.$('WEP_printarea'+loc+'H').value;
	var RE = curX + curW;
	var BE = curY + curH;
	if (curX < 0) {
		MSB.$('WEP_divimg'+myI).style.left = "0px";
	}
	if (RE > maxX) {
		var newX = Math.round(maxX - curW);
		MSB.$('WEP_divimg'+myI).style.left = newX + "px";
	}
	if (curY < 0) {
		MSB.$('WEP_divimg'+myI).style.top = "0px";
	}
	if (BE > maxY) {
		var newY = Math.round(maxY - curH)
		MSB.$('WEP_divimg'+myI).style.top = newY + "px";
	}
}
function leftjustline() {
	var actline = MSB.$('WEP_actline').value.substring(6);
	MSB.$('WEP_divimg'+actline).style.left = "0px";
	MSB.$('WEP_left'+actline).value = "0";
}
function rightjustline() {
	var loc = MSB.$('WEP_actloc').value;
	var actline = MSB.$('WEP_actline').value.substring(6);
	var myDiv = MSB.$('WEP_divimg'+actline);
	var curW = parseInt(MSB.$('WEP_divimg'+actline).style.width);
	var maxX = MSB.$('WEP_printarea'+loc+'W').value;
	var newX = Math.round(maxX - curW);
	MSB.$('WEP_divimg'+actline).style.left = newX + "px";
	MSB.$('WEP_left'+actline).value = newX;
}
function centerjustline() {
	var loc = MSB.$('WEP_actloc').value;
	var actline = MSB.$('WEP_actline').value.substring(6);
	var myDiv = MSB.$('WEP_divimg'+actline);
	var curW = parseInt(MSB.$('WEP_divimg'+actline).style.width);
	var curWhalf = Math.round(curW/2);
	var width = MSB.$('WEP_printarea'+loc+'W').value;
	var widthhalf = Math.round(width/2);
	var newX = widthhalf - curWhalf;
	MSB.$('WEP_divimg'+actline).style.left = newX + "px";
	MSB.$('WEP_left'+actline).value = newX;
}
function dellinecheck() {
	var loc = MSB.$('WEP_actloc').value;
	var numlines = parseInt(MSB.$('WEP_numlines'+loc).value);
	if (numlines > 0) {
		YAHOO.namespace("example.container");
		var handleYes = function() {
			deletetext();
			this.hide();
		};
		var handleNo = function() {
			this.hide();
		};
		simpledialog1 = new YAHOO.widget.SimpleDialog("WEP_deletedialog1", 
				 { width: "300px",
				   fixedcenter: true,
				   visible: false,
				   draggable: false,
				   close: false,
				   text: alert_delete1,
				   icon: YAHOO.widget.SimpleDialog.ICON_HELP,
				   constraintoviewport: true,
				   zIndex: "2000",
				   buttons: [ { text:button_yes, handler:handleYes, isDefault:true },
							  { text:button_no,  handler:handleNo } ]
				 } );
		simpledialog1.setHeader(alert_delete2);
		simpledialog1.render("WEP_designtool");
		simpledialog1.show();
	}
}
function createDOM(tx,ft,fs,fc,left,top,himg,wimg,zindA,fmt,fh,fv,rot) {
	var loc = MSB.$('WEP_actloc').value;
	var numlines = parseInt(MSB.$('WEP_numlines'+loc).value);
	var i;
	var newindex = MSB.$('WEP_currentInd').value;
	MSB.$('WEP_currentInd').value = parseInt(newindex) + 1;
	if (zindA == '0') {
		var Zind = '13';
	}
	else {
		var Zind = zindA;
	}
	var newID = 'WEP_divimg'+newindex;
	var newloc = 'WEP_loc'+newindex;
	var newFT = 'WEP_ft'+newindex;
	var newFC = 'WEP_fc'+newindex;
	var newFS = 'WEP_fs'+newindex;
	var newTX = 'WEP_tx'+newindex;
	var topID = 'WEP_top'+newindex;
	var leftID = 'WEP_left'+newindex;
	var wimgID = 'WEP_Wimg'+newindex;
	var himgID = 'WEP_Himg'+newindex;
	var formatID = 'WEP_format'+newindex;
	var zindID = 'WEP_Zind'+newindex;
	var flipHID = "WEP_flipH"+newindex;
	var flipVID = "WEP_flipV"+newindex;
	var rotID = "WEP_rot"+newindex;
	var archID = "WEP_arch"+newindex;
	var textind = "WEP_tx"+newindex;
	if (MSB.$('WEP_actline').value != 'none') {
		var actline = MSB.$('WEP_actline').value;
		var actindex = actline.substring(6);
		MSB.$('WEP_divimg' + actindex).style.border = "none";
	} 
	MSB.$('WEP_actline').value = "WEP_tx"+newindex;
	var newChild = document.createElement('DIV');
	newChild.setAttribute('id',newID);
	if (fmt != 'text') {
		newChild.setAttribute('class','yui-skin-sam');
	}
	var parent = MSB.$('WEP_printArea'+loc);
	parent.appendChild(newChild);
	MSB.$(newID).style.zIndex = Zind;
	MSB.$(newID).style.width = wimg + "px";
	MSB.$(newID).style.height = himg + "px";
	var parent2 = MSB.$('WEP_designParList');
	var locchild = document.createElement('INPUT');
	locchild.setAttribute('id',newloc);
	locchild.setAttribute('name',newloc);
	locchild.setAttribute('type','hidden');
	locchild.setAttribute('value',loc);
	parent2.appendChild(locchild);
	var ftchild = document.createElement('INPUT');
	ftchild.setAttribute('id',newFT);
	ftchild.setAttribute('name',newFT);
	ftchild.setAttribute('type','hidden');
	ftchild.setAttribute('value',ft);
	parent2.appendChild(ftchild);
	var fcchild = document.createElement('INPUT');
	fcchild.setAttribute('id',newFC);
	fcchild.setAttribute('name',newFC);
	fcchild.setAttribute('type','hidden');
	fcchild.setAttribute('value',fc);
	parent2.appendChild(fcchild);
	var fschild = document.createElement('INPUT');
	fschild.setAttribute('id',newFS);
	fschild.setAttribute('name',newFS);
	fschild.setAttribute('type','hidden');
	fschild.setAttribute('value',fs);
	parent2.appendChild(fschild);
	var txchild = document.createElement('INPUT');
	txchild.setAttribute('id',newTX);
	txchild.setAttribute('name',newTX);
	txchild.setAttribute('type','hidden');
	txchild.setAttribute('value',tx);
	parent2.appendChild(txchild);
	var topchild = document.createElement('INPUT');
	topchild.setAttribute('id',topID);
	topchild.setAttribute('name',topID);
	topchild.setAttribute('type','hidden');
	topchild.setAttribute('value',top);
	parent2.appendChild(topchild);
	var leftchild = document.createElement('INPUT');
	leftchild.setAttribute('id',leftID);
	leftchild.setAttribute('name',leftID);
	leftchild.setAttribute('type','hidden');
	leftchild.setAttribute('value',left);
	parent2.appendChild(leftchild);
	var himgchild = document.createElement('INPUT');
	himgchild.setAttribute('id',himgID);
	himgchild.setAttribute('name',himgID);
	himgchild.setAttribute('type','hidden');
	himgchild.setAttribute('value',himg);
	parent2.appendChild(himgchild);
	var wimgchild = document.createElement('INPUT');
	wimgchild.setAttribute('id',wimgID);
	wimgchild.setAttribute('name',wimgID);
	wimgchild.setAttribute('type','hidden');
	wimgchild.setAttribute('value',wimg);
	parent2.appendChild(wimgchild);
	var fmtchild = document.createElement('INPUT');
	fmtchild.setAttribute('id',formatID);
	fmtchild.setAttribute('name',formatID);
	fmtchild.setAttribute('type','hidden');
	fmtchild.setAttribute('value',fmt);
	parent2.appendChild(fmtchild);
	var zindchild = document.createElement('INPUT');
	zindchild.setAttribute('id',zindID);
	zindchild.setAttribute('name',zindID);
	zindchild.setAttribute('type','hidden');
	zindchild.setAttribute('value',Zind);
	parent2.appendChild(zindchild);
	var fhchild = document.createElement('INPUT');
	fhchild.setAttribute('type',"hidden");
	fhchild.setAttribute('id',flipHID);
	fhchild.setAttribute('name',flipHID);
	fhchild.setAttribute('value',fh);
	parent2.appendChild(fhchild);
	var fvchild = document.createElement('INPUT');
	fvchild.setAttribute('type',"hidden");
	fvchild.setAttribute('id',flipVID);
	fvchild.setAttribute('name',flipVID);
	fvchild.setAttribute('value',fv);
	parent2.appendChild(fvchild);
	var rotchild = document.createElement('INPUT');
	rotchild.setAttribute('type',"hidden");
	rotchild.setAttribute('id',rotID);
	rotchild.setAttribute('name',rotID);
	rotchild.setAttribute('value',rot);
	parent2.appendChild(rotchild);
	if (fmt == 'text') {
		var stkcID = 'WEP_stkc'+newindex;
		var stkwID = 'WEP_stkw'+newindex;
		var stkcchild = document.createElement('INPUT');
		stkcchild.setAttribute('id',stkcID);
		stkcchild.setAttribute('name',stkcID);
		stkcchild.setAttribute('type','hidden');
		stkcchild.setAttribute('value',MSB.$('WEP_actstkc').value);
		parent2.appendChild(stkcchild);
		var stkwchild = document.createElement('INPUT');
		stkwchild.setAttribute('id',stkwID);
		stkwchild.setAttribute('name',stkwID);
		stkwchild.setAttribute('type','hidden');
		stkwchild.setAttribute('value',MSB.$('WEP_actstkw').value);
		parent2.appendChild(stkwchild);
		var archchild = document.createElement('INPUT');
		archchild.setAttribute('id',archID);
		archchild.setAttribute('name',archID);
		archchild.setAttribute('type','hidden');
		archchild.setAttribute('value',MSB.$('WEP_actarch').value);
		parent2.appendChild(archchild);
	}
	MSB.$(newID).style.top = top + "px";
	MSB.$(newID).style.left = left + "px";
	var numlinesA = parseInt(MSB.$('WEP_numlines' + loc).value);
	MSB.$('WEP_numlines' + loc).value = numlinesA + 1;
	MSB.$(newID).style.position = 'absolute';
	MSB.$(newID).style.border = "dashed 1px #ffff00";
	MSB.$(newID).style.backgroundRepeat = "no-repeat";
	return newID;
}
function showsearchresults() {
	YAHOO.example.container.panel15.show();
	var successHandler = function(o) {
		var myDiv = MSB.$('WEP_searchresultsArea');
		myDiv.innerHTML = "";
		var file = './images/'+MSB.$('WEP_design_id').value+'/results.xml?a='+Math.floor(Math.random()*10000);
		var root = loadMyXML(file);
		var designsA = root.getElementsByTagName('design');
		if (designsA.length < 1) {
			myDiv.innerHTML = "No Results";
		}
		else {
			var myHTML = '<table width="370px" align="left" bgcolor="#FFFFFF">'+
					'<tr><td align = "left"><b>Your Designs:</b></td><td></td><td></td></tr>'+
					'<tr><td align = "left"><b>Design ID</b></td>'+
					'<td align = "left"><b>Design Name</b></td>'+
					'<td align = "left"></td></tr>';
			for (var x=0;x<designsA.length;x++) {
				var designIDA = root.getElementsByTagName('designid');
				var designID = designIDA[x].childNodes[0].nodeValue;
				var designNameA = root.getElementsByTagName('designname');
				var designName = designNameA[x].childNodes[0].nodeValue;		
				myHTML = myHTML + '<tr><td align = "left">'+designID+'</td>'+
					'<td align = "left">'+designName+'</td>'+
					'<td align = "left"><a id="WEP_open-'+designID+'" onclick="openfromsearch(this.id)">Open Design</a></td></tr>';
			}
			myHTML = myHTML + '</table>';
			myDiv.innerHTML = myHTML;
		} 
	}
	var failureHandler = function(o) {
		alert (alert_failed_connection);
	}
	var callback = {
		success: successHandler,
		failure: failureHandler
	}
	var email = MSB.$('WEP_search-email').value;
	var ID = MSB.$('WEP_design_id').value;
	//validate email in js
	var sUrl = "./php/searchdesigns.php?ID="+ID+"&email="+email;
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
}
function moveforward() {
	var actline = MSB.$('WEP_actline').value;
	var index = MSB.$('WEP_actline').value.substring(6);
	if (actline != 'none') {
		var curZind = parseInt(MSB.$('WEP_Zind'+index).value);
		MSB.$('WEP_Zind'+index).value = curZind + 1;
		MSB.$('WEP_divimg'+index).style.zIndex = curZind + 1;
	}
}
function moveback() {
	var actline = MSB.$('WEP_actline').value;
	var index = MSB.$('WEP_actline').value.substring(6);
	if (actline != 'none') {
		var curZind = parseInt(MSB.$('WEP_Zind'+index).value);
		if (curZind > 10) {
			MSB.$('WEP_Zind'+index).value = curZind - 1;
			MSB.$('WEP_divimg'+index).style.zIndex = curZind - 1;
		}
	}
}
//DT START JS
YAHOO.util.Event.onDOMReady(function() {
	var prodConfigLoad = MSB.$('WEP_prodConfigLoad').value;
	if (MSB.$('WEP_prodConfigLoad').value == 'default') {
		var root = loadMyXML('./products/products-list.xml?a='+Math.floor(Math.random()*10000));
		var prodImage = './products/products.jpg';
	}
	else {
		var root = loadMyXML('./configs/'+prodConfigLoad+'/products/products-list.xml?a='+Math.floor(Math.random()*10000));
		var prodImage = './configs/'+prodConfigLoad+'/products/products.jpg';
	}
	var myprods = root.getElementsByTagName('product');
	var newChild;
	var parent;
	var prodDiv1, prodDiv;
	var prodLI,offset;
	for (var i=0;i<myprods.length;i++) {
		prodDiv1 = myprods[i].getAttribute('id');
		prodDiv = prodDiv1.replace(/\s/g,"-");
		newChild = document.createElement('DIV');
		parent = MSB.$('WEP_carousel');
		newChild.setAttribute('id','WEP_carousel-LI'+i);
		newChild.setAttribute('title',myprods[i].getAttribute('id').replace(/\s/g,"-"));
		parent.appendChild(newChild);
		offset = -100*i;
		MSB.$('WEP_carousel-LI'+i).className = "WEP_productitem";
		MSB.$('WEP_carousel-LI'+i).style.backgroundImage = 'url('+prodImage+')';
		MSB.$('WEP_carousel-LI'+i).style.backgroundPosition = offset + "px 15px";
		YAHOO.util.Event.on('WEP_carousel-LI'+i, "click", changeproductA);
		newChild = document.createElement('DIV');
		parent = MSB.$('WEP_carousel-LI'+i);
		newChild.setAttribute('id','WEP_carousel-LI-text'+i);
		parent.appendChild(newChild);
		MSB.$('WEP_carousel-LI-text'+i).innerHTML = prodDiv1;
	}
	MSB.$('WEP_defaultProduct').value = myprods[0].getAttribute('id').replace(/\s/g,"-");
	var product = MSB.$('WEP_defaultProduct').value;
	MSB.$('WEP_actprod').value = product;
	changeproduct('fromdefault');
});
function updatecolors(product) {
	var Event = YAHOO.util.Event;
	var picker = MSB.$('WEP_productCP');
	YAHOO.util.Event.purgeElement(picker, true);
	picker.innerHTML = '';
	var picker2 = MSB.$('WEP_productSP');
	YAHOO.util.Event.purgeElement(picker2, true);
	picker2.innerHTML = '';
	var root = loadMyXML("./products/"+product+".xml?a="+Math.floor(Math.random()*10000));
	var mycolors = root.getElementsByTagName('color');
	var myrgb,mysize; 
	var textcolors = new Object();
	var sizesAvail = new Object();
	textcolors.colorData = {};
	sizesAvail.sizes = {};
	for (var t=0;t<mycolors.length;t++) {
		myrgb = mycolors[t].getElementsByTagName('productRGB')[0].childNodes[0].nodeValue;
		textcolors.colorData[myrgb] = mycolors[t].getAttribute('name');
		sizesAvail.sizes[myrgb] = mycolors[t].getElementsByTagName('sizes')[0].childNodes[0].nodeValue;
	}	
	var html ='';
	var color;
	for (var i in textcolors.colorData) {
		color = textcolors.colorData[i].replace(/\s/g,"-");
		html += '<a style="background-color:'+i+'">'+i+'</a>';
	}
	html += '<span><strong></strong></span>';
	picker.innerHTML = html;
	var em = picker.getElementsByTagName('em')[0];
	var strong = picker.getElementsByTagName('strong')[0];
	Event.on(picker, 'mouseover', function(ev) {
		var tar = Event.getTarget(ev);
		if (tar.tagName.toLowerCase() == 'a') {
			var color = textcolors.colorData[tar.innerHTML];
			var sizes = sizesAvail.sizes[tar.innerHTML];
			strong.innerHTML = color+'<br>'+sizes;
		}
	}, this, true);
	Event.on(picker, 'focus', function(ev) {
		Event.stopEvent(ev);
	});
	Event.on(picker, 'click', function(ev) {
		Event.stopEvent(ev);
		var tar = Event.getTarget(ev);
		if (tar.tagName.toLowerCase() == 'a') {
			MSB.$('WEP_productColor').value = textcolors.colorData[tar.innerHTML];
			MSB.$('WEP_prodRGB').value = tar.innerHTML;
			changeproductcolor();
		}
	}, this, true); 
}
YAHOO.util.Event.onDOMReady(function() {
	var root = loadMyXML("./fonts/fonts.xml?a="+Math.floor(Math.random()*10000));
	var myfonts = root.getElementsByTagName('font');
	var myfont;
	var parent;
	var newChild;
	var offset;
	for (var i=0;i<myfonts.length;i++) {
		myfont = myfonts[i].childNodes[0].nodeValue;
	//	alert(myfont);
		myfont = myfont.replace(/\s/g,"-");
		parent = MSB.$('WEP_fontslist');
		var newChild = document.createElement('DIV');
		newChild.setAttribute('id','WEP_selfont-'+myfont);
		newChild.setAttribute('title',myfont);
		parent.appendChild(newChild);
		offset = -150*i;
		MSB.$('WEP_selfont-'+myfont).className = "WEP_fontlistIMG";
		MSB.$('WEP_selfont-'+myfont).style.backgroundPosition = offset + "px 0px";
		YAHOO.util.Event.on('WEP_selfont-'+myfont,'click',fontselect);
	} 
									 });
YAHOO.util.Event.onDOMReady(function() {
	var root = loadMyXML("./stockimages/imagegroups.xml?a="+Math.floor(Math.random()*10000));
	var mysyms = root.getElementsByTagName('group');
	var parent = MSB.$('WEP_changestockgroup');
	if (mysyms.length == 0) {
		parent.innerHTML = 'No Images Available';
	}
	else {
		var mysymA = new Array();
		var newChild;
		var mysym;
		var mysymB;
		for (var i=0;i<mysyms.length;i++) {
			mysym = mysyms[i].childNodes[0].nodeValue;
			mysymB = mysym.replace(/\s/g,"-");
			newChild = document.createElement('A');
			newChild.setAttribute('id','WEP_selstockgroup-'+mysymB);
			parent.appendChild(newChild);
			MSB.$('WEP_selstockgroup-'+mysymB).innerHTML = mysym+'&nbsp;&nbsp;';
			YAHOO.util.Event.on('WEP_selstockgroup-'+mysymB, 'click', changeStockGroup);
		}
	}
 });
function loadourdesigns() {
	var root = loadMyXML("./ourdesigns/our-designs-categories.xml?a="+Math.floor(Math.random()*10000));
	var mysyms = root.getElementsByTagName('category');
	var parent = MSB.$('WEP_changeODgroup');
	if (mysyms.length == 0) {
		parent.innerHTML = 'No Designs Available';
	}
	else {
		var mysymA = new Array();
		var newChild;
		var mysym;
		var mysymB;
		for (var i=0;i<mysyms.length;i++) {
			mysym = mysyms[i].childNodes[0].nodeValue;
			mysymB = mysym.replace(/\s/g,"-");
			newChild = document.createElement('A');
			newChild.setAttribute('id','WEP_selODgroup-'+mysymB);
			parent.appendChild(newChild);
			MSB.$('WEP_selODgroup-'+mysymB).innerHTML = mysym+'&nbsp;&nbsp;';
			YAHOO.util.Event.on('WEP_selODgroup-'+mysymB, 'click', changeODGroup);
		}
	}
	changeODGroup();
 }
YAHOO.util.Event.onDOMReady(function() {
	var root = loadMyXML("./symbols/symbolgroups.xml?a="+Math.floor(Math.random()*10000));
	var mysyms = root.getElementsByTagName('group');
	var mysymA = new Array();
	var parent = MSB.$('WEP_changesymgroup');
	var newChild;
	var mysym;
	var mysymB;
	for (var i=0;i<mysyms.length;i++) {
		mysym = mysyms[i].childNodes[0].nodeValue;
		mysymB = mysym.replace(/\s/g,"-");
		newChild = document.createElement('A');
		newChild.setAttribute('id','WEP_selsymgroup-'+mysymB);
		parent.appendChild(newChild);
		MSB.$('WEP_selsymgroup-'+mysymB).innerHTML = mysym+'&nbsp;&nbsp;';
		YAHOO.util.Event.on('WEP_selsymgroup-'+mysymB, 'click', changeSymGroup);
	}
 });
function changeSymGroup(e) {
	if (e) {
		var elTarget = YAHOO.util.Event.getTarget(e);
		elTarget = elTarget.id;
		var mysymgroup = elTarget.substring(16);
	}
	else {
	//	var mysymgroup = "Basics";
	}
		var root = loadMyXML("./symbols/"+mysymgroup+".xml?a="+Math.floor(Math.random()*10000));
		var mysymbol;
		var mysyms = root.getElementsByTagName('symbol');
		var parent = MSB.$('WEP_symscrollgallery');
		parent.innerHTML = "";
		var newChild;
		for (var i=0;i<mysyms.length;i++) {
			mysymbol = mysyms[i].childNodes[0].nodeValue;
			newChild = document.createElement('IMG');
			newChild.setAttribute('id','WEP_selsym-'+mysymbol);
			newChild.setAttribute('name','WEP_selsym-'+mysymbol);
			newChild.setAttribute('src','./symbols/symimages/'+mysymbol+'-thumb.png');
			parent.appendChild(newChild);
			YAHOO.util.Event.on('WEP_selsym-'+mysymbol,'click', symbolselect);
		}
}
function changeStockGroup(e) {
	if (e) {
		var elTarget = YAHOO.util.Event.getTarget(e);
		elTarget = elTarget.id;
		var mysymgroup = elTarget.substring(18);
	}
	else {
	//	var mysymgroup = "Basics";
	}
	var root = loadMyXML("./stockimages/"+mysymgroup+".xml?a="+Math.floor(Math.random()*10000));
		var mysymbol;
		var mysyms = root.getElementsByTagName('image');
		var parent = MSB.$('WEP_stockscrollgal');
		parent.innerHTML = "";
		var newChild;
		for (var i=0;i<mysyms.length;i++) {
			mysymbol = mysyms[i].childNodes[0].nodeValue;
			newChild = document.createElement('IMG');
			newChild.setAttribute('id','WEP_selstock-'+mysymbol);
			newChild.setAttribute('name','WEP_selstock-'+mysymbol);
			newChild.setAttribute('src','./stockimages/'+mysymgroup+'/'+mysymbol);
			newChild.setAttribute('alt',mysymgroup);
			parent.appendChild(newChild);
			YAHOO.util.Event.on('WEP_selstock-'+mysymbol,'click', stockimgselect);
		}
}
function changeODGroup(e) {
	if (e) {
		var elTarget = YAHOO.util.Event.getTarget(e);
		elTarget = elTarget.id;
		var mysymgroup = elTarget.substring(15);
	}
	else {
		var root = loadMyXML("./ourdesigns/our-designs-categories.xml?a="+Math.floor(Math.random()*10000));
		var cats = root.getElementsByTagName('category');
		if (cats.length > 0) {
			var mysymgroup = root.getElementsByTagName('category')[0].childNodes[0].nodeValue;
		}
		else {
			return;
		}
	}
	var root = loadMyXML("./ourdesigns/"+mysymgroup+".xml?a="+Math.floor(Math.random()*10000));
	var mydiv = MSB.$('WEP_SDscrollgal');
	mydiv.innerHTML = "";
	var newChild;
	var mydesigns = root.getElementsByTagName('designThumb');
	var innerHTML='';
	var A,myID,mythumb;
	for (var i=0;i<mydesigns.length;i++) {
		mythumb = mydesigns[i].childNodes[0].nodeValue;
		A = mydesigns[i].childNodes[0].nodeValue.split('-');
		innerHTML = innerHTML + '<span id="WEP_SD-'+A[0]+'" onclick="loadSD(this.id)" class="WEP_SDimg"><a><img src="ourdesigns/'+A[0]+'/'+mythumb+'" /></a></span>';
	}
	mydiv.innerHTML = innerHTML;
}
function changefonts(e) {
	var elTarget = YAHOO.util.Event.getTarget(e);
	elTarget = elTarget.id;
}
YAHOO.util.Event.onDOMReady(function() {
	getnewID();
});
function editdesign() {
	MSB.$('WEP_design_id_old').value = MSB.$('WEP_design_id').value; 
	var root = loadMyXML("./includes/shop-defaults.xml?a="+Math.floor(Math.random()*10000));
	var shopcodeA = root.getElementsByTagName('shopcode');
	var shopcode = shopcodeA[0].childNodes[0].nodeValue;
	var serverType = 'php'; 
	if (serverType == "php") {
		var successHandler2 = function(o) {			
			var designID = o.responseText;
			MSB.$('WEP_design_id').value = designID;
			copydesigntoNew('fromedit');
		}
		var callback2 = {
			success: successHandler2
		};
		var sUrl = "./php/getepoc.php?sc="+shopcode;
		var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback2);
	}
	YAHOO.example.container.panel10.hide();
	if (MSB.$('WEP_addtocartoverlay').style.display != 'none') {
		YAHOO.example.container.panel20.hide(); 
	}
}
function newdesign() {
	MSB.$('WEP_design_id_old').value = MSB.$('WEP_design_id').value;
	getnewID();
	cleardesign();
	var myIDIV;
	YAHOO.example.container.panel10.hide();
	if (MSB.$('WEP_addtocartoverlay').style.display != 'none') {
		YAHOO.example.container.panel20.hide(); 
	}
}
function cleardesign() {
	var ID = MSB.$('WEP_design_id').value
	MSB.$('WEP_currentInd').value = '0';
	var myDiv = MSB.$('WEP_printAreaF');
	while (myDiv.hasChildNodes()) {
		myDiv.removeChild(myDiv.lastChild);
	}
	var myDiv = MSB.$('WEP_printAreaB');
	while (myDiv.hasChildNodes()) {
		myDiv.removeChild(myDiv.lastChild);
	}
	var myDiv = MSB.$('WEP_designParList');
	while (myDiv.hasChildNodes()) {
		myDiv.removeChild(myDiv.lastChild);
	}
	var myDiv = MSB.$('WEP_imageframe');
	while (myDiv.hasChildNodes()) {
		myDiv.removeChild(myDiv.lastChild);
	}
	MSB.$('WEP_numlinesF').value = "0";
	MSB.$('WEP_numlinesB').value = "0";
	MSB.$('WEP_actline').value = "none";
	MSB.$('WEP_currentFMT').value = 'text';
	MSB.$('WEP_curImCode').value = '1';
	MSB.$('WEP_imageInd').value = '1';
	MSB.$('WEP_curImExt').value = 'jpg';
	var successHandler2 = function(o) {			
		var status = o.responseText;
	}
	var callback2 = {
		success: successHandler2
	};
	var sUrl = "./php/cleardesign.php?ID="+ID;
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback2);	
}
function loadSD(e) {
	var A = e.split('-');
	var ID = A[1];
	MSB.$('WEP_open-design-id').value = ID;
	YAHOO.example.container.panel132.show();
}
function opendesign(whereA) {
	var root = loadMyXML("./includes/shop-defaults.xml?a="+Math.floor(Math.random()*10000));
	var shopcodeA = root.getElementsByTagName('shopcode');
	var shopcode = shopcodeA[0].childNodes[0].nodeValue;
	var successHandler2 = function(o) {			
		var designID = o.responseText;
		MSB.$('WEP_design_id').value = designID;
		opendesign2(o.argument.where2);
	}
	var callback2 = {
		success: successHandler2,
		argument: {where2: whereA}
	};
	var sUrl = "./php/getepoc.php?sc="+shopcode;
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback2);
	function opendesign2(where) {
		if (where == 'fromstock') {
			YAHOO.example.container.panel132.hide();
		}
		YAHOO.example.container.panel14.hide();
		MSB.$('WEP_design_id_old').value = MSB.$('WEP_open-design-id').value;
		var oldID = MSB.$('WEP_design_id_old').value;
		cleardesign();
		copydesigntoNew(where);
		if (where == 'fromstock') {
			var root = loadMyXML("./ourdesigns/"+oldID+"/"+oldID+".xml?a="+Math.floor(Math.random()*10000));
		}
		else {
			var root = loadMyXML("./saveddesigns/"+oldID+"/"+oldID+".xml");
		}
		var myfmt, mytxA, mytx, myextA, myext, myfile;
	//	var emailA = root.getElementsByTagName('email');
	//	var email = emailA[0].childNodes[0].nodeValue;
	//	MSB.$('WEP_emailadd').value = email;
		var designNameA = root.getElementsByTagName('designname');
		var designName = designNameA[0].childNodes[0].nodeValue;
		MSB.$('WEP_design_name').value = designName;
		var productTypeA = root.getElementsByTagName('producttype');
		var productType = productTypeA[0].childNodes[0].nodeValue;
		MSB.$('WEP_actprod').value = productType;
		var productColorA = root.getElementsByTagName('productcolor');
		var productColor = productColorA[0].childNodes[0].nodeValue;
		MSB.$('WEP_productColor').value = productColor;
		var productRGBA = root.getElementsByTagName('productRGB');
		var productRGB = productRGBA[0].childNodes[0].nodeValue;
		MSB.$('WEP_prodRGB').value = productRGB;
		var productSizeA = root.getElementsByTagName('productsize');
		var productSize = productSizeA[0].childNodes[0].nodeValue;
		MSB.$('WEP_productSize').value = productSize;
		var numcolorsFA = root.getElementsByTagName('numcolorsfront');
		var numcolorsF = numcolorsFA[0].childNodes[0].nodeValue;
		var numcolorsBA = root.getElementsByTagName('numcolorsback');
		var numcolorsB = numcolorsBA[0].childNodes[0].nodeValue;
		MSB.$('WEP_numcolorsF').value = numcolorsF;
		MSB.$('WEP_numcolorsB').value = numcolorsB;
		changeproduct('fromopen');
		var numlinesFA = root.getElementsByTagName('numlinesfront');
		var numlinesF = numlinesFA[0].childNodes[0].nodeValue;
		var numlinesBA = root.getElementsByTagName('numlinesback');
		var numlinesB = numlinesBA[0].childNodes[0].nodeValue;
		var frontA = root.getElementsByTagName('lines');
		var linesFA = frontA[0].getElementsByTagName('line');
		var numlines = parseInt(numlinesF) + parseInt(numlinesB);
		var tx,ft,fc,fs,top,left,W,H,fmt,stkc,stkw,flipv,fliph,rot,arch,ind;
		for (var i=0;i<numlines;i++) {
			ind = linesFA[i].getAttribute('ind');
			tx = linesFA[i].getElementsByTagName('text').item(0).childNodes[0].nodeValue;
			loc = linesFA[i].getElementsByTagName('location').item(0).childNodes[0].nodeValue;
			fmt = linesFA[i].getElementsByTagName('format').item(0).childNodes[0].nodeValue;
			fc = linesFA[i].getElementsByTagName('fontColor').item(0).childNodes[0].nodeValue;
			ft = linesFA[i].getElementsByTagName('font').item(0).childNodes[0].nodeValue;
			fs = linesFA[i].getElementsByTagName('fontSize').item(0).childNodes[0].nodeValue;
			top = linesFA[i].getElementsByTagName('top').item(0).childNodes[0].nodeValue;
			left = linesFA[i].getElementsByTagName('left').item(0).childNodes[0].nodeValue;
			flipv = linesFA[i].getElementsByTagName('flipV').item(0).childNodes[0].nodeValue;
			fliph = linesFA[i].getElementsByTagName('flipH').item(0).childNodes[0].nodeValue;
			rot = linesFA[i].getElementsByTagName('rotate').item(0).childNodes[0].nodeValue;
			wimg = linesFA[i].getElementsByTagName('wimg').item(0).childNodes[0].nodeValue;
			himg = linesFA[i].getElementsByTagName('himg').item(0).childNodes[0].nodeValue;
			zind = linesFA[i].getElementsByTagName('zIndex').item(0).childNodes[0].nodeValue;
			MSB.$('WEP_edittextbox').value = tx;
			MSB.$('WEP_currentFMT').value = fmt;
			MSB.$('WEP_actfc').value = fc;
			MSB.$('WEP_actfs').value = fs;
			MSB.$('WEP_actft').value = ft;
			MSB.$('WEP_acttop').value = top;
			MSB.$('WEP_actleft').value = left;
			MSB.$('WEP_actflipv').value = flipv;
			MSB.$('WEP_actfliph').value = fliph;
			MSB.$('WEP_actrot').value = rot;
			MSB.$('WEP_actloc').value = loc;
			MSB.$('WEP_actwimg').value = wimg;
			MSB.$('WEP_acthimg').value = himg;
			MSB.$('WEP_actzind').value = zind;
			if (fmt == 'text') {
				stkc = linesFA[i].getElementsByTagName('strokeColor').item(0).childNodes[0].nodeValue;
				stkw = linesFA[i].getElementsByTagName('strokeWidth').item(0).childNodes[0].nodeValue;
				arch = linesFA[i].getElementsByTagName('arch').item(0).childNodes[0].nodeValue;
				MSB.$('WEP_actstkc').value = stkc;
				MSB.$('WEP_actstkw').value = stkw;
				MSB.$('WEP_actarch').value = arch;
			}
			switch (fmt) {
				case 'text':
				loadtext(ind);
				break;
				case 'symbol':
				loadsymbol();
				break;
				case 'image':
				loadimage();
				break;
				case 'stock':
				loadstock();
				break;
			}
		}
		if (numlinesF > 0) {
			MSB.$('WEP_actloc').value = 'F';
		}
		else {
			MSB.$('WEP_actloc').value = 'B';
		}
	}
}
function getnewID() {
	var root = loadMyXML("./includes/shop-defaults.xml?a="+Math.floor(Math.random()*10000));
	var shopcodeA = root.getElementsByTagName('shopcode');
	var shopcode = shopcodeA[0].childNodes[0].nodeValue;
	var successHandler2 = function(o) {			
		var designID = o.responseText;
		MSB.$('WEP_design_id').value = designID;
		return;
	}
	var callback2 = {
		success: successHandler2
	};
	var sUrl = "./php/getepoc.php?sc="+shopcode;
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback2);	
}
function copydesigntoNew(where) {
	var successHandler2 = function(o) {			
			var status = o.responseText;
	}
	var callback2 = {
		success: successHandler2
	};
	var oldID = MSB.$('WEP_design_id_old').value;
	var newID = MSB.$('WEP_design_id').value;
	var sUrl = "./php/copydesign.php?old="+oldID+"&new="+newID+"&SD="+where;
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback2);
}
function openwarn() {
	YAHOO.example.container.panel14.show();
	YAHOO.example.container.panel9.hide();
}
function cancelopen() {
	YAHOO.example.container.panel14.hide();
	YAHOO.example.container.panel132.hide();
}
function openfromsearch(e) {
	var myID = e.substring(9);
	MSB.$('WEP_open-design-id').value = myID;
	openwarn();
}
//PRODUCT OPTIONS JS
YAHOO.util.Event.on("WEP_sel-F", "click", changeproductloc);
YAHOO.util.Event.on("WEP_sel-B", "click", changeproductloc);
function changeproductcolor() {
	var productcolor = MSB.$('WEP_productColor').value.replace(/\s/g,"-");
	var productcolorA = MSB.$('WEP_productColor').value; //DO NOT REMOVE WHITESPACE for XML CHECK
	var product = MSB.$('WEP_actprod').value;
	var myelementF = MSB.$('WEP_mediaLayerF');
	var myelementB = MSB.$('WEP_mediaLayerB');
	var currentview = MSB.$('WEP_printloc').value;
	var numlinesF = MSB.$('WEP_numlinesF').value;
	var numlinesB = MSB.$('WEP_numlinesB').value;
	var size = MSB.$('WEP_productSize').value;
	myelementF.style.backgroundImage = "url(./toolimages/blanks/" + product + "/" + productcolor + "-front.png)";
	myelementB.style.backgroundImage = "url(./toolimages/blanks/" + product + "/" + productcolor + "-back.png)";
	if (MSB.$('WEP_colorCalc').value == 'yes') {
		getInstantQuote('open');
	}
	if (MSB.$('WEP_priceDiv').style.display != 'none') {
		var price = pricechange(product,productcolorA,size,numlinesF,numlinesB);
		MSB.$('WEP_productPrice').value = price;
		MSB.$('WEP_priceDiv').innerHTML = oneSide+": "+MSB.$('WEP_moneySymbol').value+MSB.$('WEP_pricetemp1').value+'<br />'+oneSide+': '+MSB.$('WEP_moneySymbol').value+MSB.$('WEP_pricetemp2').value;
	}
}
function changeproductloc(e) {
	if (MSB.$('WEP_actline').value != 'none') {
		var actline = MSB.$('WEP_actline').value;
		var actindex = actline.substring(6);
		MSB.$('WEP_divimg' + actindex).style.border = "none";
		MSB.$('WEP_actline').value = 'none';
	} 
	var loc = e;
	if (loc == 'F') {
		if (MSB.$('WEP_actloc').value != "F") {
			MSB.$('WEP_actloc').value = "F";
			MSB.$('WEP_mediaLayerF').style.visibility = 'visible';
			MSB.$('WEP_mediaLayerB').style.visibility = 'hidden';
			MSB.$('WEP_actline').value = 'none';
			MSB.$('WEP_edittextbox').value = '';
		}
	}
	if (loc == 'B') {
		if (MSB.$('WEP_actloc').value != "B") {
			MSB.$('WEP_actloc').value = "B";
			MSB.$('WEP_mediaLayerF').style.visibility = 'hidden';
			MSB.$('WEP_mediaLayerB').style.visibility = 'visible';
			MSB.$('WEP_actline').value = 'none';
			MSB.$('WEP_edittextbox').value = '';
		}
	}
}
var Event = YAHOO.util.Event;
function changeproductA(e) {
	var elTarget = YAHOO.util.Event.getTarget(e);
	elTarget = elTarget.id; 
	var product = MSB.$(elTarget).getAttribute('title');
	if (product == MSB.$('WEP_actprod').value) {
		return;
	}
	MSB.$('WEP_actprod').value = product;
	changeproduct('fromchange');
}
function changeproduct(where) {
	var product = MSB.$('WEP_actprod').value;
	updatecolors(product);
	var root = loadMyXML("./products/"+product+".xml?a="+Math.floor(Math.random()*10000));
	var frontloc = root.getElementsByTagName('front')[0].childNodes[0].nodeValue;
	var backloc = root.getElementsByTagName('back')[0].childNodes[0].nodeValue;
	var proddefault = root.getElementsByTagName('default')[0].childNodes[0].nodeValue;
	var proddefaultA = proddefault.split(", ");
	var newcolor = proddefaultA[0];
	var newrgb = proddefaultA[1];
	var newsize = proddefaultA[2];
	var newview = proddefaultA[3];
	var proddesc = root.getElementsByTagName('description')[0].childNodes[0].nodeValue;
	var FXYa = root.getElementsByTagName('FrontTopLeft')[0].childNodes[0].nodeValue;
	var BXYa = root.getElementsByTagName('BackTopLeft')[0].childNodes[0].nodeValue;
	var FW = root.getElementsByTagName('FrontWidth')[0].childNodes[0].nodeValue;
	var BW = root.getElementsByTagName('BackWidth')[0].childNodes[0].nodeValue;
	var FH = root.getElementsByTagName('FrontHeight')[0].childNodes[0].nodeValue;
	var BH = root.getElementsByTagName('BackHeight')[0].childNodes[0].nodeValue;
	var FXY = FXYa.split(" ");
	var BXY = BXYa.split(" ");
	if (where != 'fromopen') {
		MSB.$('WEP_prodRGB').value = newrgb;
	}
	MSB.$('WEP_printareaFX').value = FXY[1];
	MSB.$('WEP_printareaFY').value = FXY[0];
	MSB.$('WEP_printareaBX').value = BXY[1];
	MSB.$('WEP_printareaBY').value = BXY[0];
	MSB.$('WEP_printareaFW').value = FW;
	MSB.$('WEP_printareaFH').value = FH;
	MSB.$('WEP_printareaBW').value = BW;
	MSB.$('WEP_printareaBH').value = BH;
	MSB.$('WEP_printAreaF').style.top = FXY[0] + "px";
	MSB.$('WEP_printAreaF').style.left = FXY[1] + "px";
	MSB.$('WEP_printAreaF').style.width = FW + "px";
	MSB.$('WEP_printAreaF').style.height = FH + "px";
	MSB.$('WEP_printAreaB').style.top = BXY[0] + "px";
	MSB.$('WEP_printAreaB').style.left = BXY[1] + "px";
	MSB.$('WEP_printAreaB').style.width = BW + "px";
	MSB.$('WEP_printAreaB').style.height = BH + "px";
	if (where != 'fromopen') {
		MSB.$('WEP_productColor').value = newcolor;
		MSB.$('WEP_productSize').value = newsize;
		MSB.$('WEP_printloc').value = newview;
	}
	
	MSB.$('WEP_sel-F').style.visibility = 'visible';
	MSB.$('WEP_sel-B').style.visibility = 'visible';
	if (frontloc.toLowerCase() != 'true') {
		MSB.$('WEP_sel-F').style.visibility = 'hidden';
		MSB.$('WEP_mediaLayerF').style.visibility = 'hidden';
		MSB.$('WEP_mediaLayerB').style.visibility = 'visible';
		MSB.$('WEP_printloc').value = 'B';
	}
	if (backloc.toLowerCase() != 'true') {
		MSB.$('WEP_sel-B').style.visibility = 'hidden';
		MSB.$('WEP_mediaLayerB').style.visibility = 'hidden';
		MSB.$('WEP_mediaLayerF').style.visibility = 'visible';
		MSB.$('WEP_printloc').value = 'F';
	}
	var html = '<strong>'+product.replace(/-/g," ")+'</strong><br />'+proddesc;
	MSB.$('WEP_proddescDiv').innerHTML = html;
	
	if (where == "fromchange") {
		YAHOO.example.container.panel18.show();
	}
	changeproductcolor();
}
function changeproductsize(e) {
/*	var elTarget = YAHOO.util.Event.getTarget(e);
	elTarget = elTarget.id; 
	var mysplit = elTarget.split("-");
	var index = mysplit.length - 1;
	var size = mysplit[index];
	var color = MSB.$('WEP_productColor').value;
	var product = MSB.$('WEP_actprod').value;
	var validsize = checksizeexclusion(product,color,size);
	var numlinesF = MSB.$('WEP_numlinesF').value;
	var numlinesB = MSB.$('WEP_numlinesB').value;
	var price = pricechange(product,color,size,numlinesF,numlinesB);
	if (validsize == "isvalid") {
		var oldsize = MSB.$('WEP_productSize').value;
		MSB.$('WEP_sel-size-'+product+'-'+oldsize).style.backgroundColor = "#eeeeee";
		MSB.$('WEP_productSize').value = size;
		MSB.$('WEP_sel-size-'+product+'-'+size).style.backgroundColor = "#ff9999";
		MSB.$('WEP_productPrice').value = price;
		MSB.$('WEP_priceDiv').innerHTML = "1 Side: "+MSB.$('WEP_moneySymbol').value+MSB.$('WEP_pricetemp1').value+'<br />2 Sides: '+MSB.$('WEP_moneySymbol').value+MSB.$('WEP_pricetemp2').value;
	}
	else {
		alert('Invalid Size: '+size+' not available in '+color+'.');
	} */
}
function checksizeexclusion(product,color,size) {
	var root = loadMyXML("./products/"+product+".xml?a="+Math.floor(Math.random()*10000));
	var mycolors = root.getElementsByTagName('color');
	var proddefault = root.getElementsByTagName('default')[0].childNodes[0].nodeValue;
	var proddefaultA = proddefault.split(", ");
	var defaultsize = proddefaultA[2];
	for (var i=0;i<mycolors.length;i++) {
		if (mycolors[i].getAttribute('name') == color) {
			var myexcludeA = mycolors[i].getElementsByTagName('excludesize');
			var myexclude = myexcludeA[0].childNodes[0].nodeValue;
			if (myexclude == size) {
				return(defaultsize);
			}
		} 
	} 
	return("isvalid");
}
function pricechange(product,color,size,numlinesF,numlinesB) {
	var numsides = 'oneside';
	if (numlinesF > 0 && numlinesB > 0) {
		numsides = 'twoside';
	}
	var root = loadMyXML("./products/"+product+".xml?a="+Math.floor(Math.random()*10000));
	var mycolors = root.getElementsByTagName('color');
	var myfront = root.getElementsByTagName('front')[0].childNodes[0].nodeValue;
	var myback = root.getElementsByTagName('back')[0].childNodes[0].nodeValue;
	for (var i=0;i<mycolors.length;i++) {
		if (mycolors[i].getAttribute('name') == color) {
			var myprices = mycolors[i].getElementsByTagName('prices')[0];
			var myF = myprices.getElementsByTagName('oneside')[0].childNodes[0].nodeValue;
			var spF1 = myF.split(" ");
			for (var t=0;t<spF1.length;t++) {
				var spF2 = spF1[t].split("=");
				if (spF2[0] == size) {
					var newprice1 = spF2[1];
					MSB.$('WEP_pricetemp1').value = parseFloat(newprice1).toFixed(2);
				}
			}
			var myB = myprices.getElementsByTagName('twoside')[0].childNodes[0].nodeValue;
			if (myB.charAt(0) == '+') {
				var extra = myB.substring(1);
				var newprice2 = parseFloat(newprice1) + parseFloat(extra);
				MSB.$('WEP_pricetemp2').value = parseFloat(newprice2).toFixed(2);
			}
			else {
				var spB1 = myB.split(" ");
				for (var t=0;t<spB1.length;t++) {
					var spB2 = spB1[t].split("=");
					if (spB2[0] == size) {
						var newprice2 = spB2[1];
						MSB.$('WEP_pricetemp2').value = parseFloat(newprice2).toFixed(2);
					}
				}
			}
		} 
	} 
	if (myback == 'FALSE' || myfront == 'FALSE') {
		MSB.$('WEP_pricetemp2').value = "N/A";
	}
	if (numsides == 'oneside') {
		var newprice = newprice1;
	}
	else {
		var newprice = newprice2;
	}
	return parseFloat(newprice).toFixed(2);
}
//TEXT UTIL
function addnewtext() {
	var loc = MSB.$('WEP_actloc').value;
	MSB.$('WEP_currentFMT').value = 'text';
	var mytext = MSB.$('WEP_edittextbox').value;
	var numchars = mytext.length;
	var lineGood = false;
	for (var x=0; x<numchars; x++)  {
		var charCode = mytext.charCodeAt(x);
		if (charCode >= 33 && charCode <= 126)  {
			lineGood = true;
		}
	}
	if (lineGood == false) {
		alert(alert_empty_lines);
	}	
	else {
		var fs,fc,ft,top,left,tx,newID,himg,wimg,zind,fh,fv,rot;
		tx = MSB.$('WEP_edittextbox').value;
		MSB.$('WEP_acttop').value = MSB.$('WEP_lowY').value;
		top = MSB.$('WEP_lowY').value;
		MSB.$('WEP_actleft').value = '10';
		MSB.$('WEP_actstkw').value = '0';
		MSB.$('WEP_actarch').value = '0';
		MSB.$('WEP_actstkc').value = MSB.$('WEP_defaultTextColor').value;
		left = '10';
		fc = MSB.$('WEP_defaultTextColor').value;
		ft = 'Arial';
		fs = fontSizeDefault;
		himg = '1';
		wimg = '1';
		zind = '0';
		fh = 'no';
		fv = 'no';
		rot = '0';
		newID = createDOM(tx,ft,fs,fc,left,top,himg,wimg,zind,"text",fh,fv,rot);
		edittext('fromnewline');
		MSB.$("WEP_fsedit").value = fs;
		YAHOO.util.Event.on(newID, "click", divdown);
		YAHOO.util.Event.on(newID, "mouseout", function() {divup(newID); });
	}
}
function checkwidth(Wgifold) {
	return Wgifold;
}
function edittext(fromwho) {
	var ID = MSB.$('WEP_design_id').value;
	var whichline = MSB.$('WEP_actline').value;
	var loc = MSB.$('WEP_actloc').value;
	var lineindex = whichline.substring(6);
	var numloadedimages = 0;
	var ft = MSB.$('WEP_ft' + lineindex).value;
	var fs = MSB.$('WEP_fs' + lineindex).value;
	var fc = MSB.$('WEP_fc' + lineindex).value;
	var fv = MSB.$('WEP_flipV' + lineindex).value;
	var fh = MSB.$('WEP_flipH' + lineindex).value;
	var rot = MSB.$('WEP_rot' + lineindex).value;
	var stkc = MSB.$('WEP_stkc' + lineindex).value;
	var stkw = MSB.$('WEP_stkw' + lineindex).value;
	if (fromwho != 'fromexisting') {
		var mytext = MSB.$('WEP_edittextbox').value;
	}
	else {
		if (fromwho == "fromexisting") {
			MSB.$('WEP_divimg'+lineindex).style.left = MSB.$('WEP_actleft').value + "px";
			MSB.$('WEP_left'+lineindex).value = MSB.$('WEP_actleft').value;
			MSB.$('WEP_divimg'+lineindex).style.top = MSB.$('WEP_acttop').value + "px";
			MSB.$('WEP_top'+lineindex).value = MSB.$('WEP_acttop').value;
		}
		var mytext = MSB.$('WEP_edittextbox').value;
		fromwho = 'fromeditfs';
	}
	var junk = myTime();
	if (whichline != 'none') {
		function countimages2() {
			if(++numloadedimages == 1) measureimages2(textimage);
		}
		for (var z=0;z < 1;z++) {
			var textimage = new Image();
			MSB.addEvent(textimage,'load',function () {countimages2();})
			textimage.src = "./encrypted/createtext.php?ft=" + ft + "&fc=" + fc + "&fs=" + fs + "&junk=" + junk + "&tx=" + encodeURIComponent(mytext) + "&stkc=" + stkc + "&stkw=" + stkw+"&ind="+lineindex+"&fh="+fh+"&fv="+fv+"&rot="+rot+"&ID="+ID;
		}
		function measureimages2() {
			var newWidth = parseInt(checkwidth(textimage.width));
			document.getElementById("WEP_divimg" + lineindex).style.height = textimage.height + "px";
			document.getElementById("WEP_divimg" + lineindex).style.width = newWidth + "px";
			if (fromwho != 'fromcolorchange') {
				if (fromwho == 'fromnewline') {
					var halfW = parseInt(MSB.$('WEP_printarea'+MSB.$('WEP_actloc').value+'W').value)/2;
					var newleft = halfW - Math.round(textimage.width/2);
					MSB.$("WEP_left" + lineindex).value = newleft;
					MSB.$("WEP_divimg" + lineindex).style.left = newleft + "px";
					makedragable();
				}
			}
			pngMSIE(textimage.src,textimage.height,textimage.width,lineindex);
			MSB.$("WEP_Himg" + lineindex).value = textimage.height;
			MSB.$("WEP_Wimg" + lineindex).value = newWidth;
		}
	}
}
function updatetext() {
	var whichline = MSB.$('WEP_actline').value;
	var lineindex = whichline.substring(6);
	if (MSB.$('WEP_arch'+lineindex).value == '0') {
		if (MSB.$('WEP_actline').value != 'none' && MSB.$('WEP_currentFMT').value == 'text') {
			var mytext = MSB.$('WEP_edittextbox').value;
			var txdiv = MSB.$('WEP_actline').value;
			MSB.$(txdiv).value = mytext;
			var numchars = mytext.length;
			var lineGood = false;
			for (var x=0; x<numchars; x++)  {
				var charCode = mytext.charCodeAt(x);
				if (charCode >= 33 && charCode <= 126)  {
					lineGood = true;
				}
			}
			if (lineGood == false) {
				alert(alert_empty_lines2);
				deletetext();
				return;
			}	
			edittext('fromupdate');
		}
	}
}
function editfs() {
	var newfs = parseInt(MSB.$('WEP_fsedit').value);
	var whichline = MSB.$('WEP_actline').value;
	var lineindex = whichline.substring(6);
	if (MSB.$('WEP_arch'+lineindex).value == '0') {
		/*if (newfs >= fontSizeMin && newfs <= fontSizeMax) {
			var whichline = MSB.$('WEP_actline').value;
			var lineindex = whichline.substring(6);
			MSB.$('WEP_fs' + lineindex).value = newfs;
			edittext('fromeditfs');
		} */
		if (newfs > fontSizeMax) {
			MSB.$('WEP_fsedit').value = fontSizeMax;
			MSB.$('WEP_fs' + lineindex).value = fontSizeMax;
			edittext('fromeditfs');
			return;
		}
		if (newfs < fontSizeMin) {
			MSB.$('WEP_fsedit').value = fontSizeMin;
			MSB.$('WEP_fs' + lineindex).value = fontSizeMin;
			edittext('fromeditfs');
			return;
		}
		MSB.$('WEP_fs' + lineindex).value = newfs;
		edittext('fromeditfs');
	}
}
function fsIncrease() {
	var lineindex = MSB.$('WEP_actline').value.substring(6);
	if (MSB.$('WEP_arch'+lineindex).value == '0') {
		var format = MSB.$('WEP_currentFMT').value;
		var loc = MSB.$('WEP_actloc').value;
		if (loc == 'F') {
			var maxW = MSB.$('WEP_printareaFW').value;
		}
		if (loc == 'B') {
			var maxW = MSB.$('WEP_printareaBW').value;
		}
		if (format == 'text') {
			var newfs = parseInt(MSB.$('WEP_fsedit').value);
			var curW = parseInt(MSB.$('WEP_Wimg'+lineindex).value);
			if (curW < maxW && newfs < fontSizeMax) {
				newfs = newfs + 1;
				MSB.$('WEP_fsedit').value = newfs;
				MSB.$('WEP_oldfs').value = MSB.$('WEP_fs' + lineindex).value;
				MSB.$('WEP_fs' + lineindex).value = newfs;
				edittext('fromeditfs');
				return;
			}
		}
	}
}
function fsDecrease() {
	var lineindex = MSB.$('WEP_actline').value.substring(6);
	if (MSB.$('WEP_arch'+lineindex).value == '0') {
		var format = MSB.$('WEP_currentFMT').value;
		if (format == 'text') {
			var newfs = parseInt(MSB.$('WEP_fsedit').value);
			if (newfs > fontSizeMin) {
				newfs = newfs - 1;
				MSB.$('WEP_fsedit').value = newfs;
				var whichline = MSB.$('WEP_actline').value;
				var lineindex = whichline.substring(6);
				MSB.$('WEP_oldfs').value = MSB.$('WEP_fs' + lineindex).value;
				MSB.$('WEP_fs' + lineindex).value = newfs;
				edittext('fromeditfs');
			}
		}
	}
}
function fontselect(e) {
	var lineindex = MSB.$('WEP_actline').value.substring(6);
	if (MSB.$('WEP_arch'+lineindex).value == '0') {
		var elTarget = YAHOO.util.Event.getTarget(e);
		elTarget = elTarget.id;
		var myfont = MSB.$(elTarget).getAttribute('title');
		if (MSB.$('WEP_currentFMT').value == 'text' && MSB.$('WEP_actline').value != 'none') {
			var lineindex = MSB.$('WEP_actline').value.substring(6);
			MSB.$('WEP_oldfont').value = MSB.$('WEP_ft' + lineindex).value;
			MSB.$('WEP_ft' + lineindex).value = myfont;
			edittext('fromeditft');
		}
	}
}
YAHOO.util.Event.onDOMReady(function() {
	var ID = document.getElementById("WEP_fsedit");
	var fsboxEnter = new YAHOO.util.KeyListener(ID,{keys:13},function() {
		var newfs = Math.abs(parseInt(MSB.$('WEP_fsedit').value));
		if (newfs < fontSizeMin) {
			newfs = fontSizeMin;
			MSB.$('WEP_fsedit').value = fontSizeMin;
		}
		if (newfs > fontSizeMax) {
			newfs = fontSizeMax;
			MSB.$('WEP_fsedit').value = fontSizeMax;
		}
		var lineindex = MSB.$('WEP_actline').value.substring(6);
		if (MSB.$('WEP_arch'+lineindex).value == '0') {
			MSB.$('WEP_fs' + lineindex).value = newfs;
			if (MSB.$('WEP_currentFMT').value == 'text') {
				edittext('fromeditfs'); 
			}
		}
	}
  );
	fsboxEnter.enable();
});
function loadtext(ind) {
	var ID = MSB.$('WEP_design_id').value;
	var fs,fc,ft,top,left,tx,newID,himg,wimg,zind,fh,fv,rot,arch;
	tx = MSB.$('WEP_edittextbox').value;
	top = MSB.$('WEP_acttop').value;
	left = MSB.$('WEP_actleft').value;
	ft = MSB.$('WEP_actft').value;
	fc = MSB.$('WEP_actfc').value;
	fs = MSB.$('WEP_actfs').value;
	fv = MSB.$('WEP_actflipv').value;
	fh = MSB.$('WEP_actfliph').value;
	rot = MSB.$('WEP_actrot').value;
	stkc = MSB.$('WEP_actstkc').value;
	stkw = MSB.$('WEP_actstkw').value;
	himg = MSB.$('WEP_acthimg').value;
	wimg = MSB.$('WEP_actwimg').value;
	zind = MSB.$('WEP_actzind').value;
	arch = MSB.$('WEP_actarch').value;
	newID = createDOM(tx,ft,fs,fc,left,top,himg,wimg,zind,"text",fh,fv,rot);
	var i = newID.substring(10); //divimgF0
	var junk = myTime();
	var textimage = new Image();
	if (arch == '0') {
		textimage.src = "./encrypted/createtext.php?ft=" + ft + "&fc=" + fc + "&fs=" + fs + "&junk=" + junk + "&tx=" + encodeURIComponent(tx) + "&stkc=" + stkc + "&stkw=" + stkw+"&ind="+i+"&fh="+fh+"&fv="+fv+"&rot="+rot+"&ID="+ID;
		pngMSIE(textimage.src,himg,wimg,i);
	}
	else {
		textimage.src = './images/'+MSB.$('WEP_design_id').value+'/tx'+ind+'-arch.png';
		//alert(textimage.src);
		var H = parseInt(himg)+Math.abs(parseInt(arch));
		MSB.$('WEP_divimg'+i).style.height = H + "px";
		MSB.$('WEP_divimg'+i).style.width = wimg + "px";
		pngMSIE(textimage.src,himg,wimg,i);
	}
	makedragable();
	MSB.$("WEP_fsedit").value = fs;
	YAHOO.util.Event.on(newID, "click", divdown);
	YAHOO.util.Event.on(newID, "mouseout", function() {divup(newID); });
}
function stkIncrease() {
	var lineindex = MSB.$('WEP_actline').value.substring(6);
	if (MSB.$('WEP_arch'+lineindex).value == '0') {
		var format = MSB.$('WEP_currentFMT').value;
		if (format == 'text') {
			var newstk = parseInt(MSB.$('WEP_stkedit').value);
			if (newstk < 10) {
				newstk = newstk + 1;
				MSB.$('WEP_stkedit').value = newstk;
				var whichline = MSB.$('WEP_actline').value;
				var lineindex = whichline.substring(6);
				MSB.$('WEP_stkw' + lineindex).value = newstk;
				edittext('fromeditfs');
			}
		}
	}
}
function stkDecrease() {
	var lineindex = MSB.$('WEP_actline').value.substring(6);
	if (MSB.$('WEP_arch'+lineindex).value == '0') {
		var format = MSB.$('WEP_currentFMT').value;
		if (format == 'text') {
			var newstk = parseInt(MSB.$('WEP_stkedit').value);
			if (newstk > 0) {
				newstk = newstk - 1;
				MSB.$('WEP_stkedit').value = newstk;
				var whichline = MSB.$('WEP_actline').value;
				var lineindex = whichline.substring(6);
				MSB.$('WEP_stkw' + lineindex).value = newstk;
				edittext('fromeditfs');
			}
		}
	}
}
//STOCK IMAGE UTIL
function stockimgselect(e) {
	var elTarget = YAHOO.util.Event.getTarget(e);
	elTarget = elTarget.id; 
	var mysym = elTarget.substring(9);
	var ext = mysym.split('.');
	var loc = MSB.$('WEP_actloc').value;
	MSB.$('WEP_curImExt').value = ext[1];
	var maxW = MSB.$('WEP_printarea'+loc+'W').value;
	var maxH = MSB.$('WEP_printarea'+loc+'H').value;
	var index = MSB.$('WEP_curStockCode').value;
	MSB.$('WEP_curStockCode').value = parseInt(MSB.$('WEP_curStockCode').value) + 1;
	MSB.$('WEP_currentFMT').value = 'stock';
	var fs,fc,ft,top,left,tx,wimg,himg,zind;
	MSB.$('WEP_acttop').value = MSB.$('WEP_lowY').value;
	top = MSB.$('WEP_lowY').value;
	MSB.$('WEP_actleft').value = '10';
	left = '10';
	fc = mysym;
	ft = MSB.$(elTarget).getAttribute('alt');
	fs = '100';
	tx = 'Stock'+index+'.'+ext[1];
	himg = '1';
	wimg = '1';
	zind = '0';
	fh = 'no';
	fv = 'no';
	rot = '0';
	var newID = createDOM(tx,ft,fs,fc,left,top,himg,wimg,zind,"stock",fh,fv,rot);
	var resize = new YAHOO.util.Resize(newID, {
	  handles: ['tr','tl','br','bl'],
		knobHandles: true,
		hover: true,
		proxy: true,
		ratio: true,
		maxWidth: maxW,
		maxHeight: maxH
	}); 
	YAHOO.util.Event.on(newID, "click", divdown);
	YAHOO.util.Event.on(newID, "mouseout", function() {divup(newID); });
	resize.on('endResize',function() {divup(newID); },resize,true); 
	placestock();
}
function placestock() {
	var lineindex = MSB.$('WEP_actline').value.substring(6);
	var fileext = MSB.$('WEP_curImExt').value;
	var newImg = MSB.$('WEP_tx'+lineindex).value.split('.');
	var oldImg = MSB.$('WEP_fc'+lineindex).value.split('.');
	var group = MSB.$('WEP_ft'+lineindex).value;
	var successHandler = function(o) {
		var lineindex = MSB.$('WEP_actline').value.substring(6);
		var imgID = MSB.$('WEP_tx'+lineindex).value;
		var loc = MSB.$('WEP_actloc').value;
		var numloadedimages = 0;
		var fileext = MSB.$('WEP_curImExt').value;
		function countimages2() {
			if(++numloadedimages == 1) measureimages2(textimage);
		}
		for (var z=0;z < 1;z++) {
			var textimage = new Image();
			MSB.addEvent(textimage,'load',function () {countimages2();})
			textimage.src = "./images/"+MSB.$('WEP_design_id').value+"/" + imgID;
		}
		function measureimages2() {
			var newWidth = textimage.width;
			document.getElementById("WEP_divimg" + lineindex).style.height = textimage.height + "px";
			document.getElementById("WEP_divimg" + lineindex).style.width = newWidth + "px";
			var halfW = parseInt(MSB.$('WEP_printarea'+MSB.$('WEP_actloc').value+'W').value)/2;
			var newleft = halfW - Math.round(textimage.width/2);
			document.getElementById("WEP_divimg" + lineindex).style.left = newleft + "px";
			document.getElementById("WEP_left" + lineindex).value = newleft;
			makedragable();
			pngMSIE(textimage.src,textimage.height,textimage.width,lineindex);
			document.getElementById("WEP_Himg" + lineindex).value = textimage.height;
			document.getElementById("WEP_Wimg" + lineindex).value = newWidth;
			document.getElementById("WEP_tx" + lineindex).value = imgID;
		}
	}
	var callback = {
		success: successHandler
	};
	var sUrl = "./encrypted/copystock.php?old="+oldImg[0]+"&new="+newImg[0]+"&ext="+fileext+"&g="+group+"&ID="+MSB.$('WEP_design_id').value;
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
}
function loadstock() {
	var ID = MSB.$('WEP_design_id').value;
	var fs,fc,ft,top,left,tx,wimg,himg,zind,fv,fh,rot;
	var junk = myTime();
	MSB.$('WEP_curStockCode').value = parseInt(MSB.$('WEP_curStockCode').value)+1;
	MSB.$('WEP_currentFMT').value = 'stock';
	top = MSB.$('WEP_acttop').value;
	left = MSB.$('WEP_actleft').value;
	ft = MSB.$('WEP_actft').value;
	fc = MSB.$('WEP_actfc').value;
	fs = MSB.$('WEP_actfs').value;
	fh = MSB.$('WEP_actfliph').value;
	fv = MSB.$('WEP_actflipv').value;
	rot = MSB.$('WEP_actrot').value;
	tx = MSB.$('WEP_edittextbox').value;
	himg = MSB.$('WEP_acthimg').value;
	wimg = MSB.$('WEP_actwimg').value;
	zind = MSB.$('WEP_actzind').value;
	//MSB.$('curSymCode').value = tx;
	MSB.$('WEP_edittextbox').value = "";
	var newID = createDOM(tx,ft,fs,fc,left,top,himg,wimg,zind,"stock",fh,fv,rot);
	var i = newID.substring(10);
	var textimage = new Image();
	textimage.src = "./images/"+ID+"/"+tx;
	pngMSIE(textimage.src,himg,wimg,i);
	makedragable();
	var loc = MSB.$('WEP_actloc').value;
	var maxW = MSB.$('WEP_printarea'+loc+'W').value;
	var maxH = MSB.$('WEP_printarea'+loc+'H').value;
	var resize = new YAHOO.util.Resize(newID, {
	  handles: ['tr','tl','br','bl'],
		knobHandles: true,
		hover: true,
		proxy: true,
		ratio: true,
		maxWidth: maxW,
		maxHeight: maxH
	}); 
	YAHOO.util.Event.on(newID, "click", divdown);
	YAHOO.util.Event.on(newID, "mouseout", function() {divup(newID); });
	resize.on('endResize',function() {divup(newID); },resize,true);
}
//SYMBOL UTIL
function symbolselect(e) {
	var elTarget = YAHOO.util.Event.getTarget(e);
	elTarget = elTarget.id; 
	var mysym = elTarget.substring(11);
	MSB.$('WEP_curSymCode').value = mysym;
	MSB.$('WEP_currentFMT').value = 'symbol';
	var fs,fc,ft,top,left,tx,wimg,himg,zind;
	MSB.$('WEP_acttop').value = MSB.$('WEP_lowY').value;
	top = MSB.$('WEP_lowY').value;
	MSB.$('WEP_actleft').value = '10';
	left = '10';
	fc = MSB.$('WEP_defaultTextColor').value;
	ft = 'NA';
	fs = '100';
	tx = mysym;
	himg = '1';
	wimg = '1';
	zind = '0';
	fh = 'no';
	fv = 'no';
	rot = '0';
	var newID = createDOM(tx,ft,fs,fc,left,top,himg,wimg,zind,"symbol",fh,fv,rot);
	editsymbol('fromnewline');
	var loc = MSB.$('WEP_actloc').value;
	var maxW = MSB.$('WEP_printarea'+loc+'W').value;
	var maxH = MSB.$('WEP_printarea'+loc+'H').value;
	var resize = new YAHOO.util.Resize(newID, {
	  handles: ['tr','tl','br','bl'],
		knobHandles: true,
		hover: true,
		proxy: true,
		ratio: true,
		maxWidth: maxW,
		maxHeight: maxH
	}); 
	YAHOO.util.Event.on(newID, "click", divdown);
	YAHOO.util.Event.on(newID, "mouseout", function() {divup2(newID); });
	resize.on('endResize',function() {divup2(newID); },resize,true);
}
function editsymbol(fromwho) {
	var ID = MSB.$('WEP_design_id').value;
	var lineindex = MSB.$('WEP_actline').value.substring(6);
	var whichline = MSB.$('WEP_actline').value;
	var loc = MSB.$('WEP_actloc').value;
	var numloadedimages = 0;
	var fs = MSB.$('WEP_fs' + lineindex).value;
	var fc = MSB.$('WEP_fc' + lineindex).value;
	var fv = MSB.$('WEP_flipV' + lineindex).value;
	var fh = MSB.$('WEP_flipH' + lineindex).value;
	var rot = MSB.$('WEP_rot' + lineindex).value;
	var junk = myTime();
	if (whichline != 'none') {
		function countimages2() {
			if(++numloadedimages == 1) measureimages2(textimage);
		}
		for (var z=0;z < 1;z++) {
			var textimage = new Image();
			MSB.addEvent(textimage,'load',function () {countimages2();})
			textimage.src = "./encrypted/symbol-edit.php?sym=" + MSB.$('WEP_curSymCode').value + "&junk=" + junk + "&fc=" + fc + "&fs=" + fs+"&ind="+lineindex+"&fh="+fh+"&fv="+fv+"&rot="+rot+"&ID="+ID;
		}
		function measureimages2() {
			var newWidth = parseInt(checkwidth(textimage.width));
			document.getElementById("WEP_divimg" + lineindex).style.height = textimage.height + "px";
			document.getElementById("WEP_divimg" + lineindex).style.width = newWidth + "px";
			if (fromwho != 'fromcolorchange') {
				if (fromwho == 'fromnewline') {
					var halfW = parseInt(MSB.$('WEP_printarea'+MSB.$('WEP_actloc').value+'W').value)/2;
					var newleft = halfW - Math.round(textimage.width/2);
					document.getElementById("WEP_divimg" + lineindex).style.left = newleft + "px";
					document.getElementById("WEP_left" + lineindex).value = newleft;
					MSB.$('WEP_fs'+lineindex).value = newWidth;
					makedragable();
				}
			}
			pngMSIE(textimage.src,textimage.height,textimage.width,lineindex);
			document.getElementById("WEP_Himg" + lineindex).value = textimage.height;
			document.getElementById("WEP_Wimg" + lineindex).value = newWidth;
			document.getElementById("WEP_tx" + lineindex).value = MSB.$('WEP_curSymCode').value;
		}
	}
}
function loadsymbol() {
	var ID = MSB.$('WEP_design_id').value;
	var fs,fc,ft,top,left,tx,wimg,himg,zind,fv,fh,rot;
	var junk = myTime();
	MSB.$('WEP_currentFMT').value = 'symbol';
	top = MSB.$('WEP_acttop').value;
	left = MSB.$('WEP_actleft').value;
	ft = MSB.$('WEP_actft').value;
	fc = MSB.$('WEP_actfc').value;
	fs = MSB.$('WEP_actfs').value;
	fh = MSB.$('WEP_actfliph').value;
	fv = MSB.$('WEP_actflipv').value;
	rot = MSB.$('WEP_actrot').value;
	tx = MSB.$('WEP_edittextbox').value;
	himg = MSB.$('WEP_acthimg').value;
	wimg = MSB.$('WEP_actwimg').value;
	zind = MSB.$('WEP_actzind').value;
	MSB.$('WEP_curSymCode').value = tx;
	MSB.$('WEP_edittextbox').value = "";
	var newID = createDOM(tx,ft,fs,fc,left,top,himg,wimg,zind,"symbol",fh,fv,rot);
	var i = newID.substring(10);
	var textimage = new Image();
	textimage.src = "./encrypted/symbol-edit.php?sym=" + MSB.$('WEP_curSymCode').value + "&junk=" + junk + "&fc=" + fc + "&fs=" + fs+"&ind="+i+"&fh="+fh+"&fv="+fv+"&rot="+rot+"&ID="+ID;
	pngMSIE(textimage.src,himg,wimg,i);
	makedragable();
	var loc = MSB.$('WEP_actloc').value;
	var maxW = MSB.$('WEP_printarea'+loc+'W').value;
	var maxH = MSB.$('WEP_printarea'+loc+'H').value;
	var resize = new YAHOO.util.Resize(newID, {
	  handles: ['tr','tl','br','bl'],
		knobHandles: true,
		hover: true,
		proxy: true,
		ratio: true,
		maxWidth: maxW,
		maxHeight: maxH
	}); 
	YAHOO.util.Event.on(newID, "click", divdown);
	YAHOO.util.Event.on(newID, "mouseout", function() {divup2(newID); });
	resize.on('endResize',function() {divup2(newID); },resize,true);
}
//IMAGE UTIL
function placeimage() {
	var lineindex = MSB.$('WEP_actline').value.substring(6);
	var imgID = MSB.$('WEP_tx'+lineindex).value;
	var loc = MSB.$('WEP_actloc').value;
	var numloadedimages = 0;
	var fileext = MSB.$('WEP_curImExt').value;
	function countimages2() {
		if(++numloadedimages == 1) measureimages2(textimage);
	}
	for (var z=0;z < 1;z++) {
		var textimage = new Image();
		MSB.addEvent(textimage,'load',function () {countimages2();})
		textimage.src = "./images/"+MSB.$('WEP_design_id').value+"/Cimageedit" + imgID + fileext;
	}
	function measureimages2() {
		var newWidth = textimage.width;
		document.getElementById("WEP_divimg" + lineindex).style.height = textimage.height + "px";
		document.getElementById("WEP_divimg" + lineindex).style.width = newWidth + "px";
		var halfW = parseInt(MSB.$('WEP_printarea'+MSB.$('WEP_actloc').value+'W').value)/2;
		var newleft = halfW - Math.round(textimage.width/2);
		document.getElementById("WEP_divimg" + lineindex).style.left = newleft + "px";
		document.getElementById("WEP_left" + lineindex).value = newleft;
		makedragable();
		pngMSIE(textimage.src,textimage.height,textimage.width,lineindex);
		document.getElementById("WEP_Himg" + lineindex).value = textimage.height;
		document.getElementById("WEP_Wimg" + lineindex).value = newWidth;
		document.getElementById("WEP_tx" + lineindex).value = imgID;
	}
}
function togallery() {
	var ID = MSB.$('WEP_design_id').value;
	var ind = MSB.$('WEP_imageInd').value; //imageInd is index for gallery images
	MSB.$('WEP_imgloading1').style.visibility = "visible";
	MSB.$('WEP_imggalForm').action = "skins/basic/customer/addons/my_changes/designstudio/encrypted/getimage1.php?ind="+ind+"&ID="+ID;
	MSB.$('WEP_imggalForm').target = 'WEP_Hframe1';
	YAHOO.util.Connect.setForm(MSB.$('WEP_imggalForm'),true,true);
	var successHandler = function(o) {
		var fileext = o.responseText;
		if (o.responseText == 'error:filetype') {
			MSB.$('WEP_imgloading1').style.visibility = "hidden";
			alert(alert_image_type);
		}
		else {
			var newDiv = 'WEP_divDiv' + ind;
			var newImg = 'WEP_Gimg' + ind;
			var newSrc = "./images/"+MSB.$('WEP_design_id').value+"/Cimagethumb"+ind+fileext;
			var parent = MSB.$('WEP_imageframe');
			var newChild = document.createElement('IMG');
			newChild.setAttribute('id',newImg);
			newChild.setAttribute('name',newImg);
			newChild.setAttribute('src',newSrc);
			newChild.setAttribute('alt',fileext);
			parent.appendChild(newChild);
			YAHOO.util.Event.on(newImg, "click", addimage);
			MSB.$('WEP_imageInd').value = parseInt(ind) + 1;
			parent = MSB.$('WEP_workingParams');
			newChild = document.createElement('INPUT');
			newChild.setAttribute('id','WEP_countCimage'+ind);
			newChild.setAttribute('name','WEP_countCimage'+ind);
			newChild.setAttribute('type','hidden');
			newChild.setAttribute('value','0');
			parent.appendChild(newChild);
			MSB.$('WEP_imgloading1').style.visibility = "hidden";
		}
	}
	var callback = {
		upload: successHandler
	};
	var designID = MSB.$('WEP_design_id').value;
	var canvasFW = MSB.$('WEP_printareaFW').value;
	var canvasBW = MSB.$('WEP_printareaBW').value;
	var myW;
	if (canvasFW > canvasBW) {
		myW = canvasBW;
	}
	else {
		myW = canvasFW;
	}
	var sUrl = "./encrypted/getimage1.php?ind="+ind+'&W='+myW+"&ID="+ID;
	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback);
}
function addimage(e) {
	var elTarget = YAHOO.util.Event.getTarget(e);
	elTarget = elTarget.id; 
	var id = elTarget.substring(8);
	MSB.$('WEP_currentFMT').value = 'image';
	MSB.$('WEP_curImCode').value = id; // curImCode is index for images placed on shirt
	MSB.$('WEP_curImExt').value = MSB.$(elTarget).getAttribute('alt');
	var dup = parseInt(MSB.$('WEP_countCimage'+id).value);
	if (dup > 0) {
		var ind = id+'-'+dup;
		addDupImage(ind,MSB.$('WEP_curImExt').value);
		MSB.$('WEP_countCimage'+id).value = parseInt(dup) + 1;
	}
	else {
		var ind = id+'-0';
		addFirstImage(ind);
		MSB.$('WEP_countCimage'+id).value = parseInt(dup) + 1;
	}
}
function addFirstImage(ind) {
	var loc = MSB.$('WEP_actloc').value;
	var maxW = MSB.$('WEP_printarea'+loc+'W').value;
	var maxH = MSB.$('WEP_printarea'+loc+'H').value;
	var fs,fc,ft,top,left,tx,wimg,himg,zind,fh,fv,rot;
	MSB.$('WEP_acttop').value = MSB.$('WEP_lowY').value;
	top = MSB.$('WEP_lowY').value;
	MSB.$('WEP_actleft').value = '10';
	left = '10';
	fc = 'NA';
	ft = 'Cimage';
	fs = MSB.$('WEP_curImExt').value;
	tx = ind;
	himg = '1';
	wimg = '1';
	zind = '0';
	fh = 'no';
	fv = 'no';
	rot = '0';
	var newID = createDOM(tx,ft,fs,fc,left,top,himg,wimg,zind,"image",fh,fv,rot);
	var resize = new YAHOO.util.Resize(newID, {
			  handles: ['tr','tl','br','bl'],
				knobHandles: true,
				hover: true,
				proxy: true,
				ratio: true,
				maxWidth: maxW,
				maxHeight: maxH
			}); 
	resize.on('endResize',function() {divup(newID); },resize,true);
	placeimage();
}
function addDupImage(ind,ext) {
	var successHandler = function(o) {
		var status = o.responseText;
		if (status == 'good') {
			addFirstImage(ind);
		}
	}
	var callback = {
		success: successHandler
	}
	var sUrl = "./encrypted/dupimage.php?ind="+ind+"&ext="+ext+"&ID="+MSB.$('WEP_design_id').value;
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
}
function loadimage() {
	var indA = MSB.$('WEP_edittextbox').value.split('-');
	var ind = indA[0];
	var newImg = 'WEP_Gimg' + ind;
	var ext = MSB.$('WEP_actfs').value;
	if (MSB.$('WEP_Gimg'+ind)) {
		MSB.$('WEP_countCimage'+ind).value = parseInt(MSB.$('WEP_countCimage'+ind).value) + 1;
	}
	else {
		var newSrc = "./images/"+MSB.$('WEP_design_id').value+"/Cimagethumb"+ind+ext;
		var parent = MSB.$('WEP_imageframe');
		var newChild = document.createElement('IMG');
		newChild.setAttribute('id',newImg);
		newChild.setAttribute('name',newImg);
		newChild.setAttribute('src',newSrc);
		newChild.setAttribute('alt',ext);
		parent.appendChild(newChild);
		parent = MSB.$('WEP_workingParams');
		newChild = document.createElement('INPUT');
		newChild.setAttribute('id','WEP_countCimage'+ind);
		newChild.setAttribute('name','WEP_countCimage'+ind);
		newChild.setAttribute('type','hidden');
		newChild.setAttribute('value','1');
		parent.appendChild(newChild);
		MSB.$('WEP_imageInd').value = parseInt(MSB.$('WEP_imageInd').value) + 1;
		YAHOO.util.Event.on(newImg, "click", addimage);
	}	
	var wimg = MSB.$('WEP_actwimg').value;
	var loc = MSB.$('WEP_actloc').value;
	var fileext = MSB.$('WEP_actfs').value;
	var newDiv = 'WEP_divDiv' + ind;
	var fs,fc,ft,top,left,tx,wimg,himg,zind,fh,fv,rot;
	MSB.$('WEP_currentFMT').value = 'image';
	top = MSB.$('WEP_acttop').value;
	left = MSB.$('WEP_actleft').value;
	ft = MSB.$('WEP_actft').value;
	fc = MSB.$('WEP_actfc').value;
	fs = MSB.$('WEP_actfs').value;
	fh = MSB.$('WEP_actfliph').value;
	fv = MSB.$('WEP_actflipv').value;
	rot = MSB.$('WEP_actrot').value;
	tx = MSB.$('WEP_edittextbox').value;
	himg = MSB.$('WEP_acthimg').value;
	wimg = MSB.$('WEP_actwimg').value;
	zind = MSB.$('WEP_actzind').value;
	MSB.$('WEP_curImCode').value = tx;
	MSB.$('WEP_edittextbox').value = "";
	var newID = createDOM(tx,ft,fs,fc,left,top,himg,wimg,zind,"image",fh,fv,rot); 
	var i = newID.substring(10);
	var textimage = new Image();
	textimage.src = "./images/"+MSB.$('WEP_design_id').value+"/Cimageedit" + tx + fs;
	var maxW = MSB.$('WEP_printarea'+loc+'W').value;
	var maxH = MSB.$('WEP_printarea'+loc+'H').value;
	var resize = new YAHOO.util.Resize(newID, {
		  handles: ['tr','tl','br','bl'],
			knobHandles: true,
			hover: true,
			proxy: true,
			ratio: true,
			maxWidth: maxW,
			maxHeight: maxH
		}); 
	resize.on('endResize',function() {divup(newID); },resize,true);
	pngMSIE(textimage.src,himg,wimg,i);
	makedragable(); 
}
//MSB JS
(function(){
if(!window['MSB']) {
    window['MSB'] = {};
}
function isCompatible(other) {
    if( other===false 
        || !Array.prototype.push
        || !Object.hasOwnProperty
        || !document.createElement
        || !document.getElementsByTagName
        ) {
        return false;
    }
    return true;
}
window['MSB']['isCompatible'] = isCompatible;
function $() {
    var elements = new Array();
    for (var i = 0; i < arguments.length; i++) {
        var element = arguments[i];
        if (typeof element == 'string') {
            element = document.getElementById(element);
        }
        if (arguments.length == 1) {
            return element;
        }
        elements.push(element);
    }
    return elements;
};
window['MSB']['$'] = $;
function addEvent( node, type, listener ) {
    if(!isCompatible()) { return false }
    if(!(node = $(node))) return false;
    if (node.addEventListener) {
        // W3C method
        node.addEventListener( type, listener, false );
        return true;
    } else if(node.attachEvent) {
        // MSIE method
        node['e'+type+listener] = listener;
        node[type+listener] = function(){node['e'+type+listener]( window.event );}
        node.attachEvent( 'on'+type, node[type+listener] );
        return true;
    }
    return false;
};
window['MSB']['addEvent'] = addEvent;
})();
//Form Validation
function WAAddError(formElement,errorMsg,focusIt,stopIt)  {
  if (document.WAFV_Error)  {
	  document.WAFV_Error += "\n" + errorMsg;
  }
  else  {
    document.WAFV_Error = errorMsg;
  }
  if (!document.WAFV_InvalidArray)  {
    document.WAFV_InvalidArray = new Array();
  }
  document.WAFV_InvalidArray[document.WAFV_InvalidArray.length] = formElement;
  if (focusIt && !document.WAFV_Focus)  {
	document.WAFV_Focus = focusIt;
  }

  if (stopIt == 1)  {
	document.WAFV_Stop = true;
  }
  else if (stopIt == 2)  {
	formElement.WAFV_Continue = true;
  }
  else if (stopIt == 3)  {
	formElement.WAFV_Stop = true;
	formElement.WAFV_Continue = false;
  }
}
function WAValidateAN(formElement,value,errorMsg,allowUpper,allowLower,allowNumbers,allowSpace,extraChars,focusIt,stopIt,required)  {
  var isValid = true;
  extraChars = extraChars.replace(/&quot;/g,'"');
    for (var x=0; x<value.length; x++)  {
	  var charGood = false;
	  var nextChar = value.charAt(x);
	  var charCode = value.charCodeAt(x);
	  if (allowLower)  {
	    if (charCode >= 97 && charCode <= 122)  {
		  charGood = true;
		}
	  }
	  if (allowUpper)  {
	    if (charCode >= 65 && charCode <= 90)  {
		  charGood = true;
		}
	  }
	  if (allowNumbers)  {
	    if (charCode >= 48 && charCode <= 57)  {
		  charGood = true;
		}
	  }
	  if (allowSpace)  {
	    if (nextChar == " ")  {
		  charGood = true;
		}
	  }
	  if (extraChars)  {
	    if (unescape(extraChars).indexOf(nextChar) >= 0)  {
		  charGood = true;
		}
	  }
	  if (!charGood)  {
	    isValid = false;
		x = value.length;
	  }
	}
	if (required && value=="") {
	  isValid = false;
  }
  if (!isValid)  {
  }
  return isValid;
}
function WAValidateEM(formElement,value,errorMsg,focusIt,stopIt,required) {
  var isValid = true;
	var knownDomsPat = /^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat = /^(.+)@(.+)$/;
	var accepted = "\[^\\s\\(\\)><@,;:\\\\\\\"\\.\\[\\]\]+";
	var quotedUser = "(\"[^\"]*\")";
	var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var section = "(" + accepted + "|" + quotedUser + ")";
	var userPat = new RegExp("^" + section + "(\\." + section + ")*$");
	var domainPat = new RegExp("^" + accepted + "(\\." + accepted +")*$");
	var theMatch = value.match(emailPat);
	var acceptedPat = new RegExp("^" + accepted + "$");
	var userName = "";
	var domainName = "";
	if (theMatch==null) {
	  isValid = false;
	}
	else  {
	  userName = theMatch[1];
	  domainName = theMatch[2];
	  var domArr = domainName.split(".");
	  var IPArray = domainName.match(ipDomainPat);
	  for (x=0; x < userName.length; x++) {
		if (userName.charCodeAt(x) > 127) {
		  isValid = false;
		}
	  }
	  for (x=0; x < domainName.length; x++) {
		if (domainName.charCodeAt(x) > 127) {
		  isValid = false;
		}
	  }
	  if (userName.match(userPat) == null) {
		isValid = false;
	  }
	  if (IPArray != null) {
		for (var x=1; x<=4; x++) {
		  if (IPArray[x] > 255) {
			isValid = false;
		  }
		}
	  }
	  for (x=0; x < domArr.length; x++) {
		if (domArr[x].search(acceptedPat) == -1 || domArr[x].length == 0) {
		  isValid = false;
		}
	  }
	  if (domArr[domArr.length-1].length !=2 && domArr[domArr.length-1].search(knownDomsPat) == -1) {
		isValid = false;
	  }
	  if (domArr.length < 2) {
		isValid = false;
	  }
	}
	return isValid;
}
function loadMyXML (file) {
	var xmlDoc;
	xmlDoc=new window.XMLHttpRequest();
	xmlDoc.open("GET",file,false);
	xmlDoc.send("null");
	return xmlDoc.responseXML;
}
function getInstantQuote(from) {
	var successHandler = function(o) {
		var HTML ='';
		var HTML2 ='';
		var HTML3 ='';
		var size, sizePrice;
		var status = o.responseText;
		if (from == 'wrk') {
			var colors = status.split(':');
		}
		if (from == 'S') {
			var colors = new Array();
			colors[0] = MSB.$('WEP_numcolorsF2').value;
			colors[1] = MSB.$('WEP_numcolorsB2').value;
			if ((colors[0] == '0') && (colors[1] == '0')) {
				colors[2] = '1';
			}
		}
		if (from == 'open') {
			var colors = new Array();
			colors[0] = MSB.$('WEP_numcolorsF').value;
			colors[1] = MSB.$('WEP_numcolorsB').value;
		}
		MSB.$('WEP_numcolorsF').value = colors[0];
		MSB.$('WEP_numcolorsB').value = colors[1];
		if (colors[2] == '1') {
			HTML = alert_instant_quote;
			MSB.$('WEP_numcolorsF').value = '0';
			MSB.$('WEP_numcolorsB').value = '0';
		}
		else {
			var prod = MSB.$('WEP_actprod').value;
			var root = loadMyXML('products/'+prod+'-pricesheet.xml?a='+Math.floor(Math.random()*10000));
			var setup = parseInt(root.getElementsByTagName('setupPerColor')[0].childNodes[0].nodeValue);
			var pricePerColor = parseInt(root.getElementsByTagName('pricePerColor')[0].childNodes[0].nodeValue);
			var Cprice = colors[0]*pricePerColor + colors[1]*pricePerColor;
			Cprice = parseFloat(Cprice);
			var maxNumColors = root.getElementsByTagName('maxNumberColors')[0].childNodes[0].nodeValue;
			MSB.$('WEP_maxNumColors').value = maxNumColors;
			var setupCharges = setup*colors[0] + setup*colors[1];
			var breaks = root.getElementsByTagName('priceBreaks');
			var breakA = breaks[0].getElementsByTagName('breakPoint');
			var Iprices = root.getElementsByTagName('blankPrices');
			var IpriceA = Iprices[0].getElementsByTagName('blank');
			HTML3 = '<select id="ADTCsizeSelect" name="ADTCsizeSelect">';
			HTML3 = HTML3 + '</select>';
			var Iprice = 0.00;
			var Iprice = parseFloat(IpriceA[0].childNodes[0].nodeValue);
			var color;
			for (var i=0;i<IpriceA.length;i++) {
				color = IpriceA[i].getAttribute('color');
				if (color == MSB.$('WEP_productColor').value) {
					Iprice = parseFloat(IpriceA[i].childNodes[0].nodeValue);
				}
			}
			var Fprice = Cprice + Iprice;
			HTML = setup_charges_text+MSB.$('WEP_moneySymbol').value+setupCharges+'<br />';
			HTML = HTML + max_colors_text+' '+maxNumColors;
			HTML = HTML + '<table class="WEP_IQtable"><tr class="head"><td>Qty</td><td>per item</td></tr>';
			HTML2 = '<select id="WEP_IQadtcQtySelect" name="WEP_IQadtcQtySelect">';
			var qty;
			var Pprice = 0.00;
			var price = 0.00;
			for (var i=0;i<breakA.length;i++) {
				qty = breakA[i].getAttribute('qty');					
				Pprice = parseFloat(breakA[i].childNodes[0].nodeValue);
				price = parseFloat(Pprice+Fprice).toFixed(2);
				if (i == 0) {
					MSB.$('WEP_productPrice2').value = price;
				}
				HTML = HTML + '<tr><td>'+qty+'</td><td id="IQamount'+qty+'">'+MSB.$('WEP_moneySymbol').value+price+'</td></tr>';
				HTML2 = HTML2 + '<option value="'+qty+'_'+price+'" >'+qty+'</option>';
			}
			HTML = HTML + '</table>';
			HTML2 = HTML2 + '</select>';
		}
		if (from == 'wrk' || from == 'open') {
			MSB.$('WEP_IQresultsDiv').innerHTML = HTML;
			MSB.$('WEP_priceDiv2').innerHTML = HTML;
		}
		if (from == 'S') {
		}
	}
	var failureHandler = function(o) {
		alert (alert_failed_connection)
	}
	var callback = {
		success: successHandler,
		failure: failureHandler
	}
	YAHOO.util.Connect.setForm("WEP_formSaveDesign");
	var cObj = YAHOO.util.Connect.asyncRequest('POST', './php/get-instant-quote.php', callback);
} 
function calcNumColors() {
	var successHandler = function(o) {
		var status = o.responseText;
		var colors = status.split(':');
		MSB.$('WEP_numcolorsF').value = colors[0];
		MSB.$('WEP_numcolorsB').value = colors[1];
		MSB.$('WEP_numcolorsF2').value = colors[0];
		MSB.$('WEP_numcolorsB2').value = colors[1];
		if (colors[2] == '1') {
			HTML = instant_quote_text;
			MSB.$('WEP_numcolorsF').value = '0';
			MSB.$('WEP_numcolorsB').value = '0';
			MSB.$('WEP_numcolorsF2').value = '0';
			MSB.$('WEP_numcolorsB2').value = '0';
		}
		savedesignA();
	}
	var failureHandler = function(o) {
		alert (alert_failed_connection)
	}
	var callback = {
		success: successHandler,
		failure: failureHandler
	}
	YAHOO.util.Connect.setForm("WEP_formSaveDesign");
	var cObj = YAHOO.util.Connect.asyncRequest('POST', './php/get-instant-quote.php', callback);
}
function openGetQForm() {
	YAHOO.example.container.panel29.show();
} 