function check_all(frm)
{len=frm.elements.length;var i=0;if(frm.delall.checked==true)
{for(i=0;i<len;i++)
{frm.elements[i].checked=true;}}
else
{for(i=0;i<len;i++)
{frm.elements[i].checked=false;}}}
function ValidateSelection(frm,tot,act_url)
{var x=true;for(var i=0;i<tot;i++)
{if(document.getElementById('del'+i).checked)
{x=false;confirmDel(frm,act_url);break;}}
if(x)
alert('No items selected! At least one checkbox must be ticked off to perform this action.');return false;}
function confirmDel(frm,act_url)
{if(confirm("Are you sure you want to proceed?"))
{frm.Process.value='DELETEMULTIPLE';frm.action=act_url;frm.submit();}}
function changeDisplayPage(pgName,PageNo){window.location.href="index.php?cmd="+pgName+"&page="+(PageNo-1);}
function echeck(str){var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if(str.indexOf(at)==-1){return false}
if(str.indexOf(at)==-1||str.indexOf(at)==0||str.indexOf(at)==lstr){return false}
if(str.indexOf(dot)==-1||str.indexOf(dot)==0||str.indexOf(dot)==lstr){return false}
if(str.indexOf(at,(lat+1))!=-1){return false}
if(str.substring(lat-1,lat)==dot||str.substring(lat+1,lat+2)==dot){return false}
if(str.indexOf(dot,(lat+2))==-1){return false}
if(str.indexOf(" ")!=-1){return false}
return true}
function BLcheckEmail(){var EmailID=document.FrmCustomer.email.value;var emailID=EmailID.replace(/^\s+|\s+$/g,"");if((emailID==null)||(emailID=="")){return false;}
if(echeck(emailID)==false){return false;}else{return true;}}
function trim(str)
{if(!str||typeof str!='string')
return null;return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');}
function AddtoCompare(id){if(id!=""&&id!=null){$('#logos').show();$.ajax({url:"add_to_compare.php",type:"GET",data:"PID="+id+"&Process=AddCompare",cache:false,success:function(html){if(html=="Success"){$('#logos').hide('slow');$('#DIV_CMP_PROD_SUCCESS').modal({containerCss:{height:168}});}else if(html=="Exists"){$('#logos').hide('slow');$('#DIV_CMP_PROD_ERROR').modal({containerCss:{height:168}});}else{alert('Sorry, unexpected error. Please try again.');$('#logos').hide();}}});}else{alert('Sorry, unexpected error. Please try again.');}}
function AddtoWishlist(id){if(id!=""&&id!=null){$('#logos').show();$.ajax({url:"add_to_wishlist.php",type:"GET",data:"PID="+id+"&Process=AddCompare",cache:false,success:function(html){if(html=="Success"){$('#logos').hide('slow');$('#DIV_WISHLIST_SUCCESS').modal({containerCss:{height:168}});}else if(html=="Exists"){$('#logos').hide('slow');$('#DIV_WISHLIST_ERROR').modal({containerCss:{height:168}});}else{alert('Sorry, unexpected error. Please try again.');$('#logos').hide();}}});}else{alert('Sorry, unexpected error. Please try again.');}}
