function MM_preloadImages(){var d=document;if(d.images){if(!d.MM_p)d.MM_p=new Array();var i,j=d.MM_p.length,a=MM_preloadImages.arguments;for(i=0;i<a.length;i++)
if(a[i].indexOf("#")!=0){d.MM_p[j]=new Image;d.MM_p[j++].src=a[i];}}}
function MM_swapImgRestore(){var i,x,a=document.MM_sr;for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)x.src=x.oSrc;}
function MM_findObj(n,d){var p,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}
if(!(x=d[n])&&d.all)x=d.all[n];for(i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers[i].document);if(!x&&d.getElementById)x=d.getElementById(n);return x;}
function MM_swapImage(){var i,j=0,x,a=MM_swapImage.arguments;document.MM_sr=new Array;for(i=0;i<(a.length-2);i+=3)
if((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x;if(!x.oSrc)x.oSrc=x.src;x.src=a[i+2];}}
function postValidate(refForm){strError="";var io=document.getElementById('internetonly').checked;if(refForm.vendor_name.value.length==0){strError+=" - Please enter the Vendor Name\n";}
if((refForm.vendor_postcode1.value.length==0)&&(!io)){strError+=" - Please enter the Vendor Postcode\n";}
if(refForm.title.value.length==0){strError+=" - Please enter the Promotion Title\n";}
if((refForm.logo.value.length>1)&&(!check_extension(refForm.logo.value))){strError+=" - The filetype for your logo is invalid. Please use images with JPEG or JPG extensions\n";}
if(refForm.fullinfo.value.length==0){strError+=" - Please enter a description\n";}
if(!refForm.terms.checked){strError+=" - You must agree to the terms and conditions\n";}
if((refForm.vendor_postcode1.value.length>0)&&(!io)){var ok=false;for(i=0;i<arrValidPC.length;i++){if(refForm.vendor_postcode1.value.toLowerCase()==arrValidPC[i].toLowerCase()){var ok=true;break;}}
if(!ok){strError+=" - Invalid postcode entered\n";}}
if(strError.length>0){alert(strError);return false;}else{return true;}}
function postValidate_1(refForm){strError="";if(document.forms[0].title.value.length==0){strError+=" - Please enter the Promotion Title\n";}
if((document.forms[0].logo.value.length>1)&&(!check_extension(refForm.logo.value))){strError+=" - The filetype for your logo is invalid. Please use images with JPEG or JPG extensions\n";}
if(document.forms[0].fullinfo.value.length==0){strError+=" - Please enter a Description\n";}
if(strError.length>0){alert(strError);return false;}else{return true;}}
function postValidate_2(refForm){strError="";if(refForm.title.value.length==0){strError+=" - Please enter the Product Title\n";}
if((refForm.logo.value.length>1)&&(!check_extension(refForm.logo.value))){strError+=" - The filetype for your image is invalid. Please use images with JPEG or JPG extensions\n";}
if(strError.length>0){alert(strError);return false;}else{return true;}}
function postValidate_3(refForm){strError="";var io=document.getElementById('internetonly').checked;if((refForm.vendor_postcode1.value.length==0)&&(!io)){strError+=" - Please enter a postcode or tick the Internet only box\n";}
if(!refForm.terms.checked){strError+=" - You must agree to the terms and conditions\n";}
if((refForm.vendor_postcode1.value.length>0)&&(!io)){var ok=false;for(i=0;i<arrValidPC.length;i++){if(refForm.vendor_postcode1.value.toLowerCase()==arrValidPC[i].toLowerCase()){var ok=true;break;}}
if(!ok){strError+=" - Invalid postcode entered\n";}}
if(strError.length>0){alert(strError);return false;}else{return true;}}
function check_extension(strWhat){var arrAllowed=["jpeg","jpg"];for(i=0;i<=arrAllowed.length;i++){if(strWhat.toLowerCase().indexOf(arrAllowed[i])>0){return true;}}
return false;}
function questionValidate(refForm){strError="";if(refForm.txt.value.length==0){strError+=" - Please enter a message\n";}
if(strError.length>0){alert(strError);return false;}else{return true;}}
function checkContinous(ref){if(ref){document.forms[0].end_day.disabled=true;document.forms[0].end_month.disabled=true;document.forms[0].end_year.disabled=true;}else{document.forms[0].end_day.disabled=false;document.forms[0].end_month.disabled=false;document.forms[0].end_year.disabled=false;}}
function checkPostCode(toCheck){if(toCheck.length==0){return true;}
toCheck=toCheck.toUpperCase();for(i=0;i<arrValidPC.length;i++){if(toCheck.indexOf(arrValidPC[i])>-1){return true;break;}}
alert("Invalid Postcode");return false;}
function postPromotionDisable(bSetting){fields=["vendor_address1","vendor_address2","vendor_town","vendor_postcode","vendor_postcode2"];for(var i=0;i<fields.length;i++){ref=document.getElementById(fields[i]);if(bSetting){ref.disabled=true;ref.value="";ref.style.backgroundColor='#cccccc';}else{ref.disabled=false;ref.style.backgroundColor='transparent';}}}
function checkSearchForm(){if(checkPostCode(document.getElementById('search').postcode.value)){document.getElementById('search').submit();}
return false;}
function checkSigninform(){document.getElementById('signin').submit();}
function checkforenter(functiontocall){document.onkeydown=function(e){var code;if(!e)var e=window.event;if(e.keyCode)code=e.keyCode;else if(e.which)code=e.which;if(code==13){eval(functiontocall+"()");}}}
function LimitText(f,c,w){if(f.value.length>c){f.value=f.value.substring(0,c);}
w.value=c-f.value.length;}
function navigateCalendar(month,year){var url="index_calendar_get.php?month="+month+"&year="+year;if(window.XMLHttpRequest){req=new XMLHttpRequest();}else if(window.ActiveXObject){req=new ActiveXObject("Microsoft.XMLHTTP");}
req.open("GET",url,true);req.onreadystatechange=callbackCalendar;req.send(null);}
function callbackCalendar(){if(req.readyState==4){if(req.status==200){response=req.responseText;document.getElementById("calendar").innerHTML=response;}else{alert("There was a problem retrieving the data:\n"+req.statusText);}}}
function productPopup(iProductId){var refWindow=window.open("promotion_detail_product_image.php?id="+iProductId,"Product","left=30,top=30,resizable=1,scrollbars=no,status=no,width=1,height=1");}
function productPopupresizeWinTo(idOfDiv){var oH=document.getElementById(idOfDiv);var oW=oH.clip?oH.clip.width:oH.offsetWidth;var oH=oH.clip?oH.clip.height:oH.offsetHeight;if(!oH){return false;}
var x=window;x.resizeTo(oW+200,oH+200);var myW=0,myH=0,d=x.document.documentElement,b=x.document.body;if(x.innerWidth){myW=x.innerWidth;myH=x.innerHeight;}
else if(d&&d.clientWidth){myW=d.clientWidth;myH=d.clientHeight;}
else if(b&&b.clientWidth){myW=b.clientWidth;myH=b.clientHeight;}
if(window.opera&&!document.childNodes){myW+=16;}
oW+=10;oH+=10;x.resizeTo(oW+((oW+200)-myW),oH+((oH+200)-myH));x.focus();}
function MM_showHideLayers(){var i,p,v,obj,args=MM_showHideLayers.arguments;for(i=0;i<(args.length-2);i+=3)
with(document)if(getElementById&&((obj=getElementById(args[i]))!=null)){v=args[i+2];if(obj.style){obj=obj.style;v=(v=='show')?'visible':(v=='hide')?'hidden':v;}obj.visibility=v;}}


/* /start/ script_essentials.js contents */
function byId(objId){return(document.getElementById(objId));}
function randomString(length){ var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split(''); if(!length){length = Math.floor(Math.random() * chars.length);} var str=''; for(var i=0;i<length;i++){ str += chars[Math.floor(Math.random() * chars.length)]; } return str; }

/* bvsearch /start/ */
if(typeof bvMode=="undefined") { var bvMode="global"; } if(typeof bpickArr=="undefined") { var bpickArr=new Array(); } if(typeof vpickArr=="undefined") { var vpickArr=new Array(); } if(typeof bvcommonreq=="undefined") { var bvcommonreq=""; } function bvsearchAttachEvents(){ $("#bQ").keyup(function(event){ var val=$("#bQ").val(); val=val.replace(/[^a-z0-9\_\-\'\"\& ]/i,""); $("#bQ").val(val); if(event.keyCode=='13') { event.preventDefault(); } var bck=bvMode; bvSearchx('#bresults',bpickArr,bvBuildRequest('1','0'),true); bvMode=bck; }); $("#vQ").keyup(function(event){ var val=$("#vQ").val(); val=val.replace(/[^a-z0-9\_\-\'\"\& ]/i,""); $("#vQ").val(val); if(event.keyCode=='13') { event.preventDefault(); } var bck=bvMode; bvSearchx('#vresults',vpickArr,bvBuildRequest('2','0'),true); bvMode=bck; }); } function resultsFrameCompact() { e=document.getElementById("bresults"); e.style.height=1+'px'; e.style.overflow='hidden'; f=document.getElementById("vresults"); f.style.height=1+'px'; f.style.overflow='hidden'; } function resultsFrameExpand() { e=document.getElementById("bresults"); e.style.height='255px'; e.style.overflow='auto'; f=document.getElementById("vresults"); f.style.height='255px'; f.style.overflow='auto'; } function bvStrEscape(str) { str=str.replace("&amp;","&","gi"); str=str.replace("&#39;","'","gi"); str=str.replace("&#039;","'","gi"); str=str.replace("&apos;","'","gi"); str=str.replace("&quot;","\"","gi"); str=str.replace("+","%2B","gi"); str=escape(str); return(str); } function inArray(val,arr) { var rtn=-1; if(typeof arr=="object"&&val.length>0) { var i=0; while(i<arr.length&&rtn<0) { if(val.toLowerCase()==arr[i].toLowerCase()) { rtn=i; } i++; } } return(rtn); } function bvSetOption(entry,pickArr) { var rtn=1,pos=0; entry=entry.replace(/\s*\([0-9]+\)\s*/,""); pos=inArray(entry,pickArr); if(pos<0) { pos=pickArr.length; pickArr[pos]=entry; } else { rtn=-1; pickArr[pos]=""; } return(rtn); } function bvBind(pickArr) { $(".bvResultEntryList").unbind(); $(".bvResultEntryList").click(function(){ var entry=$(this).text(); entry=entry.replace(/\s*\([0-9]+\)\s*/,""); if(bvSetOption(entry,pickArr)>0) { $(this).addClass("bv_clicked"); } else { $(this).removeClass("bv_clicked"); } return false; }); $(".bvResultEntryList").hover(function(){ $(this).addClass("bv_link_over"); },function(){ $(this).removeClass("bv_link_over"); }); } function bvHandleResult(text,pickArr) { var html='',base=''; var i=0; var arr=new Array(); if(text.length<1) { return("No results returned."); } arr=text.split("^"); for(i=0;i<arr.length;i++) { var entry=arr[i].replace(/\s*\([0-9]+\)\s*/i,""); if(inArray(entry,pickArr)<0) { html+='<div class="bvResultEntryList bv_link">'+arr[i]+'</div>'; } else { html+='<div class="bvResultEntryList bv_link bv_clicked">'+arr[i]+'</div>'; } } return(html); } function bvBuildRequest(qtype,locals) { var req; var i=0; bvMode="global"; req="qtype="+qtype; if(locals=='1') { bvMode="local"; if(bvcommonreq.length>0) { req+="&"+bvcommonreq; } for(i=0;i<bpickArr.length;i++) { if(bpickArr[i].length>0) { req+='&brand[]='+bvStrEscape(bpickArr[i]); } } for(i=0;i<vpickArr.length;i++) { if(vpickArr[i].length>0) { req+='&vendor[]='+bvStrEscape(vpickArr[i]); } } } if(qtype=='1'&&document.getElementById('bQ').value!="Type to search") { req+='&q='+bvStrEscape(document.getElementById('bQ').value); } else { if(qtype=='2'&&document.getElementById('vQ').value!="Type to search") { req+='&q='+bvStrEscape(document.getElementById('vQ').value); } } return req; } function bvClearForm(qtype) { if(qtype=='1'||qtype=='2') { var localReq=(bvMode=="local")?'1':'0'; if(qtype=='1') { bpickArr=new Array(); document.getElementById('bQ').value=""; bvSearchx('#bresults',bpickArr,bvBuildRequest('1',localReq),true); } else { vpickArr=new Array(); document.getElementById('vQ').value=""; bvSearchx('#vresults',vpickArr,bvBuildRequest('2',localReq),true); } } } function bvSendTopSearch(qtype) { var req=''; if(qtype=='1'||qtype=='2') { if(qtype=='1') { if(bvMode!="local") { for(i=0;i<bpickArr.length;i++) { if(bpickArr[i].length>0) { req+='&brand[]='+bvStrEscape(bpickArr[i]); } } } else { req=bvBuildRequest(-1,'1'); } } else { if(bvMode!="local") { for(i=0;i<vpickArr.length;i++) { if(vpickArr[i].length>0) { req+='&vendor[]='+bvStrEscape(vpickArr[i]); } } } else { req=bvBuildRequest(-1,'1'); } } req=req.replace(/^&/i,""); var dest='http://'+location.hostname+'/search.php?'+req; window.location=dest; } return false; } function bvSearchx(resultObjId,pickArr,qry,sync) { $.ajax({ url:'/bvsearch.php', type:'GET', timeout:10000, dataType:'text', data:qry, cache:true, async:sync, beforeSend:function(){ $(resultObjId).html('<img src="/images/loading1.gif" style="margin:100px auto 0 200px;" />loading...'); }, dataFilter:function(data){ return bvHandleResult(data,pickArr); }, success:function(data){ $(resultObjId).html(data); bvBind(pickArr); },error:function(){ $(resultObjId).html("timeout... please try again"); } }); return false; } 
/* bvsearch /end/ */

/* vanillaFrame v0.5 /start/ */ 
function getScrollXY(){ var scrOfX=0,scrOfY=0; if(typeof(window.pageYOffset)=='number'){ /*Netscape FF3 Chrome Safari*/ scrOfY=window.pageYOffset; scrOfX=window.pageXOffset; } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ){ /*DOM compliant (Chrome Safari)*/ scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft; } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop)){ /*IE6+ FF3*/ scrOfY=document.documentElement.scrollTop; scrOfX=document.documentElement.scrollLeft; } return[parseInt(scrOfX),parseInt(scrOfY)]; }

function show_vanillaFrame(){ try{
var scrollXY=getScrollXY();
var t=parseInt($(window).height())/2;
var l=parseInt($(window).width())/2;
var scrollXY=getScrollXY();
var boxH=parseInt($(document).find("div#vanillaFrameBox").css("height"))/2;
var boxW=parseInt($(document).find("div#vanillaFrameBox").css("width"))/2;
t=(t+scrollXY[1])-boxH; if(t<1){t=1};
l=(l+scrollXY[0])-boxW; if(l<1){l=1};
$(document).find("div#vanillaFrameWrapper").css("display","block");
$(document).find("div#vanillaFrameShadow").css({"display":"block","height":parseInt($(document).height()),"width":parseInt($(document).width())});
$(document).find("div#vanillaFrameBox").css({"display":"block","top":t,"left":l});
$(document).find("iframe#vanillaFrameiframe").css({"display":"block","scrolling":"no","overflowX":"hidden","overflowY":"auto"});
}catch(err){} return false; }

function hide_vanillaFrame(){ try{
$(document).find("div#vanillaFrameWrapper").css("display","none");
$(document).find("div#vanillaFrameShadow").css("display","none");
$(document).find("div#vanillaFrameBox").css("display","none");
$(document).find("iframe#vanillaFrameiframe").css("display","none");
}catch(err){} return false; }

function vanillaFrame(url,title,mainWidth,mainHeight){ try{ 
if(typeof url=="undefined"){url="about:blank";} if(typeof title=="undefined"){title="";} 
if(typeof mainWidth=="undefined"){ mainWidth="360px"; } if(typeof mainHeight=="undefined"){ mainHeight="300px"; }
var selector=$(document).find("body"); 
$(document).keyup(function(event){if(event.keyCode=='27'){hide_vanillaFrame();}});
hide_vanillaFrame();
if(selector.find("div#vanillaFrameWrapper").length==0){ var html=''+
'<div id="vanillaFrameWrapper" style="position:absolute;display:none;height:100%;min-height:100%;top:0px;left:0px;right:0px;" >'+
'<div id="vanillaFrameShadow"'+
' style="position:fixed;display:none;top:0px;left:0px;width:100%;height:100%;z-index:9999999998;overflow:auto;'+
' background-attachment:scroll; background-color:#FFFFFF; background-image:url(/accounts/images/overlay_background.png);'+
' background-position: left top; background-repeat:repeat; opacity:0.3;filter:Alpha(Opacity=30); " >'+
'</div>'+
'<div id="vanillaFrameBox"'+
' style="position:absolute;display:none;background:#FFFFFF;width:1px;height:1px;z-index:9999999999;padding:0px;margin:0px;" >'+
'<p id="vanillaFrameBoxTitle" '+
' style="position:relative;display:block;float:left;margin:5px 0px 8px 5px;height:22px;font-size:18px;font-weight:bold;color:#000;border:0px;" > '+
' '+ title +'</p>'+
'<p id="vanillaFrameBoxClose" '+
'style="position:relative;display:block;float:right;margin:5px 5px 0px 0px;height:15px;font-size:12px;color:#000;cursor:pointer;border:0px;" '+
' onclick="javascript:document.getElementById(\'vanillaFrameWrapper\').style.display=\'none\';" >&nbsp;Close&nbsp;</p>'+
'<div id="vanillaFrameBoxContent"'+
' style="position:relative;float:left;display:block;padding:0px;margin:0px;overflow:hidden;" >'+
'<iframe id="vanillaFrameiframe" name="vanillaFrameiframe" src="about:blank" width="1px" height="1px" scrolling="yes" '+
' style="border:0px; padding:0px;margin:0px;overflow-x:hidden;overflow-y:auto;" frameborder="0" ></iframe>'+
'</div></div></div>'; selector.append(html); }
selector.find("div#vanillaFrameBox").css({"width":mainWidth,"height":mainHeight});
selector.find("iframe#vanillaFrameiframe").css("display","none"); 
offsetBoxContent=selector.find("div#vanillaFrameBoxContent").offset();
var usableW=parseInt( selector.find("div#vanillaFrameBox").css("width"))-parseInt( selector.find("div#vanillaFrameBox").css("paddingLeft"))-parseInt( selector.find("div#vanillaFrameBox").css("paddingRight"));
var usableH=parseInt( selector.find("div#vanillaFrameBox").css("height"))-parseInt( selector.find("div#vanillaFrameBox").css("paddingTop"))-parseInt( selector.find("div#vanillaFrameBox").css("paddingBottom"));
usableH=usableH-parseInt( selector.find("#vanillaFrameBoxTitle").css("height"))-parseInt( selector.find("#vanillaFrameBoxTitle").css("marginTop"))-parseInt( selector.find("#vanillaFrameBoxTitle").css("marginBottom"));
selector.find("div#vanillaFrameBoxContent").css({"width":parseInt(usableW),"height":parseInt(usableH)});
selector.find("iframe#vanillaFrameiframe").css({"width":parseInt(usableW),"height":parseInt(usableH)});
selector.find("p#vanillaFrameBoxTitle").html(title);
show_vanillaFrame();
selector.find("div#vanillaFrameBoxContent").find("p#vanillaFrameSpinner").remove();
selector.find("div#vanillaFrameBoxContent").prepend('<p id="vanillaFrameSpinner" style="font-size:18px; font-weight:bold; margin:10px 0px 0px 35px;"> loading...</p>');
selector.find("iframe#vanillaFrameiframe").attr("src",url).one("load",function(){ selector.find("div#vanillaFrameBoxContent").find("p#vanillaFrameSpinner").remove(); selector.find("iframe#vanillaFrameiframe").css("display","block"); });
}catch(err){ hide_vanillaFrame(); return false; } return false; }
/* vanillaFrame v0.5 /end/ */

/* add to lookbook /start/ (require vanillaFrame) */
function lbAddToMyList(prodId){try{var id=prodId.replace(/[^0-9]+/,""); if(prodId==id){var src="/lookbook/addtomylist.php?mode=compact&html=1&prodID="+prodId; vanillaFrame(src,"Lookbook Products"); }}catch(err){return false;}return false;}
/* add to lookbook /end/ (require vanillaFrame) */

/* add to sales alerts /start/ (require vanillaFrame) */
function saAddProduct(prodId){try{var id=prodId.replace(/[^0-9]+/,"");if(prodId==id){var src="/salesalert_addprod.php?mode=compact&prodID="+prodId;vanillaFrame(src,"My Sales Alerts"); }}catch(err){return false;}return false;}
/* add to sales alerts /end/ (require vanillaFrame) */

/* add to wishlist /start/ (require vanillaFrame) */
function mlAddProduct(prodId,vendorname){try{var id=prodId.replace(/[^0-9]+/,"");if(prodId==id){var src="/mylynks_addtolist.php?mode=compact&prodID="+prodId+"&vendor_name="+vendorname;vanillaFrame(src,"My Wish List"); }}catch(err){return false;}return false;}
/* add to wishlist /end/ (require vanillaFrame) */


/* accounts compact functions v0.4 (require vanillaFrame) /start/ */
function signinCompact(parentreload) {
 try{ if(typeof parentreload=="undefined"){parentreload="";}else{if(parentreload==0){parentreload="";}else{parentreload="&parentreload=1";}} 
 var thisurl=self.location.protocol+'//'+self.location.hostname+"/accounts/?task=signin&mode=compact"+parentreload;
 if(self.document!=top.document){ parent.vanillaFrame(thisurl,"Sign In","360","300"); }
 else{ vanillaFrame(thisurl,"Sign In","360","300"); }
}catch(err){top.location.href=thisurl;}return false;}

function signupCompact(parentreload) {
 try{ if(typeof parentreload=="undefined"){parentreload="";}else{if(parentreload==0){parentreload="";}else{parentreload="&parentreload=1";}} 
 var thisurl=self.location.protocol+'//'+self.location.hostname+"/accounts/?task=signup&mode=compact"+parentreload;
 if(self.document!=top.document){ parent.vanillaFrame(thisurl,"Register","400","480"); }
 else{ vanillaFrame(thisurl,"Register","400","480"); }
}catch(err){top.location.href=thisurl;}return false;}

function recoveryCompact(args){
 try{ if(typeof args=="undefined"){args="";}else{args="&"+args;}
 var thisurl=self.location.protocol+'//'+self.location.hostname+"/accounts/?task=recovery&mode=compact"+args;
 if(self.document!=top.document){ parent.vanillaFrame(thisurl,"Forgot Your Password?","360","300"); }
 else{ vanillaFrame(thisurl,"Forgot Your Password?","360","300"); }
}catch(err){top.location.href=thisurl;}return false;}

function changepwdCompact(args){
 try{ if(typeof args=="undefined"){args="";}else{args="&"+args;}
 var thisurl=self.location.protocol+'//'+self.location.hostname+"/accounts/?task=changepwd&mode=compact"+args;
 if(self.document!=top.document){ parent.vanillaFrame(thisurl,"Change Password","360","360"); }
 else{ vanillaFrame(thisurl,"Change Password","360","360"); }
}catch(err){top.location.href=thisurl;}return false;}
/* accounts compact functions v0.4 (require vanillaFrame) /end/ */

/* /end/ script_essentials.js contents */
