function check_sale_login(){if(document.getElementById("username").value.trim()==""){alert("Please enter username");document.getElementById("username").focus();return false}if(document.getElementById("password").value.trim()==""){alert("Please enter password");document.getElementById("password").focus();return false}}function check_sale_step1(){if(document.getElementById("LookingTo1").checked==false&&document.getElementById("LookingTo2").checked==false){alert("Please select I'm looking to");document.getElementById("LookingTo1").focus();return false}if(document.getElementById("NewProduct").checked==false&&document.getElementById("NewProduct1").checked==false&&document.getElementById("NewProduct2").checked==false){alert("Is the item  you are selling used or new?");document.getElementById("NewProduct").focus();return false}if(get_saleChkCount("sale_category")==0){alert("Please select atleast one category");return false}if(get_saleChkCount("sale_category")>2){alert("Please select maximum of 2 categorires");return false}}function get_saleChkCount(b){f1=document.sale_step1;var c=0;for(i=0;i<f1.length;i++){var a=f1[i].name;if(a.indexOf(b)>=0&&f1[i].type=="checkbox"&&f1[i].checked==true){c++}}return c}function get_saleChkCount1(b){f1=document.sale_step2;var c=0;for(i=0;i<f1.length;i++){var a=f1[i].name;if(a.indexOf(b)>=0&&f1[i].type=="checkbox"&&f1[i].checked==true){c++}}return c}function check_sale_step2(a){if(document.getElementById("PostingTitle").value.trim()==""){alert("Please enter posting title");document.getElementById("PostingTitle").focus();return false}if(document.getElementById("LookingTo").value.trim()=="Sell"){if(document.getElementById("ProductPrice").value.trim()==""){alert("Please enter original price");document.getElementById("ProductPrice").focus();return false}if(checknumber(document.getElementById("ProductPrice").value.trim())==false){alert("Please enter valid original price. Only enter numerical characters. Do not enter currency symbols.");document.getElementById("ProductPrice").focus();return false}if(document.getElementById("DiscountPrice").value.trim()==""){alert("Please enter discount price");document.getElementById("DiscountPrice").focus();return false}if(checknumber(document.getElementById("DiscountPrice").value.trim())==false){alert("Please enter valid discount price. Only enter numerical characters. Do not enter currency symbols.");document.getElementById("DiscountPrice").focus();return false}}if(document.getElementById("ProductDescription").value.trim()==""){alert("Please enter product description");document.getElementById("ProductDescription").focus();return false}if(document.getElementById("SaleCity").value.trim()=="Other"&&document.getElementById("OtherCity").value.trim()==""){alert("Please enter city name");document.getElementById("OtherCity").focus();return false}if(document.getElementById("CompanyName").value.trim()==""){alert("Please enter company name");document.getElementById("CompanyName").focus();return false}if(document.getElementById("CompanyUrl").value.trim()==""){alert("Please enter company web site");document.getElementById("CompanyUrl").focus();return false}if(document.getElementById("CompanyUrl").value.trim()!=""){if(isValidURL(document.getElementById("CompanyUrl").value)==false){alert("Please enter valid company web site");document.getElementById("CompanyUrl").focus();return false}}if(document.getElementById("RetypeCompanyUrl").value.trim()==""){alert("Please retype company web site");document.getElementById("RetypeCompanyUrl").focus();return false}if(document.getElementById("RetypeCompanyUrl").value.trim()!=""){if(isValidURL(document.getElementById("RetypeCompanyUrl").value)==false){alert("Please enter valid company web site");document.getElementById("RetypeCompanyUrl").focus();return false}}if(document.getElementById("CompanyUrl").value.trim()!=document.getElementById("RetypeCompanyUrl").value.trim()){alert("Company web site and retype web site should be same");document.getElementById("CompanyUrl").focus();return false}if(get_saleValidFile("sale_img")>0){alert("Please upload valid sale image(s)");return false}if(document.getElementById("reply_email").value.trim()!=""&&document.getElementById("re_reply_email").value.trim()==""){alert("Please retype reply email id");document.getElementById("reply_email").focus();return false}if(document.getElementById("reply_email").value.trim()==""&&document.getElementById("re_reply_email").value.trim()!=""){alert("Please enter reply email id");document.getElementById("reply_email").focus();return false}if(document.getElementById("reply_email").value.trim()!=""&&emailCheck(document.getElementById("reply_email").value)==false){alert("Please enter valid reply email id");document.getElementById("reply_email").focus();return false}if(document.getElementById("re_reply_email").value.trim()!=""&&emailCheck(document.getElementById("re_reply_email").value)==false){alert("Please enter valid reply email id");document.getElementById("re_reply_email").focus();return false}if(document.getElementById("reply_email").value.trim()!=""&&document.getElementById("re_reply_email").value.trim()!=""){if(document.getElementById("reply_email").value.trim()!=document.getElementById("re_reply_email").value.trim()){alert("Reply email id and retype reply email id should be same");document.getElementById("reply_email").focus();return false}}if(document.getElementById("HelpingHand").checked==true){if(document.getElementById("HelpingWebAddress").value.trim()==""){alert("Please enter website address");document.getElementById("HelpingWebAddress").focus();return false}if(document.getElementById("HelpingWebAddress").value.trim()!=""){if(isValidURL(document.getElementById("HelpingWebAddress").value)==false){alert("Please enter valid website address");document.getElementById("HelpingWebAddress").focus();return false}}}document.getElementById("Post").disabled="true";hidden_span=document.getElementById("hide_stuff");hidden_span.style.display="block";return true}function check_sale_edit(a){if(document.getElementById("LookingTo1").checked==false&&document.getElementById("LookingTo2").checked==false){alert("Please select I'm looking to");document.getElementById("LookingTo1").focus();return false}if(document.getElementById("NewProduct").checked==false&&document.getElementById("NewProduct1").checked==false&&document.getElementById("NewProduct2").checked==false){alert("Is the product you are selling used or new?");document.getElementById("NewProduct").focus();return false}if(get_saleChkCount1("sale_category")==0){alert("Please select atleast one category");return false}if(get_saleChkCount1("sale_category")>2){alert("Please select maximum of 2 categorires");return false}if(document.getElementById("PostingTitle").value.trim()==""){alert("Please enter posting title");document.getElementById("PostingTitle").focus();return false}if(document.getElementById("SelLookingTo").value.trim()=="Sell"){if(document.getElementById("ProductPrice").value.trim()==""){alert("Please enter original price");document.getElementById("ProductPrice").focus();return false}if(document.getElementById("DiscountPrice").value.trim()==""){alert("Please enter discount price");document.getElementById("DiscountPrice").focus();return false}}if(document.getElementById("ProductDescription").value.trim()==""){alert("Please enter product description");document.getElementById("ProductDescription").focus();return false}if(document.getElementById("SaleCity").value.trim()=="Other"&&document.getElementById("OtherCity").value.trim()==""){alert("Please enter city name");document.getElementById("OtherCity").focus();return false}if(document.getElementById("CompanyUrl").value.trim()==""){alert("Please enter company web site");document.getElementById("CompanyUrl").focus();return false}if(document.getElementById("CompanyUrl").value.trim()!=""){if(isValidURL(document.getElementById("CompanyUrl").value)==false){alert("Please enter valid company web site");document.getElementById("CompanyUrl").focus();return false}}if(document.getElementById("RetypeCompanyUrl").value.trim()==""){alert("Please retype company web site");document.getElementById("RetypeCompanyUrl").focus();return false}if(document.getElementById("RetypeCompanyUrl").value.trim()!=""){if(isValidURL(document.getElementById("RetypeCompanyUrl").value)==false){alert("Please enter valid company web site");document.getElementById("RetypeCompanyUrl").focus();return false}}if(get_saleValidFile("sale_img")>0){alert("Please upload valid sale image(s)");return false}if(document.getElementById("reply_email").value.trim()!=""&&document.getElementById("re_reply_email").value.trim()==""){alert("Please retype reply email id");document.getElementById("reply_email").focus();return false}if(document.getElementById("reply_email").value.trim()==""&&document.getElementById("re_reply_email").value.trim()!=""){alert("Please enter reply email id");document.getElementById("reply_email").focus();return false}if(document.getElementById("reply_email").value.trim()!=""&&emailCheck(document.getElementById("reply_email").value)==false){alert("Please enter valid reply email id");document.getElementById("reply_email").focus();return false}if(document.getElementById("re_reply_email").value.trim()!=""&&emailCheck(document.getElementById("re_reply_email").value)==false){alert("Please enter valid reply email id");document.getElementById("re_reply_email").focus();return false}if(document.getElementById("reply_email").value.trim()!=""&&document.getElementById("re_reply_email").value.trim()!=""){if(document.getElementById("reply_email").value.trim()!=document.getElementById("re_reply_email").value.trim()){alert("Reply email id and retype reply email id should be same");document.getElementById("reply_email").focus();return false}}document.getElementById("Post").disabled="true";hidden_span=document.getElementById("hide_stuff");hidden_span.style.display="block";return true}function get_saleValidFile(b){f1=document.sale_step2;var c=0;for(i=0;i<f1.length;i++){var a=f1[i].name;if(a.indexOf(b)>=0&&f1[i].type=="file"&&f1[i].value.trim()!=""&&LimitAttach1(f1[i].value)==false){c++}}return c}function addSaleImage(){var a=document.getElementById("div_images");var b=(document.sale_step2.num_images.value-1)+2;document.sale_step2.num_images.value=b;if(b<=2){var c=document.createElement("div");var d="div_images_"+b;c.setAttribute("id",d);c.setAttribute("style","padding-top:10px;");c.innerHTML="<table width='100%'  border='0' cellspacing='2' cellpadding='2'><tr><td align='left' valign='top' width='13%'><strong>Image caption:</strong></td><td align='right' valign='top'><input type='text' id='image_caption[]' name='image_caption[]' value='' size='23' maxlength='30'><br>(max of 30 characters)</td><td align='left' valign='top' width='72%'><input type='file' id='sale_img[]' name='sale_img[]'><br><a href='javascript:deleteSaleImage("+b+")' class='blue_link'>Remove</a></td></tr></table>";a.appendChild(c)}}function deleteSaleImage(b){var c=document.getElementById("div_images");var d=document.sale_step2.num_images.value;var a=document.getElementById("div_images_"+b);c.removeChild(a);document.sale_step2.num_images.value=d-1}function show_optionalSaleInfo(){document.getElementById("PriceNegotiableTr").style.display="";document.getElementById("ProductWarrantyTr").style.display="";document.getElementById("ProductBoxTr").style.display="";document.getElementById("GeneralProductConditionTr").style.display="";document.getElementById("optional_show").style.display="none";document.getElementById("optional_close").style.display=""}function hide_optionalSaleInfo(){document.getElementById("PriceNegotiableTr").style.display="none";document.getElementById("ProductWarrantyTr").style.display="none";document.getElementById("ProductBoxTr").style.display="none";document.getElementById("GeneralProductConditionTr").style.display="none";document.getElementById("optional_show").style.display="";document.getElementById("optional_close").style.display="none"}var SaleReq=createXMLHttpRequest();function GetSaleState(){var a=document.getElementById("SaleCountry").value;if(a!=""){SaleReq.open("get","SaleStates.php?CountryId="+a);SaleReq.onreadystatechange=SaleStateHandleResponse;SaleReq.send(null)}}function SaleStateHandleResponse(){if(SaleReq.readyState==4){var a=SaleReq.responseText;document.getElementById("SaleState").innerHTML=a;GetSaleCity()}}var SaleReq1=createXMLHttpRequest();function GetSaleCity(){var a=document.getElementById("SaleState").value;if(a!=""){SaleReq1.open("get","SaleCity.php?StateId="+a);SaleReq1.onreadystatechange=SaleCityHandleResponse;SaleReq1.send(null)}}function SaleCityHandleResponse(){if(SaleReq1.readyState==4){var a=SaleReq1.responseText;document.getElementById("SaleCity").innerHTML=a}}function check_step3(){if(document.getElementById("captcha_code").value.trim()==""){alert("Please Enter Security Code");return false}}function redirect_editSale_post(b){var a="com_sale_post|step3";window.location.href="http://www.macdirectory.com/component/option,com_sale3/task,editSale/sale_id,"+b+"/next,"+a+"/"}function post_serviceComment(a){document.getElementById("link_postComment").style.display="none";document.getElementById("new_serviceComment").style.display=""}function chk_postServiceComment(){if(document.getElementById("comment_txt").value.trim()==""){alert("Please enter comment");document.getElementById("comment_txt").focus();return false}}function show_serviceCommentReply(b){var c="video_comment_reply_"+b;var a="commment_reply_"+b;document.getElementById(c).style.display="";document.getElementById(a).style.display="none"}function chk_serviceCommentReply(a){var b="reply_text_"+a;if(document.getElementById(b).value.trim()==""){alert("Please enter your comment reply");document.getElementById(b).focus();return false}}function ChangePhotographerImage(){document.getElementById("RemovePhotographerImageLink").style.display=""}function ListCategorySale(){var a=document.getElementById("category").value;if(a=="all"){window.location="http://www.macdirectory.com/component/option,com_sale/task,viewAll/"}else{if(a=="Books"||a=="Games"||a=="Hardware"||a=="iPhone"||a=="iPod"||a=="Laptop"||a=="Software"||a=="Miscellaneous"){window.location="http://www.macdirectory.com/component/option,com_sale1/task,viewCategory/catName,"+a+"/"}else{window.location="http://www.macdirectory.com/component/option,com_sale1/task,searchCategory/catName,"+a+"/"}}}function ListCategoryWanted(){var a=document.getElementById("category").value;if(a=="all"){window.location="http://www.macdirectory.com/component/option,com_wanted/task,viewAll/"}else{if(a=="Books"||a=="Games"||a=="Hardware"||a=="iPhone"||a=="iPod"||a=="Laptop"||a=="Software"){window.location="http://www.macdirectory.com/component/option,com_wanted1/task,viewCategory/catName,"+a+"/"}else{window.location="http://www.macdirectory.com/component/option,com_wanted1/task,searchCategory/catName,"+a+"/"}}}function check_SaleReply(){if(document.getElementById("sen_name").value.trim()==""){alert("Please enter your name");document.getElementById("sen_name").focus();return false}if(document.getElementById("sen_email").value.trim()==""){alert("Please enter your email");document.getElementById("sen_email").focus();return false}if(document.getElementById("sen_email").value.trim()!=""){if(emailCheck(document.getElementById("sen_email").value)==false){alert("Please enter valid your email");document.getElementById("sen_email").focus();return false}}if(document.getElementById("message").value.trim()==""){alert("Please enter personal message");document.getElementById("message").focus();return false}if(document.getElementById("captcha_code").value.trim()==""){alert("Please enter spam code");document.getElementById("captcha_code").focus();return false}}function CheckSaleCity(){if(document.getElementById("SaleCity").value=="Other"){document.getElementById("OtherCityTr").style.display=""}else{document.getElementById("OtherCityTr").style.display="none"}}function CheckApplicationForm(){var a=document.getElementById("TaxId").value;if(document.getElementById("FirstName").value.trim()==""){alert("Please enter first name");document.getElementById("FirstName").focus();return false}if(document.getElementById("LastName").value.trim()==""){alert("Please enter last name");document.getElementById("LastName").focus();return false}if(document.getElementById("Email").value.trim()==""){alert("Please enter email");document.getElementById("Email").focus();return false}if(document.getElementById("Email").value.trim()!=""){if(emailCheck(document.getElementById("Email").value)==false){alert("Please enter valid email");document.getElementById("Email").focus();return false}}if(document.getElementById("RetypeEmail").value.trim()==""){alert("Please enter retype email");document.getElementById("RetypeEmail").focus();return false}if(document.getElementById("RetypeEmail").value.trim()!=""){if(emailCheck(document.getElementById("RetypeEmail").value)==false){alert("Please enter valid retype email");document.getElementById("RetypeEmail").focus();return false}}if(document.getElementById("RetypeEmail").value.trim()!=""&&document.getElementById("Email").value.trim()!=""){if(document.getElementById("RetypeEmail").value!=document.getElementById("Email").value){alert("Email and retype email should be same");document.getElementById("RetypeEmail").focus();return false}}if(document.getElementById("CompanyName").value.trim()==""){alert("Please enter company name");document.getElementById("CompanyName").focus();return false}if(document.getElementById("CompanyUrl").value.trim()==""){alert("Please enter company URL");document.getElementById("CompanyUrl").focus();return false}if(document.getElementById("CompanyUrl").value.trim()!=""){if(isValidURL(document.getElementById("CompanyUrl").value)==false){alert("Please enter complete company URL (http://www._______.com)");document.getElementById("CompanyUrl").focus();return false}}if(document.getElementById("Telephone").value.trim()==""){alert("Please enter telephone number");document.getElementById("Telephone").focus();return false}if(document.getElementById("TaxId").value.trim()==""){alert("Please enter Tax ID number");document.getElementById("TaxId").focus();return false}if(document.getElementById("TaxId").value.trim()!=""){if(checknumber(document.getElementById("TaxId").value)==false){alert("Must be a 9 digit number for U.S. entries. No dashes or spaces allowed");document.getElementById("TaxId").focus();return false}}if(document.getElementById("StreetAddress").value.trim()==""){alert("Please enter street address");document.getElementById("StreetAddress").focus();return false}if(document.getElementById("City").value.trim()==""){alert("Please enter city");document.getElementById("City").focus();return false}if(document.getElementById("State").value.trim()==""){alert("Please enter state");document.getElementById("State").focus();return false}if(document.getElementById("Zip").value.trim()==""){alert("Please enter zip");document.getElementById("Zip").focus();return false}if(document.getElementById("Country").value.trim()==""){alert("Please select country");document.getElementById("Country").focus();return false}if(document.getElementById("Country").value.trim()=="United States of America"&&a.length!=9){alert("Must be a 9 digit number for U.S. entries. No dashes or spaces allowed");document.getElementById("TaxId").focus();return false}if(get_ApplicationChkCount("InterestedSection")==0){alert("Which sections are you interested in posting content?");return false}if(get_ApplicationChkCount("LookingFor")==0){alert("What are you looking to sell/buy?");return false}if(document.getElementById("DiscountLevel").value.trim()=="Select"){alert("What type of deal/discount will you provide to MacDirectory users?");document.getElementById("DiscountLevel").focus();return false}if(document.getElementById("SaleCommision").value.trim()==""){alert("What type of sales commission can you provide to MacDirectory for sales obtained via this program?");document.getElementById("SaleCommision").focus();return false}if(document.getElementById("captcha_code").value.trim()==""){alert("Please enter security code");document.getElementById("captcha_code").focus();return false}}function get_ApplicationChkCount(b){f1=document.ApplicationForm;var c=0;for(i=0;i<f1.length;i++){var a=f1[i].name;if(a.indexOf(b)>=0&&f1[i].type=="checkbox"&&f1[i].checked==true){c++}}return c};
