
/* /CommerceCM/scripts/controls.js */

function CCM_ChangeCurrency(currency,defaultcurrency){var currentHref=document.location.href;var newHref=document.location.href;var theCurrency=(currency-0);if(!CCM_ValidateCurrency(theCurrency)){theCurrency=defaultcurrency;}
if(currentHref.indexOf("?")<0){newHref=currentHref+"?pricecat="+theCurrency;}
else if(currentHref.toLowerCase().indexOf("pricecat=")<0){newHref=currentHref+"&pricecat="+theCurrency;}
else{newHref=currentHref.replace(/pricecat\=[0-9]+/gi,"pricecat="+theCurrency);}
document.location.href=newHref;}
function CCM_ValidateCurrency(currency){if(currency>0&&currency<6){return true;}else{return false;}}
function CCM_AppendStyleSheet(placeholder,src){if(!src){return;}
var I=(navigator.appName=="Microsoft Internet Explorer")&&((navigator.userAgent.toLowerCase().indexOf("Mac")!=-1)||(navigator.appVersion.toLowerCase().indexOf("Mac")!=-1));var A=(navigator.userAgent.toLowerCase().indexOf("safari")!=-1);if(I||A){document.write("<"+"link"+" rel='stylesheet' type='text/css' href='"+src+"'>");}else{var cssLinkElement=document.createElement("link");cssLinkElement.rel="stylesheet";cssLinkElement.type="text/css";cssLinkElement.href=src;document.getElementById(placeholder).appendChild(cssLinkElement);}}
function CCM_PreventCollapse(item){if(item.Parent==item.ParentRadPanelbar){document.location.href=item.NavigateUrl
return false;}}
function CCM_PreventExpand(item){if(item.Parent==item.ParentRadPanelbar){document.location.href=item.NavigateUrl
return false;}}
function CCM_getObj(name){if(document.getElementById){return document.getElementById(name);}else if(document.all){return document.all[name];}else if(document.layers&&document.layers[name]!=null){return CCM_getObjNN4(document,name);}else{return false;}}
function CCM_getObjStyle(name){if(document.getElementById){return document.getElementById(name).style;}else if(document.all){return document.all[name].style;}else if(document.layers){return CCM_getObjNN4(document,name);}}
function CCM_getObjNN4(obj,name){var x=obj.layers;var foundLayer;for(var i=0;i<x.length;i++){if(x[i].id==name){foundLayer=x[i];}else if(x[i].layers.length){var tmp=CCM_getObjNN4(x[i],name);}
if(tmp){foundLayer=tmp;}}
if(foundLayer){return foundLayer;}else{return false;}}
var isIE=(navigator.appVersion.indexOf("MSIE")!=-1)?true:false;var isWin=(navigator.appVersion.toLowerCase().indexOf("win")!=-1)?true:false;var isOpera=(navigator.userAgent.indexOf("Opera")!=-1)?true:false;function CCM_ControlVersion()
{var version;var axo;var e;try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");version=axo.GetVariable("$version");}catch(e){}
if(!version)
{try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");version="WIN 6,0,21,0";axo.AllowScriptAccess="always";version=axo.GetVariable("$version");}catch(e){}}
if(!version)
{try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");version=axo.GetVariable("$version");}catch(e){}}
if(!version)
{try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");version="WIN 3,0,18,0";}catch(e){}}
if(!version)
{try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");version="WIN 2,0,0,11";}catch(e){version=-1;}}
return version;}
function CCM_GetSwfVer(){var flashVer=-1;if(navigator.plugins!=null&&navigator.plugins.length>0){if(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]){var swVer2=navigator.plugins["Shockwave Flash 2.0"]?" 2.0":"";var flashDescription=navigator.plugins["Shockwave Flash"+swVer2].description;var descArray=flashDescription.split(" ");var tempArrayMajor=descArray[2].split(".");var versionMajor=tempArrayMajor[0];var versionMinor=tempArrayMajor[1];if(descArray[3]!=""){tempArrayMinor=descArray[3].split("r");}else{tempArrayMinor=descArray[4].split("r");}
var versionRevision=tempArrayMinor[1]>0?tempArrayMinor[1]:0;var flashVer=versionMajor+"."+versionMinor+"."+versionRevision;}}
else if(navigator.userAgent.toLowerCase().indexOf("webtv/2.6")!=-1)flashVer=4;else if(navigator.userAgent.toLowerCase().indexOf("webtv/2.5")!=-1)flashVer=3;else if(navigator.userAgent.toLowerCase().indexOf("webtv")!=-1)flashVer=2;else if(isIE&&isWin&&!isOpera){flashVer=CCM_ControlVersion();}
return flashVer;}
function CCM_DetectFlashVer(reqMajorVer,reqMinorVer,reqRevision)
{versionStr=CCM_GetSwfVer();if(versionStr==-1){return false;}else if(versionStr!=0){if(isIE&&isWin&&!isOpera){tempArray=versionStr.split(" ");tempString=tempArray[1];versionArray=tempString.split(",");}else{versionArray=versionStr.split(".");}
var versionMajor=versionArray[0];var versionMinor=versionArray[1];var versionRevision=versionArray[2];if(versionMajor>parseFloat(reqMajorVer)){return true;}else if(versionMajor==parseFloat(reqMajorVer)){if(versionMinor>parseFloat(reqMinorVer))
return true;else if(versionMinor==parseFloat(reqMinorVer)){if(versionRevision>=parseFloat(reqRevision))
return true;}}
return false;}}
function CCM_AddExtension(src,ext)
{if(src.indexOf('?')!=-1)
return src.replace(/\?/,ext+'?');else
return src+ext;}
function CCM_Generateobj(objAttrs,params,embedAttrs)
{var str='';if(isIE&&isWin&&!isOpera)
{str+='<object ';for(var i in objAttrs)
str+=i+'="'+objAttrs[i]+'" ';for(var i in params)
str+='><param name="'+i+'" value="'+params[i]+'" /> ';str+='></object>';}else{str+='<embed ';for(var i in embedAttrs)
str+=i+'="'+embedAttrs[i]+'" ';str+='> </embed>';}
document.write(str);}
function CCM_RunContent(){var ret=CCM_GetArgs
(arguments,".swf","movie","clsid:d27cdb6e-ae6d-11cf-96b8-444553540000","application/x-shockwave-flash");CCM_Generateobj(ret.objAttrs,ret.params,ret.embedAttrs);}
function CCM_GetArgs(args,ext,srcParamName,classid,mimeType){var ret=new Object();ret.embedAttrs=new Object();ret.params=new Object();ret.objAttrs=new Object();for(var i=0;i<args.length;i=i+2){var currArg=args[i].toLowerCase();switch(currArg){case"classid":break;case"pluginspage":ret.embedAttrs[args[i]]=args[i+1];break;case"src":case"movie":args[i+1]=CCM_AddExtension(args[i+1],ext);ret.embedAttrs["src"]=args[i+1];ret.params[srcParamName]=args[i+1];break;case"onafterupdate":case"onbeforeupdate":case"onblur":case"oncellchange":case"onclick":case"ondblClick":case"ondrag":case"ondragend":case"ondragenter":case"ondragleave":case"ondragover":case"ondrop":case"onfinish":case"onfocus":case"onhelp":case"onmousedown":case"onmouseup":case"onmouseover":case"onmousemove":case"onmouseout":case"onkeypress":case"onkeydown":case"onkeyup":case"onload":case"onlosecapture":case"onpropertychange":case"onreadystatechange":case"onrowsdelete":case"onrowenter":case"onrowexit":case"onrowsinserted":case"onstart":case"onscroll":case"onbeforeeditfocus":case"onactivate":case"onbeforedeactivate":case"ondeactivate":case"type":case"codebase":case"id":ret.objAttrs[args[i]]=args[i+1];break;case"width":case"height":case"align":case"vspace":case"hspace":case"class":case"title":case"accesskey":case"name":case"tabindex":ret.embedAttrs[args[i]]=ret.objAttrs[args[i]]=args[i+1];break;default:ret.embedAttrs[args[i]]=ret.params[args[i]]=args[i+1];}}
ret.objAttrs["classid"]=classid;if(mimeType)ret.embedAttrs["type"]=mimeType;return ret;}
var ATTRIBUTES=new Array();var LABELS=new Array();var PRICE=new Array();var DEFAULTPRICE=new Array();var ADDTOCARTBTN=new Array();var ATTRFLDS=new Array();var ATTRLBLS=new Array();var QTYFLDS=new Array();var SETTINGS=new Array();function loadAttribute1(productid){var ddlAttribute1=$(ATTRFLDS[productid].attribute1);var ddlAttribute2=$(ATTRFLDS[productid].attribute2);var ddlAttribute3=$(ATTRFLDS[productid].attribute3);var ddlAttribute4=$(ATTRFLDS[productid].attribute4);var lblAttribute1=ATTRLBLS[productid].attribute1;var lblAttribute2=ATTRLBLS[productid].attribute2;if(ddlAttribute1){ddlAttribute1.options.length=0;ddlAttribute1.options[0]=new Option("","");if(ddlAttribute2){ddlAttribute2.options.length=0;ddlAttribute2.options[0]=new Option("","");}
if(ddlAttribute3){ddlAttribute3.options.length=0;ddlAttribute3.options[0]=new Option("","");}
if(ddlAttribute4){ddlAttribute4.options.length=0;ddlAttribute4.options[0]=new Option("","");}
if(ATTRIBUTES[productid].length>0){var moreThan1Attribute=false;var optionIndexStart=0;if(!SETTINGS[productid].oneandone){ddlAttribute1.options[0].text=replaceSubstring(SETTINGS[productid].select,"<replacementlabel>",lblAttribute1);optionIndexStart++;}else{var label=Builder.node('div');label.setStyle({textAlign:"left",overflow:"hidden",fontSize:"14px",padding:"0 0 20px 0"});label=$(label);label.update(ATTRIBUTES[productid][0].originalvalue);ddlAttribute1.insert({before:label});$("UI_ProductAttributes"+productid).setStyle({height:"21px",width:"210px",overflow:"hidden",border:"solid 1px #DCD1C3",padding:0,margin:"0 auto"});}
for(var a=0;a<=ATTRIBUTES[productid].length-1;a++){ddlAttribute1.options[(a+optionIndexStart)]=new Option(ATTRIBUTES[productid][a].text,ATTRIBUTES[productid][a].value);if(!moreThan1Attribute&&ATTRIBUTES[productid][a].attribs.length>0){moreThan1Attribute=true;}}
if(moreThan1Attribute){if(ddlAttribute2&&lblAttribute1){ddlAttribute2.options[0].text=replaceSubstring(replaceSubstring(replaceSubstring(SETTINGS[productid].selectprevious,"<replacementpreviouslabel>",lblAttribute1),"<replacementlabel>",lblAttribute2),"<replacementlabel>",lblAttribute2);}
if(ddlAttribute3&&lblAttribute1){ddlAttribute3.options[0].text=replaceSubstring(replaceSubstring(SETTINGS[productid].selectprevious,"<replacementpreviouslabel>",lblAttribute1),"<replacementlabel>",lblAttribute2);}
if(ddlAttribute4&&lblAttribute1){ddlAttribute4.options[0].text=replaceSubstring(replaceSubstring(SETTINGS[productid].selectprevious,"<replacementpreviouslabel>",lblAttribute1),"<replacementlabel>",lblAttribute2);}}else{if(ddlAttribute2){ddlAttribute2.options[0].text="";}
if(ddlAttribute3){ddlAttribute3.options[0].text="";}
if(ddlAttribute4){ddlAttribute4.options[0].text="";}}}}}
function loadAttribute2(productid){var ddlAttribute1=$(ATTRFLDS[productid].attribute1);var ddlAttribute2=$(ATTRFLDS[productid].attribute2);var ddlAttribute3=$(ATTRFLDS[productid].attribute3);var ddlAttribute4=$(ATTRFLDS[productid].attribute4);var lblAttribute1=ATTRLBLS[productid].attribute1;var lblAttribute2=ATTRLBLS[productid].attribute2;var lblAttribute3=ATTRLBLS[productid].attribute3;var attrib1val=ddlAttribute1.options[ddlAttribute1.selectedIndex].value;if(ddlAttribute2&&lblAttribute1){ddlAttribute2.options.length=0;ddlAttribute2.options[0]=new Option(replaceSubstring(replaceSubstring(SETTINGS[productid].selectprevious,"<replacementpreviouslabel>",lblAttribute1),"<replacementlabel>",lblAttribute2),"");if(ddlAttribute3&&lblAttribute1){ddlAttribute3.options.length=0;ddlAttribute3.options[0]=new Option(replaceSubstring(replaceSubstring(SETTINGS[productid].selectprevious,"<replacementpreviouslabel>",lblAttribute1),"<replacementlabel>",lblAttribute2),"");}
if(ddlAttribute4&&lblAttribute1){ddlAttribute4.options.length=0;ddlAttribute4.options[0]=new Option(replaceSubstring(replaceSubstring(SETTINGS[productid].selectprevious,"<replacementpreviouslabel>",lblAttribute1),"<replacementlabel>",lblAttribute2),"");}
for(var a=0;a<=ATTRIBUTES[productid].length-1;a++){if(ATTRIBUTES[productid][a].value==attrib1val){if(ATTRIBUTES[productid][a].attribs.length>0){var moreThan2Attribute=false;ddlAttribute2.options[0].text=replaceSubstring(SETTINGS[productid].select,"<replacementlabel>",lblAttribute2);for(var b=0;b<=ATTRIBUTES[productid][a].attribs.length-1;b++){ddlAttribute2.options[(b+1)]=new Option(ATTRIBUTES[productid][a].attribs[b].text,ATTRIBUTES[productid][a].attribs[b].value);if(!moreThan2Attribute&&ATTRIBUTES[productid][a].attribs[b].attribs.length>0){moreThan2Attribute=true;}}
if(moreThan2Attribute){if(ddlAttribute3&&lblAttribute2){ddlAttribute3.options[0].text=replaceSubstring(replaceSubstring(SETTINGS[productid].selectprevious,"<replacementpreviouslabel>",lblAttribute2),"<replacementlabel>",lblAttribute3);}
if(ddlAttribute4&&lblAttribute2){ddlAttribute4.options[0].text=replaceSubstring(replaceSubstring(SETTINGS[productid].selectprevious,"<replacementpreviouslabel>",lblAttribute2),"<replacementlabel>",lblAttribute3);}}else{if(ddlAttribute3){ddlAttribute3.options[0].text="";}
if(ddlAttribute4){ddlAttribute4.options[0].text="";}}}}}}}
function loadAttribute3(productid){var ddlAttribute1=$(ATTRFLDS[productid].attribute1);var ddlAttribute2=$(ATTRFLDS[productid].attribute2);var ddlAttribute3=$(ATTRFLDS[productid].attribute3);var ddlAttribute4=$(ATTRFLDS[productid].attribute4);var lblAttribute2=ATTRLBLS[productid].attribute2;var lblAttribute3=ATTRLBLS[productid].attribute3;var lblAttribute4=ATTRLBLS[productid].attribute4;if(ddlAttribute1&&ddlAttribute2&&lblAttribute2&&ddlAttribute3){var attrib1val=ddlAttribute1.options[ddlAttribute1.selectedIndex].value;var attrib2val=ddlAttribute2.options[ddlAttribute2.selectedIndex].value;ddlAttribute3.options.length=0;ddlAttribute3.options[0]=new Option(replaceSubstring(replaceSubstring(SETTINGS[productid].selectprevious,"<replacementpreviouslabel>",lblAttribute2),"<replacementlabel>",lblAttribute3),"");if(ddlAttribute4&&lblAttribute2){ddlAttribute4.options.length=0;ddlAttribute4.options[0]=new Option(replaceSubstring(replaceSubstring(SETTINGS[productid].selectprevious,"<replacementpreviouslabel>",lblAttribute2),"<replacementlabel>",lblAttribute3),"");}
for(var a=0;a<=ATTRIBUTES[productid].length-1;a++){if(ATTRIBUTES[productid][a].value==attrib1val){if(ATTRIBUTES[productid][a].attribs.length>0){for(var b=0;b<=ATTRIBUTES[productid][a].attribs.length-1;b++){if(ATTRIBUTES[productid][a].attribs[b].value==attrib2val){if(ATTRIBUTES[productid][a].attribs[b].attribs.length>0){var moreThan3Attribute=false;ddlAttribute3.options[0].text=replaceSubstring(SETTINGS[productid].select,"<replacementlabel>",lblAttribute3);for(var c=0;c<=ATTRIBUTES[productid][a].attribs[b].attribs.length-1;c++){ddlAttribute3.options[(c+1)]=new Option(ATTRIBUTES[productid][a].attribs[b].attribs[c].text,ATTRIBUTES[productid][a].attribs[b].attribs[c].value);if(!moreThan3Attribute&&ATTRIBUTES[productid][a].attribs[b].attribs[c].attribs.length>0){moreThan3Attribute=true;}}
if(moreThan3Attribute){if(ddlAttribute4&&lblAttribute3){ddlAttribute4.options[0].text=replaceSubstring(replaceSubstring(SETTINGS[productid].selectprevious,"<replacementpreviouslabel>",lblAttribute3),"<replacementlabel>",lblAttribute4);}}else{if(ddlAttribute4){ddlAttribute4.options[0].text="";}}}}}}}}}}
function loadAttribute4(productid){var ddlAttribute1=$(ATTRFLDS[productid].attribute1);var ddlAttribute2=$(ATTRFLDS[productid].attribute2);var ddlAttribute3=$(ATTRFLDS[productid].attribute3);var ddlAttribute4=$(ATTRFLDS[productid].attribute4);var lblAttribute3=ATTRLBLS[productid].attribute3;var lblAttribute4=ATTRLBLS[productid].attribute4;var attrib1val=ddlAttribute1.options[ddlAttribute1.selectedIndex].value;var attrib2val=ddlAttribute2.options[ddlAttribute2.selectedIndex].value;var attrib3val=ddlAttribute3.options[ddlAttribute3.selectedIndex].value;if(ddlAttribute4){ddlAttribute4.options.length=0;ddlAttribute4.options[0]=new Option(replaceSubstring(replaceSubstring(SETTINGS[productid].selectprevious,"<replacementpreviouslabel>",lblAttribute3),"<replacementlabel>",lblAttribute4),"");for(var a=0;a<=ATTRIBUTES[productid].length-1;a++){if(ATTRIBUTES[productid][a].value==attrib1val){if(ATTRIBUTES[productid][a].attribs.length>0){for(var b=0;b<=ATTRIBUTES[productid][a].attribs.length-1;b++){if(ATTRIBUTES[productid][a].attribs[b].value==attrib2val){if(ATTRIBUTES[productid][a].attribs[b].attribs.length>0){for(var c=0;c<=ATTRIBUTES[productid][a].attribs[b].attribs.length-1;c++){if(ATTRIBUTES[productid][a].attribs[b].attribs[c].value==attrib3val){if(ATTRIBUTES[productid][a].attribs[b].attribs[c].attribs.length>0){ddlAttribute4.options[0].text=replaceSubstring(SETTINGS[productid].select,"<replacementlabel>",lblAttribute4);for(var d=0;d<=ATTRIBUTES[productid][a].attribs[b].attribs[c].attribs.length-1;d++){ddlAttribute4.options[(d+1)]=new Option(ATTRIBUTES[productid][a].attribs[b].attribs[c].attribs[d].text,ATTRIBUTES[productid][a].attribs[b].attribs[c].attribs[d].value);}}}}}}}}}}}}
function loadPrice(what,productid,a1index,a2index,a3index,a4index){var newprice=null;var outofstock=false;try{if(a4index){newprice=ATTRIBUTES[productid][(a1index-1)].attribs[(a2index-1)].attribs[(a3index-1)].attribs[(a4index-1)].price;outofstock=ATTRIBUTES[productid][(a1index-1)].attribs[(a2index-1)].attribs[(a3index-1)].attribs[(a4index-1)].soldout;}else if(a3index){newprice=ATTRIBUTES[productid][(a1index-1)].attribs[(a2index-1)].attribs[(a3index-1)].price;outofstock=ATTRIBUTES[productid][(a1index-1)].attribs[(a2index-1)].attribs[(a3index-1)].soldout;}else if(a2index){newprice=ATTRIBUTES[productid][(a1index-1)].attribs[(a2index-1)].price;outofstock=ATTRIBUTES[productid][(a1index-1)].attribs[(a2index-1)].soldout;}else if(a1index){newprice=ATTRIBUTES[productid][(a1index-1)].price;outofstock=ATTRIBUTES[productid][(a1index-1)].soldout;}}catch(x){}
if($(QTYFLDS[productid][0])&&$(QTYFLDS[productid][2])){if(outofstock){$(QTYFLDS[productid][0]).hide();$(QTYFLDS[productid][2]).show();}else{$(QTYFLDS[productid][2]).hide();$(QTYFLDS[productid][0]).show();}}
if(!newprice||newprice==""){newprice=DEFAULTPRICE[productid];$(QTYFLDS[productid][2]).hide();$(QTYFLDS[productid][0]).show();$(QTYFLDS[productid][1]).disable();$(QTYFLDS[productid][1]).value=0;}else{showHideQuantity(what,QTYFLDS[productid][0],QTYFLDS[productid][2],QTYFLDS[productid][1]);}
if($(PRICE[productid])){$(PRICE[productid]).innerHTML=newprice;}}
function showHideQuantity(what,quantityid,outofstockid,quantityfldid){if(what.selectedIndex>0){$(quantityfldid).enable();var val=what.options[what.selectedIndex].value;if(val==""){$(quantityid).hide();$(outofstockid).show();$(quantityfldid).value=0;}else{$(outofstockid).hide();$(quantityid).show();if(($(quantityfldid).value-0)==0){$(quantityfldid).value=1;}}}else{$(outofstockid).hide();$(quantityid).show();$(quantityfldid).disable();$(quantityfldid).value=0;}}
function checkQuantitiesAndAttributes(sender,args){args.IsValid=true;}
function checkQuantity(sender,args){args.IsValid=true;}
function checkAttribute1(sender,args){args.IsValid=true;}
function checkAttribute2(sender,args){args.IsValid=true;}
function checkAttribute3(sender,args){args.IsValid=true;}
function checkAttribute4(sender,args){args.IsValid=true;}
var SWATCHTHUMBSIZEWIDTH=30;var SWATCHTHUMBSIZEHEIGHT=30;var SWATCHSIZEWIDTH=411;var SWATCHSIZEHEIGHT=411;var WRITENAME=false;var SWATCHES=new Array();var ACTUALSWATCHES=new Array();var COLORNAMEID="ColorName";var SWATCHCONTAINERID="Swatches";var SELECTCOLOR="";var CURRENTSWATCH=-1;function writeSwatchName(productid,name){var spnColorName=$(COLORNAMEID+productid);if(WRITENAME&&spnColorName){spnColorName.innerHTML=name;}}
function emptySwatchName(productid){var spnColorName=$(COLORNAMEID+productid);if(WRITENAME&&spnColorName){spnColorName.innerHTML=SELECTCOLOR;}}
function loadSwatches(productid){try{if(typeof(onSwatchLoad)==='function'){onSwatchLoad(productid);}}catch(x){}
var spnColorName=$(COLORNAMEID+productid);if(!WRITENAME&&spnColorName){spnColorName.hide();}
for(i=0;i<=SWATCHES.length-1;i++){if(SWATCHES[i][0]!=""){ACTUALSWATCHES.push(SWATCHES[i]);var div=Builder.node('div',{className:"Swatch"});div=$(div);var a=Builder.node('a',{href:"javascript:void(0);",onclick:"popupSwatch("+productid+", "+i+", "+(SWATCHSIZEWIDTH+50)+", "+(SWATCHSIZEHEIGHT+100)+");",onmouseover:"writeSwatchName("+productid+", '"+SWATCHES[i][1]+"');",onmouseout:"emptySwatchName("+productid+");"});a=$(a);div.appendChild(a);var img=Builder.node('img',{src:SWATCHES[i][0],width:SWATCHTHUMBSIZEWIDTH,height:SWATCHTHUMBSIZEHEIGHT,alt:SWATCHES[i][1],border:"0"});img=$(img);a.appendChild(img);$(SWATCHCONTAINERID+productid).appendChild(div);var spnColorName=$(COLORNAMEID+productid);if(WRITENAME&&spnColorName){SELECTCOLOR=spnColorName.innerHTML;}}}}
function popupSwatch(productid,index,width,height){var newWindow=window.open("/popup_Swatch.aspx?productid="+productid+"&imageindex="+index,'Swatch_Popup','width='+width+',height='+height+',scrollbars=yes,menubar=no,toolbar=no,location=no,directories=no,resizable=yes,top=100,left=100')
self.name='swatchWindow'
newWindow.focus()
return false;}

/* /scripts/ScriptNew.js */

function popupgoToLink(aTag){newWindow=window.open(aTag.href,'CommerceCM_Popup','width=580,height=400,scrollbars=yes,menubar=no,toolbar=no,location=no,directories=no,resizable=yes,top=0,left=0')
self.name='mainWindow'
newWindow.focus()
return false;}
function isValidEmail(emailAddress){var emailReg="^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";var regex=new RegExp(emailReg);return regex.test(emailAddress);}
function popwindow_small(url)
{var newwindow;newwindow=window.open(url,'name','height=350,width=430, left=300, top=40');if(window.focus){newwindow.focus()}}
function popwindow(url,height,width,returnvalue)
{try{if(!height)height=550;if(!width)width=430;var newwindow;var options='height='+height+',width='+width+', left=300, top=40'
newwindow=window.open(url,null,options);if(window.focus){newwindow.focus()}
return returnvalue}
catch(e){return true;}}
function popwindowscroll(url,height,width,returnvalue)
{try{if(!height)height=550;if(!width)width=430;if(height==600&&width==436){height=620;width=470;}
newwindow=window.open(url,'name','height='+height+',width='+width+', left=300, top=40, scrollbars=yes');if(window.focus){newwindow.focus()}
return returnvalue}
catch(e){return true;}}

/* drop down mask */

/*
function DropDownMask(_sourceId,_customFunction,_customObject){this.SourceClientID=_sourceId;this.CustomFunction=_customFunction;this.CustomObject=_customObject;}
DropDownMask.prototype.toggleList=function(event){var elem=Event.element(event);$(this.SourceClientID+"_drop").toggle();}
DropDownMask.prototype.selectListItem=function(event){var elem=Event.element(event);var text=elem.ancestors()[0].innerHTML;var link=elem.ancestors()[3].previous().firstDescendant();link.update(text);elem.ancestors()[2].hide();var oldVal=$(this.SourceClientID).getValue();var newVal=elem.select(".value")[0].innerHTML;if(oldVal!=newVal){$(this.SourceClientID).setValue(newVal);if(typeof this.CustomFunction==='function'){this.CustomFunction(oldVal,newVal,this);}}}
DropDownMask.prototype.createDropDown=function(){var source=$(this.SourceClientID);var options=source.options;$(this.SourceClientID+"_link").observe('click',this.toggleList.bind(this));var ul=$(this.SourceClientID+"_drop");for(i=0; i<options.length; i++){var li=new Element('li');var a2=new Element('a',{"href": "#"});a2.update('<span>'+options[i].text+'<span class="value">'+options[i].value+'</span></span>');a2.observe('click',this.selectListItem.bind(this));li.insert({bottom: a2});ul.insert({bottom: li});}}
function doNothing(){}
*/


function DropDownMask(_sourceId, _customFunction, _customObject){
	this.SourceClientID = _sourceId;
	this.CustomFunction = _customFunction;
	this.CustomObject = _customObject;
}

DropDownMask.prototype.toggleList = function(event){
	var elem = Event.element(event);
	$(this.SourceClientID + "_drop").toggle();
}

DropDownMask.prototype.selectListItem = function(event){
	var elem = Event.element(event);
	var text = elem.ancestors()[0].innerHTML;
	var link = elem.ancestors()[3].previous().firstDescendant();
	link.update(text);
	elem.ancestors()[2].hide();
	var oldVal = $(this.SourceClientID).getValue();
	var newVal = elem.select(".value")[0].innerHTML;
	if(oldVal != newVal){
		$(this.SourceClientID).setValue(newVal);
		if(typeof this.CustomFunction === 'function'){
			this.CustomFunction(oldVal, newVal, this);
		}
	}
}

DropDownMask.prototype.createDropDown = function (){
	var source = $(this.SourceClientID);
    var options = source.options;
    $(this.SourceClientID + "_link").observe('click', this.toggleList.bind(this));
    var ul = $(this.SourceClientID + "_drop");
    for(i=0; i<options.length; i++){
		var li = new Element('li');
		var a2 = new Element('a', {"href": "#"});
		a2.update('<span>' + options[i].text + '<span class="value">' + options[i].value + '</span></span>');
		a2.observe('click', this.selectListItem.bind(this));
		li.insert({bottom: a2});
		ul.insert({bottom: li});
    }
}

function doNothing(){}

