function trim(b,a){return ltrim(rtrim(b,a),a)}function ltrim(b,a){a=a||"\\s";return b.replace(new RegExp("^["+a+"]+","g"),"")}function rtrim(b,a){a=a||"\\s";return b.replace(new RegExp("["+a+"]+$","g"),"")}function hide(b){var a=document.getElementById(b);if(a){a.style.display="none"}}function show(b){var a=document.getElementById(b);if(a&&a.style.display=="none"){a.style.display=""}}function expand(a){show(a)}function showHide(a){if(document.getElementById(a).style.display=="none"){document.getElementById(a).style.display=""}else{document.getElementById(a).style.display="none"}}function getElementValue(b){var a=document.getElementById(b);if(!a){return""}return a.value}function tooltip(f,b,c){var b=document.getElementById(b);if(b.style.visibility=="hidden"){var a;var d;if(document.all){a=event.clientX+document.documentElement.scrollLeft;d=event.clientY+document.documentElement.scrollTop}else{a=f.pageX;d=f.pageY}a=a+15;d=d+15;b.style.left=a+"px";b.style.top=d+"px";if(c==undefined){var c=250}b.style.width=c+"px";b.style.visibility="visible"}else{b.style.visibility="hidden"}}function swapProductImage(a){if(document.getElementById("productImg")){document.getElementById("productImg").setAttribute("src",a)}}function swapImage(c,g,f){var b="productImg_"+c;changeImage(b,f);if(c==g){return}var a=document.getElementsByTagName("div");for(var d=0;d<a.length;d++){var e=a[d].id+"";if(e.indexOf(g)>0){a[d].style.display="inline"}if(e.indexOf(c)>0){a[d].style.display="none"}}}function swapTab(a){switch(a){case"popupOverview":document.getElementById("popupOverview").style.display="block";document.getElementById("popupSpecifications").style.display="none";document.getElementById("popupWhatsInBox").style.display="none";break;case"popupSpecifications":document.getElementById("popupOverview").style.display="none";document.getElementById("popupSpecifications").style.display="block";document.getElementById("popupWhatsInBox").style.display="none";break;case"popupWhatsInBox":document.getElementById("popupOverview").style.display="none";document.getElementById("popupSpecifications").style.display="none";document.getElementById("popupWhatsInBox").style.display="block";break;default:document.getElementById("popupOverview").style.display="block";document.getElementById("popupSpecifications").style.display="none";document.getElementById("popupWhatsInBox").style.display="none"}}function popUp(URL,thewidth,theheight,theleft,thetop,thetoolbar,thescrollbars,thelocationbar,thestatus,themenubar,theresizable,id){if(URL==undefined){URL="http://www.carphonewarehouse.com"}if(id==undefined){id="cpw"}if(thetoolbar==undefined){thetoolbar=0}if(thescrollbars==undefined){thescrollbars=1}if(thelocationbar==undefined){thelocationbar=0}if(thestatus==undefined){thestatus=0}if(themenubar==undefined){themenubar=0}if(theresizable==undefined){theresizable=0}if(thewidth==undefined){thewidth=800}if(theheight==undefined){theheight=400}if(theleft==undefined){theleft=200}if(thetop==undefined){thetop=100}eval("var cpwPopup = window.open('"+URL+"','"+id+"','toolbar="+thetoolbar+",scrollbars="+thescrollbars+",location="+thelocationbar+",status="+thestatus+",menubar="+themenubar+",resizable="+theresizable+",width="+thewidth+",height="+theheight+",left = "+theleft+",top = "+thetop+"');");if(cpwPopup){return false}else{return true}}function changeImage(a,b){document.getElementById(a).src=b}function removeSpacesInFormField(d){var c=document.getElementById(d);if(!c){return}var b=c.value;var a="";b=""+b;splitstring=b.split(" ");for(i=0;i<splitstring.length;i++){a+=splitstring[i]}c.value=a}function newShowHide(a,b){if(document.getElementById(a)){if(document.getElementById(a).style.display=="none"){document.getElementById(a).style.display="block";if(b.src){b.src="http://media.phonehouse.com/cpw-sales/static/images/common/buttons/btn_hide.gif"}}else{document.getElementById(a).style.display="none";if(b.src){b.src="http://media.phonehouse.com/cpw-sales/static/images/common/buttons/btn_show.gif"}}}};