if(typeof(WS)=="undefined"){var WS={}}var colors=[];for(key in vars.colors){var temp={code:key,name:vars.colors[key]};colors.push(temp)}WS.picker={container:null,bckgColorsContainer:null,vinilColorsContainer:null,vinilSelector:null,layersCount:0,selectedLayer:"0",flashObj:null,reverseState:false,colorSelect1:null,colorSelect2:null,orientationSelect:null,init:function(a){this.container=$("#flashCntainer")[0];this.bckgColorsContainer=$("#bckgColorsContainer")[0];this.vinilColorsContainer=$("#vinilColorsContainer")[0];this.vinilSelector=$("#vinilSelector")[0];this.colorSelect1=$("select[name=id[7]]")[0];if(this.colorSelect1){this.colorSelect1.parentNode.parentNode.style.display="none"}this.colorSelect2=$("select[name=id[9]]")[0];if(this.colorSelect2){this.colorSelect2.parentNode.parentNode.style.display="none"}this.orientationSelect=$("select[name=id[8]]")[0];if(this.orientationSelect){this.orientationSelect.parentNode.parentNode.style.display="none"}this.flashObj=document.test;this.layersCount=layersCount;this.initBckgColors();this.initVinilColors();this.initVinilSelector()},initBckgColors:function(){var b=this.config.colors;var d=parseInt(b.length/2);for(i=0;i<b.length;i++){var a=(i==d)?" clearLeft":"";var c=document.createElement("div");c.className=b[i].code+" bckgColor"+a;c.style.backgroundColor="#"+b[i].code;c.title=b[i].name;c.onclick=function(){WS.picker.flashObj.setVar("bckgColor",this.className.split(" ")[0]);$("#backColorInput").val(this.className.split(" ")[0])};this.bckgColorsContainer.appendChild(c);if(i+1==d){this.bckgColorsContainer.appendChild(document.createElement("br"))}}},initVinilColors:function(){var b=this.config.colors;var d=parseInt(b.length/2);for(i=0;i<b.length;i++){var a=(i==d)?" clearLeft":"";var c=document.createElement("div");c.className=b[i].code+" bckgColor"+a;c.style.backgroundColor="#"+b[i].code;c.title=b[i].name;c.onclick=function(){WS.picker.selectedLayer=$("input[name=vinilSelector]:checked").val();var f=(WS.picker.selectedLayer=="0")?"color1":"color2";WS.picker.flashObj.setVar(f,this.className.split(" ")[0]);if(WS.picker.colorSelect1){WS.picker.setVinilColor(this.className.split(" ")[0])}var e=$("input[@name=vinilSelector]:checked").val();$("#vinilColorInput"+e).val(this.className.split(" ")[0])};this.vinilColorsContainer.appendChild(c);if(i+1==d){this.vinilColorsContainer.appendChild(document.createElement("br"))}}},initVinilSelector:function(){for(i=0;i<this.layersCount;i++){var a=(i==0)?"checked":"";try{radioObj=document.createElement('<input type="radio" value="'+i+'" name="vinilSelector" id="vinilSelector'+i+'" '+a+"/>")}catch(c){radioObj=document.createElement("input")}$(radioObj).attr("type","radio");$(radioObj).attr("name","vinilSelector");radioObj.id="vinilSelector"+i;radioObj.value=i;if(i==0){radioObj.checked=true}this.vinilSelector.appendChild(radioObj);var b=document.createElement("label");b.setAttribute("for","vinilSelector"+i);b.innerHTML="Oblik"+(i+1)+"&nbsp;&nbsp;&nbsp;&nbsp;";this.vinilSelector.appendChild(b)}this.appendRotationLinks()},appendRotationLinks:function(){var b=document.createElement("div");b.id="rotationLinksContainer";b.innerHTML="Odaberi orijentaciju:<br/><br/>";this.vinilColorsContainer.appendChild(b);var c=document.createElement("a");c.href="#";c.id="normalLayerLink";c.className="selected";c.innerHTML="normalna";c.onclick=function(d){if(d){d.preventDefault()}if(WS.picker.reverseState){WS.picker.reverseState=false;WS.picker.flashObj.reverseLayers();WS.picker.handleRotationLinks(this)}return false};b.appendChild(c);var a=document.createElement("a");a.href="#";a.id="reverseLayerLink";a.innerHTML="zrcalna";a.onclick=function(d){if(d){d.preventDefault()}if(!WS.picker.reverseState){WS.picker.reverseState=true;WS.picker.flashObj.reverseLayers();WS.picker.handleRotationLinks(this)}return false};b.appendChild(a)},setVinilColor:function(a){if(WS.picker.selectedLayer==0){colorSelect=this.colorSelect1}else{colorSelect=this.colorSelect2}options=colorSelect.options;for(i=0;i<options.length;i++){if(options[i].innerHTML.indexOf(a)!=-1){colorSelect.selectedIndex=i;break}}},handleRotationLinks:function(a){if(a.id=="normalLayerLink"){$("#normalLayerLink")[0].className="selected";$("#reverseLayerLink")[0].className="";$("#stickerOrientation").val("1");if(this.orientationSelect){this.orientationSelect.value=231}}else{$("#normalLayerLink")[0].className="";$("#reverseLayerLink")[0].className="selected";$("#stickerOrientation").val("0");if(this.orientationSelect){this.orientationSelect.value=232}}},config:{colors:colors}};
