function check_search_form_submit(words,phrase){var keyword=words.value;if(keyword==''||keyword==' '||keyword==phrase){alert(common_js_lib_msg1);return false}return true}function check_search_form_submit2(words,phrase){var keyword=words.value;
    var categoryid;
    if( words.form.categoryid ) 
    {
        categoryid = words.form.categoryid.value;
    }

var inclosed=words.form.in_closed.checked;var fulltext = words.form.fulltext.checked;if((!categoryid||inclosed|| fulltext)&&(keyword==''||keyword==' '||keyword==phrase)){alert(common_js_lib_msg1);return false}return true}function reload_selling_second_page(dr){dr.form.mo.value='condition-form';dr.form.submit()}function reload_similar_posting_page(dr){set_no_check_value(1);submit_all_postage();dr.form.action=dr.form.action+'#extras';dr.form.mo.value='posting-similar';dr.form.submit()}function redir_auction(drop){index=drop.selectedIndex;if(index==null){value=''}else{value=drop.options[index].value}if(value!=''){new_url=auction_redir_base+value;location.href=new_url}}function redir_category(drop){index=drop.selectedIndex;if(index==null){value=''}else{value=drop.options[index].value}if(value!=''){categorytype=value.substring(0,1);categoryid=value.substring(1);if(categorytype=='c'){new_url=listings_server+"cat-"+categoryid+".php"}else{new_url=listings_server+"scat-"+categoryid+".php"}location.href=new_url}}function redir_search(drop){index=drop.selectedIndex;if(index==null){value=''}else{value=drop.options[index].value}if(value!=''){new_url=search_redir_base+value;location.href=new_url}}function collapse_div(id){if(document.all){div_elem=document.all[id];if(div_elem){div_elem.style.display='none'}}if(!document.all&&document.getElementById){div_elem=document.getElementById(id);if(div_elem){div_elem.style.display='none'}}}function expand_div(id,showtype){if(!showtype){showtype='block'}if(document.all){div_elem=document.all[id];if(div_elem){div_elem.style.display=showtype}}if(!document.all&&document.getElementById){div_elem=document.getElementById(id);if(div_elem){div_elem.style.display=showtype}}}function open_faq_window(url){var width=250;var height=150;var from_top=100;var from_left=100;var toolbar='no';var location='no';var directories='no';var status='no';var menubar='no';var scrollbars='yes';var resizable='yes';var atts='width='+width+'show,height='+height+',top='+from_top+',screenY=';atts+=from_top+',left='+from_left+',screenX='+from_left+',toolbar='+toolbar;atts+=',location='+location+',directories='+directories+',status='+status;atts+=',menubar='+menubar+',scrollbars='+scrollbars+',resizable='+resizable;myWin1=window.open(url,'win_name',atts);if(navigator.appName!="Microsoft Internet Explorer"){if(window.focus){myWin1.focus()}}}function showHideDiv(id){if(document.all){if(document.all[id].style.display=='none'){document.all[id].style.display='block'}else{document.all[id].style.display='none'}}if(!document.all&&document.getElementById){if(document.getElementById(id).style.display=='none'){document.getElementById(id).style.display='block'}else{document.getElementById(id).style.display='none'}}}function count_chars_left(input,divname,total){total_chars=input.value.length;chars_left=total-total_chars;if(document.all){document.all[divname].innerHTML=chars_left}if(!document.all&&document.getElementById){document.getElementById(divname).innerHTML=chars_left}}function cent(amount){amount-=0;amount=(Math.floor((amount+0.0001)*100)/100);return(amount==Math.floor(amount))?amount+'.00':((amount*10==Math.floor(amount*10))?amount+'0':amount)}var opened_div;function getposOffset(overlay,offsettype){var totaloffset=(offsettype=="left")?overlay.offsetLeft:overlay.offsetTop;var parentEl=overlay.offsetParent;while(parentEl!=null){totaloffset=(offsettype=="left")?totaloffset+parentEl.offsetLeft:totaloffset+parentEl.offsetTop;parentEl=parentEl.offsetParent}return totaloffset}function overlay(curobj,subobjstr,opt_position){if(opened_div&&opened_div!=subobjstr){overlayclose(opened_div)}if(document.getElementById){var subobj=document.getElementById(subobjstr);document.onmousemove=function(e){clicktohide(curobj,subobjstr,e)};subobj.style.display=(subobj.style.display!="block")?"block":"none";var xpos=getposOffset(curobj,"left")+((typeof opt_position!="undefined"&&opt_position.indexOf("right")!=-1)?-(subobj.offsetWidth-curobj.offsetWidth):0);var ypos=getposOffset(curobj,"top")+((typeof opt_position!="undefined"&&opt_position.indexOf("bottom")!=-1)?curobj.offsetHeight-1:0);subobj.style.left=xpos+"px";subobj.style.top=ypos+"px";opened_div=subobjstr;return false}else return true}function overlayclose(subobj){document.getElementById(subobj).style.display="none"}function clicktohide(linkobj,subobj,e){var currentnode=(window.event)?event.srcElement:e.target;var hidesubobj=true;while(currentnode.tagName!="BODY"&&currentnode.tagName!="HTML"){if(currentnode.id==subobj||currentnode==linkobj){hidesubobj=false;break}currentnode=currentnode.parentNode}if(hidesubobj)overlayclose(subobj)}function valid_zip(country,zip){if(country=='us'){var err;if(zip.length!=5){err=true}for(i=0;i<zip.length;i++){if(zip.charAt(i)<'0'||zip.charAt(i)>'9'){err=true;break}}}if(country=='ca'){reg_exp_pcode=new RegExp(/(^s*([a-z](\s)?\d(\s)?){3}$)s*/i);if(!reg_exp_pcode.test(zip)){err=true}}
  if( country == 'uk' )
  {
	var postcodeRegEx = /[A-Z]{1,2}[0-9]{1,2} ?[0-9][A-Z]{2}/i;
	var postcodeRegEx2 = /[A-Z]{1,2}[0-9]{1,2}$/i;
	if( ! postcodeRegEx.test(zip) && ! postcodeRegEx2.test(zip) )
	{
           err = true; 
	}
  }

if(err){alert(common_js_lib_msg2);return false}return true}function valid_zip_nomessage(country,zip){var err;if(country=='us'){if(zip.length!=5){err=true}for(i=0;i<zip.length;i++){if(zip.charAt(i)<'0'||zip.charAt(i)>'9'){err=true;break}}}return!err}function check_weight_lb(elem){re=/[^\d\.\,]/g;newstr=elem.value.replace(re,"");re=/\,/g;newstr=newstr.replace(re,".");newstr=parseInt(newstr);if(isNaN(newstr)){newstr=''}elem.value=newstr}function check_weight_oz(elem){re=/[^\d\.\,]/g;newstr=elem.value.replace(re,"");re=/\,/g;newstr=newstr.replace(re,".");re=/\.+/g;newstr=newstr.replace(re,".");newstr=parseFloat(newstr);newstr=Math.floor(newstr*10)/10;if(isNaN(newstr)){newstr=''}elem.value=newstr}function check_amount(field){str=field.value;if( str == '' ) { return ; }re=/\,/g;str=str.replace(re,".");if(str.match(/^\./)){str='0'+str}if(str==''){str='0.00'}if(!str.match(/^\d+$|^\d+\.\d{2}$|^\d+\.\d{1}$/)){alert(common_js_lib_msg3)}if(str.match(/^\d+\.\d{1}$/)){str+='0'}field.value=str}function open_print_invoice_window(url){var width=800;var height=600;var from_top=100;var from_left=100;var toolbar='no';var location='no';var directories='no';var status='no';var menubar='no';var scrollbars='yes';var resizable='yes';var atts='width='+width+'show,height='+height+',top='+from_top+',screenY=';atts+=from_top+',left='+from_left+',screenX='+from_left+',toolbar='+toolbar;atts+=',location='+location+',directories='+directories+',status='+status;atts+=',menubar='+menubar+',scrollbars='+scrollbars+',resizable='+resizable;myWin1=window.open(url,'win_name',atts);if(navigator.appName!="Microsoft Internet Explorer"){if(window.focus){myWin1.focus()}}}
function check_amount_neg(field){str=field.value;if( str == '' ) { return ; }re=/\,/g;str=str.replace(re,".");if(str.match(/^\./)){str='0'+str}if(str==''){str='0.00'} var minus = ''; if(str.charAt(0) == '-' ){minus='-';str=str.substr(1);} if(!str.match(/^\d+$|^\d+\.\d{2}$|^\d+\.\d{1}$/)){alert(common_js_lib_msg3)}if(str.match(/^\d+\.\d{1}$/)){str+='0'}field.value=minus+str}
