function jsValidate(obj)
{
  if(obj.parts_year.value == ""){
    alert("Select year");
    obj.parts_year.focus();
    return false;
  }
  if(obj.parts_make.value == ""){
    alert("Select make");
    obj.parts_make.focus();
    return false;
  }
  if(obj.parts_model.value == ""){
    alert("Select model");
    obj.parts_model.focus();
    return false;
  }
  if(obj.parts.value == ""){
    alert("Select parts");
    obj.parts.focus();
    return false;
  }
  
  estr=obj.email.value
  estr1=obj.confirm_email.value
  if(obj.email.value == ""){
    alert("Please supply your email address");
    obj.email.focus();
    return false;
  }    

  /*var email_pattern = /^(([^<>()[\]\\.,;:\s@'\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
  if(!obj.email.value.match(email_pattern)){
    alert("Please supply valid email address");
    obj.email.focus();
    return false;
  }*/
 
 
  var email_pattern = /^(([^<>()[\]\\!#$%^&*|`~,/?<+=,>;:\s@'\{}"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
  if(!obj.email.value.match(email_pattern)){
    alert("Please supply valid email address");
    obj.email.focus();
    return false;
  }
  if(obj.confirm_email.value == ""){
    alert("Please supply your confirm email address");
    obj.confirm_email.focus();
    return false;
  } 
  if(!obj.confirm_email.value.match(email_pattern)){
    alert("Please supply valid confirm email address");
    obj.confirm_email.focus();
    return false;
  }
  if(estr != estr1){
		alert("Email and confirm email values should be the same");
		obj.confirm_email.focus();
		return false;
	}



//
// Fred Potmesil commented out the following lines
// for testing canadian postal codes in 
// mrcycleparts.   Just using the same code as
// what is in place in partshotlines.
// we should have only one general javascript library include
// file, that would be great.
//
/* 
  if(isNaN(obj.zip_code.value)){
    alert("Please supply valid zip code");
    obj.zip_code.focus();
    return false;
  } 
  */
 
	if(obj.zip_code.value == "")
    {
    alert("Please supply your zip code");
    obj.zip_code.focus();
    return false;
    }


    if( validate_ca_us_zip( obj.zip_code.value.toUpperCase() ) )
    {
    }
    else
    {
        return false;
    }


   if(obj.phone.value != "") 
    { 
        var phone_pattern = /^\d{3}\-\d{3}\-\d{4}$/;

        if(!obj.phone.value.match(phone_pattern))
        {
            alert("Please enter phone number in this format 888-555-1212");
            obj.phone.focus();
            return false;
        }
    }   
}







function validate_ca_us_zip( v )
{
    rval = false;
    // v = obj.zip_code.value.toUpperCase();

    var regex = /((^\d{5}([- |]\d{4})?$)|(^[A-Z]\d[A-Z][- |]\d[A-Z]\d$)|(^[A-Z]\d[A-Z]\d[A-Z]\d$))/;

    if( regex.test(v) )
    {
        //alert("VALID ZIP ENTERED!!");
        rval = true;
    }
    else
    {
        alert("Please enter VALID CANADIAN or USA zip code");
    }

    return rval;
}







/*File Fucntion For parts_access.tpl */
function psValidate(obj){
  /*if(obj.txt_keywords.value == ""){
   alert("Please enter keywords to search");
   obj.txt_keywords.focus();
   return false;
  }*/
  if(!obj.chk_nuparts.checked && !obj.chk_accessories.checked && !obj.chk_clothing.checked ){
   alert("Please select atleast one of the option to search");
   obj.chk_nuparts.focus();
   return false;
  }
} 

// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this notice.

// SETUPS:
// ===============================

// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=300,height=300,left='+PositionX+',top='+PositionY;

function popImage(imageURL,imageTitle){
imageTitle='Large Image';
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=120-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block">');
writeln('<script type="text/javascript">');
writeln('var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");');
writeln('document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));');
writeln('</script>');
writeln('<script type="text/javascript">');
writeln('try {');
writeln('var pageTracker = _gat._getTracker("UA-2248825-3");');
writeln('pageTracker._trackPageview();');
writeln('} catch(err) {}</script>');
writeln('</body></html>');
close();  
}}

 
/* function for open and close image window */
function open_new_window(url,title){
  new_window = window.open(url,'title','left=330,top=250,toolbar=0,resizable=0,width=500,height=500,left=55,top=15,scrollbars=1')
}
function close_window(){
  new_window.close();
}
/* Function for delete confirmation */
function confirmdel(){
  if (!confirm("Are you sure want to delete this record?")){
		return false;
	}
}

function imgDel(){
  if (!confirm("Are you sure you want to remove this image?")){
		return false;
	}
}
