function MM_reloadPage(init) {  //reloads the window if Nav4 resized
    if (init==true) with (navigator) {
        if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
            document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage;
        }
        }
    else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
    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_preloadImages() { //v3.0
    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_findObj(n, d) { //v4.01
    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() { //v3.0
    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 MM_showHideLayers() { //v6.0
        var i,p,v,obj,args=MM_showHideLayers.arguments;
        for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) {
            v=args[i+2];
            if (obj.style) {
                obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v;
            }
            obj.visibility=v;
        }
    }
}

function MM_showHideLayers() { //v6.0
    var i,p,v,obj,args=MM_showHideLayers.arguments;
    //alert("i: " + i + " p: " + p + " v: " + v + " args: 0: " + args[0] + " 1: " + args[1] + " 2: " + args[2]);
    for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) {
        v=args[i+2];
        if (obj.style) {
            obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v;
        }
        obj.visibility=v;
    }
}



function trim(inputString)
{
    // Removes leading and trailing spaces from the passed string. Also removes
    // consecutive spaces and replaces it with one space. If something besides
    // a string is passed in (null, custom object, etc.) then return the input.
    if (typeof inputString != "string") {
        return inputString;
    }
    var retValue = inputString;
    var ch = retValue.substring(0, 1);
    while (ch == " ")
    { // Check for spaces at the beginning of the string
        retValue = retValue.substring(1, retValue.length);
        ch = retValue.substring(0, 1);
    }
    ch = retValue.substring(retValue.length-1, retValue.length);
    while (ch == "  ")
    { // Check for spaces at the end of the string
        retValue = retValue.substring(0, retValue.length-1);
        ch = retValue.substring(retValue.length-1, retValue.length);
    }
    while (retValue.indexOf("  ") != -1)
    { // Note that there are two spaces in the string - look for multiple spaces within the string
        retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
    }
    return retValue; // Return the trimmed string back to the user
}
        
            
var validchars = "abcdefghijklmnopqrstuvwxyz0123456789._@";
var validcharsPwd = "abcdefghijklmnopqrstuvwxyz0123456789._#$%&|+!@~^()=-:;{}[]<>?";
var vailidLoginEmailChars = "abcdefghijklmnopqrstuvwxyz0123456789._@+-&'*/=?^{}~";

function validateLogin(res)
{
    var login = document.billform.loginId.value;
    var pwd = document.billform.password.value;

    var result='';
    var focus=0;
    //Check loginId
    if( login =='' )
    {
        if( result == '' )
        {
            focus=1;
            result = 'Please enter valid information for following field(s):';
        }
        //document.billform.loginId.focus();
        result += '\n Login Id';
    }
    else
    {
        if( login.length > 255 )
        {

            if( result == '' )
            {
                focus=1;
                result += 'Please enter valid information for following field(s):';
            }
            
            result +='\n Invalid Login id, length exceeded';

            document.billform.loginId.value = '';
        //document.billform.loginId.focus();
            
        }
    }                 

    //Check password
    if(document.billform.password.value =='') 
    {
        if( result == '' )
        {
            focus=2;
            result = 'Please enter valid information for following field(s):';
        }
        
        //document.billform.password.focus();
        result += '\n Password';
    }
    else
    {
        if( pwd.length > 35 ) 
        {
            if( result == '' )
            {
                focus=2;
                result += 'Please enter valid information for following field(s):';
            }

            document.billform.password.value = '';
            //document.billform.password.focus();

            result +='\n Invalid Password, length exceeded';
        }



    }                 

    if ( result=='' )
    {
        document.billform.action="/login.do";
        document.billform.submit();
    }
    else
    {
        alert(result);
        if(focus==1)
            document.billform.loginId.focus();
        if(focus==2)
            document.billform.password.focus();
        
    }

}
                            
                            
function validateRegistration(ret)
{
    var phno =document.getElementById(12).value;
    var i;
    var totallength=phno.length;
    
    var strtindexofopbrk=phno.indexOf("(",0);
    var strtindexofclbrk=phno.indexOf(")",0);
    var strtindexofbar=phno.indexOf("-",0);
    var strtindexofspc=phno.indexOf(" ",0);
    var lastindexofbar=phno.lastIndexOf("-");
    var lastindexofopbrk=phno.lastIndexOf("(");
    var lastindexofclbrk=phno.lastIndexOf(")");
    var lastindexofspc=phno.lastIndexOf(" ");
    var phonelength=phno.length -1;

    var faxno =document.getElementById(13).value;
    var y;
    var faxtotallength=faxno.length;
    var fstrtindexofopbrk=faxno.indexOf("(",0);
    var fstrtindexofclbrk=faxno.indexOf(")",0);
    var fstrtindexofbar=faxno.indexOf("-",0);
    var fstrtindexofspc=faxno.indexOf(" ",0);
    var flastindexofbar=faxno.lastIndexOf("-");
    var flastindexofopbrk=faxno.lastIndexOf("(");
    var flastindexofclbrk=faxno.lastIndexOf(")");
    var flastindexofspc=faxno.lastIndexOf(" ");
    var faxlength=faxno.length -1;   
    /*//binita
	 var ph2no =document.getElementById(66).value;
    var m;
    var ph2totallength=ph2no.length;
    var p2strtindexofopbrk=ph2no.indexOf("(",0);
    var p2strtindexofclbrk=ph2no.indexOf(")",0);
    var p2strtindexofbar=ph2no.indexOf("-",0);
    var p2strtindexofspc=ph2no.indexOf(" ",0);
    var p2lastindexofbar=ph2no.lastIndexOf("-");
    var p2lastindexofopbrk=ph2no.lastIndexOf("(");
    var p2lastindexofclbrk=ph2no.lastIndexOf(")");
    var p2lastindexofspc=ph2no.lastIndexOf(" ");
    var ph2length=ph2no.length -1;   
    //binita*/
    var str = document.getElementById(0).value ;


    var result = '';
    var login = document.getElementById(20).value;
    var pwd = document.getElementById(1).value;
    var fname = document.getElementById(3).value;
    var lname = document.getElementById(4).value;
    var company = document.getElementById(5).value;
    var city = document.getElementById(9).value;
    var zip = document.getElementById(11).value;
    var fax = document.getElementById(13).value;
    //var ph2 = document.getElementById(66).value;
    var ext = document.billform.phoneExtension.value;
    var website = document.billform.webSiteAddress.value;

    var validchars = "abcdefghijklmnopqrstuvwxyz0123456789._@";
    var validcitychars = "abcdefghijklmnopqrstuvwxyz0123456789._- ";
    var numchars = "0123456789";
    var validExt = "0123456789.()- ";
    var validweb = "abcdefghijklmnopqrstuvwxyz0123456789./- ";
    var fieldFocus=0;
    var fieldName='';

    for( i=0;i<phno.length;i++ )
    {
        var chr =phno.charAt(i);
        if( parseInt(chr) != chr)
        {
            totallength--;
        }
    }


    for( y=0;y<faxno.length;y++ )
    {
        var chr =faxno.charAt(y);
        if( parseInt(chr) != chr)
        {
            faxtotallength--;
        }
    }
    if( str != '' )
    {
        var check1=str.lastIndexOf("@");
        var check2=str.indexOf(".",check1);
        var check3=check2-check1;
        var check4=str.indexOf("@",0);
    }

    if( trim(document.getElementById(20).value)=='' )
    {
        if( result == '' )
        
        {
            fieldFocus=20;
            result = 'Please enter/select valid information for following field(s):';
        }

        //document.billform.login.focus();
        result += '\n Login Id';
    }
    else
    {
        if( document.getElementById(20).value.length > 35 ) 
        {
            if( result == '' )
            
            {
                fieldFocus=20;
                result += 'Please enter/select valid information for following field(s):';
            }

            document.billform.login.value = '';
            //document.billform.login.focus();

            result +='\n Invalid Login id, length exceeded';
        }
    }

    if( trim(document.getElementById(1).value) =='') 
    {
        if( result == '' )
        {
            fieldFocus=1;
            result = 'Please enter/select valid information for following field(s):';
        }

        // document.billform.password.focus();
        result+= '\n Password' ;
    }
    else
    {
        if( document.getElementById(1).value.length > 35 ) 
        {
            if( result == '' )
            {
                fieldFocus=1;
                result += 'Please enter/select valid information for following field(s):';
            }

            document.billform.password.value = '';
            // document.billform.password.focus();
            result +='\n Invalid Password, length exceeded';
        }
    }

    if( trim(document.getElementById(2).value ) =='' ) 
    {
        if( result == '' )
        {
            fieldFocus=2;
            result = 'Please enter/select valid information for following field(s):';
        }

        //document.billform.confirmPassword.focus();
        result+= '\n Confirm Password' ;
    }
    else
    {
        if( document.getElementById(2).value != document.getElementById(1).value ) 
        {
            if( result == '' )
            {
                fieldFocus=2;
                result += 'Please enter/select valid information for following field(s):';
            }

            document.billform.confirmPassword.value = '';
            //document.billform.confirmPassword.focus();
    
            result +='\n Password and Confirm Password must be same.';
        }
    }

    if( trim(document.getElementById(3).value)=='') 
    {
        if( result == '' )
        {
            fieldFocus=3;
            result = 'Please enter/select valid information for following field(s):';
        }

        // document.billform.firstName.focus();
        result+= '\n First Name' ;
    }
    else
    {
        if( document.getElementById(3).value.length > 35 ) 
        {
            if( result == '' )
            {
                fieldFocus=3;
                result += 'Please enter/select valid information for following field(s):';
            }
    
            document.billform.firstName.value = '';
            //document.billform.firstName.focus();

            result +='\n Invalid First Name, length exceeded';
        }

    }                 

    if( trim(document.getElementById(4).value)=='') 
    {
        if( result == '' )
        {
            fieldFocus=4;
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Last Name' ;
    }
    else
    {
        if( document.getElementById(4).value.length > 35 ) 
        {
            if( result == '' )
            {
                fieldFocus=4;
                result += 'Please enter/select valid information for following field(s):';
            }
            document.billform.lastName.value = '';
            result +='\n Invalid Last Name, length exceeded';
        }
    }                 


    if(document.getElementById(0).value=='') 
    {
        if( result == '' )
        {
            fieldFocus=0;
            result = 'Please enter/select valid information for following field(s):';
        }
        result += '\n Email Id';
    }
    else
    {
        if(! ( check1 >= 1 && check2 > 1 && check3 > 1 &&  str.length!=check2+1 ) )
        {
            if( result == '' )
            {
                fieldFocus=0;
                result += 'Please enter/select valid information for following field(s):';
            }

            document.billform.email.value = '';
            result +='\n Invalid email address.';
        }
    }
    if(document.billform.title.value =='Select') 
    {
        if( result == '' )
        {
            fieldFocus=6;
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Title' ;
    }

    if(document.billform.department.value=='Select') 
    {
        if( result == '' )
        {
            fieldFocus=7;
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Department' ;
    }

    if(trim(document.getElementById(8).value) =='') 
    {
        if( result == '' )
        {
            fieldFocus=8;
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Address' ;
    }
    else
    {
        if( document.getElementById(8).value.length > 255 ) 
        {
            if( result == '' )
            {
                fieldFocus=8;
                result += 'Please enter/select valid information for following field(s):';
            }

            document.billform.address1.value = '';
            result +='\n Invalid Address Line1, length exceeded';
        }
    }                 

    if( document.getElementById(21).value.length > 255 ) 
    {
        if( result == '' )
        {
            result += 'Please enter/select valid information for following field(s):';
        }

        document.billform.address2.value = '';
        result +='\n Invalid Address Line2, length exceeded';
    }

    if(trim(document.getElementById(9).value) =='') 
    {
        if( result == '' )
        {
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n City' ;
    }
    else
    {
        if( document.getElementById(9).value.length > 30 ) 
        {
            if( result == '' )
            {
                result += 'Please enter/select valid information for following field(s):';
            }
            document.billform.city.value = '';
            result +='\n Invalid City Name, length exceeded';
        }
    } 
	
    if(document.billform.country.value=='Select Country') 
    {
        if( result == '' )
        {    
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Country' ;
    }

    if(trim(document.billform.zipcode.value) =='') 
    {
        if( result == '' )
        {  
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Zip' ;
    }
    else
    {
        if( document.billform.zipcode.value.length > 10 ) 
        {
            if( result == '' )
            {
                result += 'Please enter/select valid information for following field(s):';
            }
    
            document.billform.zipcode.value = '';
            //document.billform.zipcode.focus();
            result +='\n Invalid Zipcode, length exceeded';
        }

        for (var i=0; i < zip.length; i++) 
        {
            var letter = zip.charAt(i).toLowerCase();
            if (validweb.indexOf(letter) != -1)
                continue;
    
            if( result == '' )
            {
                fieldFocus=11;
                result += 'Please enter/select valid information for following field(s):';
            }
    
            document.billform.zipcode.value = '';
            result +='\n Invalid Zipcode, special characters are  not allowed';
            break;
        }

        // Zip Validation for USA
        if(document.billform.country.value=='USA') {
            validZipChars =  "0123456789-";
            for (var i=0; i < zip.length; i++)
            {
                var letter = zip.charAt(i).toLowerCase();

                if(letter == '-' && i != 5){
                    if( result == '' )
                    {
                        fieldFocus=11;
                        result += 'Please enter/select valid information for following field(s):';
                    }
			
                    document.billform.zipcode.value = '';
                    // document.billform.zipcode.focus();
                    result +='\n Invalid Zipcode';
                    break;
                }

                if(letter != '-' && i == 5){
                    if( result == '' )
                    {
                        fieldFocus=11;
                        result += 'Please enter/select valid information for following field(s):';
                    }
			
                    document.billform.zipcode.value = '';
                    // document.billform.zipcode.focus();
                    result +='\n Invalid Zipcode';
                    break;
                }


                if (validZipChars.indexOf(letter) != -1)
                    continue;
			
                if( result == '' )
                {
                    fieldFocus=11;
                    result += 'Please enter/select valid information for following field(s):';
                }
			
                document.billform.zipcode.value = '';
                // document.billform.zipcode.focus();
                result +='\n Invalid Zipcode, special characters are  not allowed';
                break;
            }

        }

    // end of zip validation for USA

    }

    if(document.getElementById(12).value=='') 
    {
        if( result == '' )
        {
            fieldFocus=12;
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Phone Number' ;
    }
    else
    {
        if( (strtindexofclbrk==0) || (strtindexofbar==0) || (strtindexofspc==0) || (lastindexofbar==phonelength) || (lastindexofspc==phonelength) || (lastindexofopbrk==phonelength) || (totallength<10) || ( strtindexofopbrk+1==strtindexofclbrk) )
        {
            if(result=='')
            {
                fieldFocus=12;
                result = 'Please enter/select valid information for following field(s):';
            }

            document.billform.phoneNumber.value = '';
            result+= '\n Invalid Phone Number';
        }

        for (var i=0; i < document.getElementById(12).value.length; i++) 
        {
            var letter = (document.getElementById(12).value).charAt(i).toLowerCase();
            if (validExt.indexOf(letter) != -1)
                continue;
            if( result == '' )
            {
                fieldFocus=12;
                result += 'Please enter/select valid information for following field(s):';
            }

            document.billform.phoneNumber.value = '';
            //document.billform.phoneNumber.focus();

            result +='\n Phone Number should be numeric';
            break;
        }
        
        
    }

    if( document.billform.phoneExtension.value.length > 10 ) 
    {
        if( result == '' )
        {
            result += 'Please enter/select valid information for following field(s):';
        }

        document.billform.phoneExtension.value = '';
        //document.billform.phoneExtension.focus();
        result +='\n Invalid phone extension, length exceeded';
    }

    for (var i=0; i < ext.length; i++) 
    {
        var letter = ext.charAt(i);
        if (validExt.indexOf(letter) != -1)
            continue;
        
        if( result == '' )
        {
            result += 'Please enter/select valid information for following field(s):';
        }
        
        document.billform.phoneExtension.value = '';
        // document.billform.phoneExtension.focus();

        result +='\n Invalid Phone extension';
        break;
    }


    if( document.billform.faxNumber.value.length > 0 )
    {
        if( (fstrtindexofclbrk==0) || (fstrtindexofbar==0) || (fstrtindexofspc==0) || (flastindexofbar==faxlength) || (flastindexofspc==faxlength) || (flastindexofopbrk==faxlength) || (faxtotallength<10) || ( fstrtindexofopbrk+1==fstrtindexofclbrk) )
        {
            if(result=='')
            {
                fieldFocus=13;
                result = 'Please enter/select valid information for following field(s):';
            }

            document.billform.faxNumber.value = '';
            //  document.billform.faxNumber.focus();
            result+= '\n Invalid Fax Number';
        }

        for (var i=0; i < document.billform.faxNumber.value.length; i++) 
        {
            var letter = (document.billform.faxNumber.value).charAt(i).toLowerCase();
            if (validExt.indexOf(letter) != -1)
                continue;
            if( result == '' )
            {
                fieldFocus=13;
                result += 'Please enter/select valid information for following field(s):';
            }

            document.billform.faxNumber.value = '';
            //document.billform.faxNumber.focus();

            result +='\n Fax Number should be numeric';
            break;
        }


    }                       

    if( document.billform.webSiteAddress.value.length > 0 )
    {
        for (var i=0; i < website.length; i++) 
        {
            var letter = website.charAt(i);

            if (validweb.indexOf(letter) != -1)
                continue;

            if( result == '' )
            {
                fieldFocus=44;
                result += 'Please enter/select valid information for following field(s):';
            }
            
            document.billform.webSiteAddress.value = '';
            //document.billform.webSiteAddress.focus();

            result +='\n Invalid Web site address';
            break;
        }

        if( document.billform.webSiteAddress.value.length > 255 ) 
        {
            if( result == '' )
            {
                fieldFocus=44;
                result += 'Please enter/select valid information for following field(s):';
            }
            document.billform.webSiteAddress.value = '';
            result +='\n Invalid Web site address, length exceeded';
        }
    }                       
    if(document.billform.businessType.value=='Select')
    {
        if( result == '' )
        {   
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Business Type ' ;
    }

    if(document.billform.businessType.value=='33')
    {
        if(document.billform.businessTypeOther.value =='')
        {
            if(result=='')
            {  
                result = 'Please enter/select valid information for following field(s):';
            }
            result+= '\n Specify type of business in other box';
        }                           
    }


    if(document.billform.promotionalPurchases.value=='Select')
    {
        if( result == '' )
        {   
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Promotional Purchases ' ;
    }

    if(document.billform.numberOfEmployees.value=='Select') 
    {
        if( result == '' )
        {   
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Number of Employees';
    }


    if(document.billform.source.value=='')
    {
        if( result == '' )
        {
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n How did you hear about us?';
    }
    if(document.billform.source.selectedIndex==7)
    {
        if(trim(document.billform.referralName.value)=='')
        {
            if( result == '' )
            {
                result = 'Please enter/select valid information for following field(s):';
            }
            result+= '\n Referral Name?';
        }
    }
    if(document.billform.source.selectedIndex==8)
    {
        if(trim(document.billform.salesPersonName.value)=='')
        {
            if( result == '' )
            {
                result = 'Please enter/select valid information for following field(s):';
            }
            result+= '\n Sales Person Name';
        }
    }

    
    

    if (result == '')
    {   
        document.billform.action="/signup.do";
        document.billform.submit();
    }
    else
    {
        alert ( result );
    }
}
        
        
function changeBox(cbox) 
{
    box = eval(cbox);
    box.checked = !box.checked;
}
 

function IsNumeric(sText)
{
    var ValidChars = "0123456789.";
    var IsNumber=true;
    var Char;

    for (i = 0; i < sText.length && IsNumber == true; i++) 
    { 
        Char = sText.charAt(i); 
        if (ValidChars.indexOf(Char) == -1) 
        {
            IsNumber = false;
        }
    }

    return IsNumber;
}
function IsInt(sText)
{
    var ValidChars = "0123456789";
    var IsNumber=true;
    var Char;

    for (i = 0; i < sText.length && IsNumber == true; i++) 
    { 
        Char = sText.charAt(i); 
        if (ValidChars.indexOf(Char) == -1) 
        {
            IsNumber = false;
        }
    }

    return IsNumber;
}

function fnChekInt(obj)
{
    var ValidChars = "0123456789";
    var IsNumber=true;
    var Char;
    var sText=obj.value
   

    for (i = 0; i < sText.length && IsNumber == true; i++) 
    { 
        Char = sText.charAt(i); 
        if (ValidChars.indexOf(Char) == -1) 
        {
            IsNumber = false;
        }
    }

    if(IsNumber==false){
        alert("Please enter integer only!");
        obj.value=''
        obj.focus();
        return false;
    }
}


// Sample Page Javascript function Starts



function valButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {
            cnt = i; i = -1;
        }
    }
    if (cnt > -1)
        return btn[cnt].value;
    else
        return null;
}

function selectedBudget()
{
    if(document.requestform.selectRange.selectedIndex>0)
    {
        document.requestform.budgetRange.value = document.requestform.selectRange.options[document.requestform.selectRange.selectedIndex].value;
    }
}

function validateSample(request)
{
    ab = document.getElementById(1).value ;
    var result='';
    var focus=0;
    var shipId=document.requestform.shippingAddressId;
    var sizeOfcolor=eval(document.requestform.colorSize.value);
    
    charges();
    
    
    if(document.requestform.colorChoice3)
    {
        //alert(document.requestform.colorChoice3.options[document.requestform.colorChoice3.selectedIndex].value);
        document.requestform.supplierId.value=document.requestform.colorChoice3.options[document.requestform.colorChoice3.selectedIndex].value;
    }
    
    if(document.requestform.colorChoice3!=null)
    {
        if(document.requestform.colorChoice3.selectedIndex ==0)
        {
            if(result=='')
            {
                focus=-3;
                result=' Please enter valid information in following field(s):';
            }
            result+= '\n  supplier.'
        }
    }
    
    if(document.requestform.supplierSKU!=null)
    {
        if(document.requestform.supplierSKU.value ==''|| document.requestform.supplierSKU.value == null)
        {
            if(result=='')
            {
                focus=-1;
                result=' Please enter valid information in following field(s):';
            }
            result+= '\n  supplierSKU.'
        }
    }
    if(document.requestform.supplierSKUName != null)
    {
        if(document.requestform.supplierSKUName.value == '' || document.requestform.supplierSKUName.value == null)
        {
            if(result=='')
            {
                focus=-2;
                result=' Please enter valid information in following field(s):';
            }
            result+= '\n  supplier SKU Name.'
        }
    }
    
    
    // alert(sizeOfcolor +"DDDDDD    "+document.requestform.colorChoice.value);
    if( sizeOfcolor>0 && trim(document.requestform.colorChoice.value)=='NA' )
    {
        if(result=='')
        {
            focus=1;
            result=' Please enter valid information in following field(s):';
        }
    
        //document.requestform.colorChoice.focus();
        result+= '\n  Color Choice' ;
    }
     
	
    
    if(trim(document.requestform.shipping.value != 'UPS Ground'))
    {
        if(trim(document.requestform.accountNumber.value) == '')
        {
            if(result=='')
            {
                focus=6;
                result='Please enter valid information in following field(s):';
            }
    
            // document.requestform.accountNumber.focus();
            result+= '\n  Shipping account number ';
        }
        else
        {
            if( trim(document.requestform.accountNumber.value.length) > 50 )
            {
                if( result == '' )
                {
                    focus=6;
                    result += 'Please enter/select valid information for following field(s):';
                }
                    
                document.requestform.accountNumber.value='';
                // document.requestform.accountNumber.focus();
                result +='\n Shipping account number, length exceeded';
            }
        }
    }
    if(document.requestform.colorChoice2)
    {
        if(document.requestform.colorChoice2.selectedIndex!=0)
        {
            document.requestform.wishlistId.value=document.requestform.colorChoice2.options[document.requestform.colorChoice2.selectedIndex].value;
        }
    }
   
       
    
    var qty =  document.requestform.wishlistQuantity.value
    
    if(trim(qty) == '' || isNaN(qty) || qty.indexOf('.') != -1 || trim(qty) <= 0){
        	
        if(result=='')
        {
            focus=9;
    	    	            
            result=' Please enter valid information in following field(s):';
        }
        result +='\n  valid number of items.';
    		
    }
	
	
	
    if(document.requestform.wishlistNew.value=="false" )
    {
	           		     	
        if(document.requestform.colorChoice2)
        {
            if(document.requestform.colorChoice2.selectedIndex==0)
            {
                if(result=='')
                {
                    result=' Please enter valid information in following field(s):';
                }
                result +='\n  wishlist name.';
            }
        }
        else
        {
            if(result=='')
            {
                result=' Please enter valid information in following field(s):';
            }
            result +='\n  create New wishlist.';
        }
	       	
	                           
	             		        	   
    }
	    
    //  alert("wishlist new  *********"+document.requestform.wishlistNew.value)
    if(document.requestform.wishlistNew.value=="true")
    {
        var wishName = trim(document.requestform.wishlistName.value)
        var eventDate = document.requestform.eventDate.value
        var budgetRange = document.requestform.budgetRange.value
    	
        wishlistCount =myArray.length
        var wishName = trim(document.requestform.wishlistName.value)
        var wishlistString
        var wishlistSpilt
        var flag = false;
	    	     
        for(i=0;i<myArray.length;i++)
        {
            wishlistString = myArray[i]
            wishlistSpilt = wishlistString.split(":");
	    	     
            if(wishName == wishlistSpilt[1])
            {
                flag =true;
                break;
	    	       
            }
        }
    
    	
        if(flag)
        {
            if(result=='')
            {
            {
                focus=8;
		
                result=' Please enter valid information in following field(s):';
            }
            result +='\n  wishlist name already exist.';
            }
        }
		     
	    
	    	
        if(wishName == ''){
	    	
            if(result=='')
            {
                focus=8;
			 		            
                result=' Please enter valid information in following field(s):';
            }
            result +='\n  wishlist name.';
	    		
	    		
        }
    	
    	
        if(document.requestform.selectRange.selectedIndex==0){
            //alert("hellooooooooooooooooooooooo");
            if(result=='')
            {
                focus=10;
		    	            
                result=' Please enter valid information in following field(s):';
            }
            result +='\n  your total expected Budget.';
			
        }
    }
	
    	
    	
	
   
    if(result=='')
    {
        if(document.requestform.wishlistNew.value=="true")
        {
            if(ValidateDate('eventDate') == true){
                document.requestform.action="/SampleCreated.do";
                document.requestform.submit();
            }
        }
        else
        {
            //  alert("wishlist id **********"+document.requestform.wishlistId.value)
            document.requestform.action="/SampleCreated.do";
            document.requestform.submit();
        }

		
		
		
		
    }
    else
    {
        alert(result);

    }
}

function validateSampleAddress(user){

    // alert(user)
    
    var phno =document.getElementById(11).value;
    var i;
    var totallength=phno.length;
    var result='';
    var strtindexofopbrk=phno.indexOf("(",0);
    var strtindexofclbrk=phno.indexOf(")",0);
    var strtindexofbar=phno.indexOf("-",0);
    var strtindexofspc=phno.indexOf(" ",0);
    var lastindexofbar=phno.lastIndexOf("-");
    var lastindexofopbrk=phno.lastIndexOf("(");
    var lastindexofclbrk=phno.lastIndexOf(")");
    var lastindexofspc=phno.lastIndexOf(" ");
    var phonelength=phno.length -1;

    var locat= document.getElementById(1).value;
    var fname=  document.getElementById(2).value;
    var lname= document.getElementById(3).value;
    var company = document.getElementById(4).value;
    var city = document.getElementById(7).value;
    var zip = document.getElementById(10).value;
        
    var ext = document.getElementById(12).value;
    
    var validchars = "abcdefghijklmnopqrstuvwxyz0123456789._@";
    var validcitychars = "abcdefghijklmnopqrstuvwxyz0123456789._- ";
    var numchars = "0123456789";
    var validExt = "0123456789.()- ";
    var validweb = "abcdefghijklmnopqrstuvwxyz0123456789./- ";
    for( i=0;i<phno.length;i++ )
    {
        var chr =phno.charAt(i);
        if( parseInt(chr) != chr)
        {
            totallength--;
        }
    }
       
    addressCount = nameAddressArray.length
    var addressAlready;
    var flag = false;
    var locationName = trim(document.getElementById(1).value);
    for(i=0;i<addressCount;i++)
    {
        addressAlready = trim(nameAddressArray[i]);
        if(locationName == addressAlready)
        {
            flag =true;
            break;
        }
    }
    if(flag)
    {
        if(result=='')
        {
        {
            focusId=1;
            result=' Please enter valid information in following field(s):';
        }
        result +='\n  Location name already exist.';
        }
    }
		       
    if(locationName == '')
    {
        if( result == '' )
        {
            focusId=1;
            result = 'Please enter/select valid information for following field(s):';
        }
	        
	       
        result+= '\n Location' ;
    }
	
	
	
	
	
	
    if(trim(document.getElementById(2).value)=='')
    {
        if( result == '' )
        {
            focusId=2;
            result = 'Please enter/select valid information for following field(s):';
        }
	        
	       
        result+= '\n First Name' ;
    }

    if(trim(document.getElementById(3).value)=='')
    {
        if( result == '' )
        {
            focusId=3;
            result = 'Please enter/select valid information for following field(s):';
        }
	        
	       
        result+= '\n Last Name' ;
    }
         
    if(trim(document.getElementById(5).value) =='')
    {
        if( result == '' )
        {
            focusId=5;
            result = 'Please enter/select valid information for following field(s):';
        }
	        
	      
        result+= '\n Address' ;
    }

      

    if(trim(document.getElementById(7).value) =='')
    {
        if( result == '' )
        {
            focusId=7;
            result = 'Please enter/select valid information for following field(s):';
        }
	        
	      
        result+= '\n City' ;
    }
    else
    {
        if( document.getElementById(7).value.length > 30 )
        {
            if( result == '' )
            {
                focusId=7;
                result += 'Please enter/select valid information for following field(s):';
            }
	    
            document.addressForm.city.value = '';
	        
	
            result +='\n Invalid City Name, length exceeded';
        }
    }
		

    if(document.addressForm.country.value=='Select Country')
    {
        if( result == '' )
        {
            focusId=9;
            result = 'Please enter/select valid information for following field(s):';
        }
	        
	      
        result+= '\n Country' ;
    }

    if(trim(document.getElementById(10).value) =='')
    {
        if( result == '' )
        {
            focusId=10;
            result = 'Please enter/select valid information for following field(s):';
        }
	
	      
        result+= '\n Zip' ;
    }
    else
    {
        if( document.getElementById(10).value.length > 10 )
        {
            if( result == '' )
            {
                focusId=10;
                result += 'Please enter/select valid information for following field(s):';
            }
	    
            document.addressForm.zip.value = '';
	           
            result +='\n Invalid Zipcode, length exceeded';
        }
	
        for (var i=0; i < zip.length; i++)
        {
            var letter = zip.charAt(i).toLowerCase();
            if (validweb.indexOf(letter) != -1)
                continue;
	    
            if( result == '' )
            {
                focusId=10;
                result += 'Please enter/select valid information for following field(s):';
            }
	    
            document.addressForm.zip.value = '';
	           
            result +='\n Invalid Zipcode, special characters are  not allowed - 1 ';
            break;
        }

        // Zip Validation for USA
        if(document.addressForm.country.value=='USA') {         

            validZipChars =  "0123456789-";
            for (var i=0; i < zip.length; i++)
            {
                var letter = zip.charAt(i).toLowerCase();

                if(letter == '-' && i != 5){
                    if( result == '' )
                    {
                        focusId=10;
                        result += 'Please enter/select valid information for following field(s):';
                    }
			
                    document.addressForm.zip.value = '';
                    // document.billform.zipcode.focus();
                    result +='\n Invalid Zipcode';
                    break;
                }

					
                if(letter != '-' && i == 5){
                    if( result == '' )
                    {
                        focusId=10;
                        result += 'Please enter/select valid information for following field(s):';
                    }
			
                    document.addressForm.zip.value = '';
                    // document.billform.zipcode.focus();
                    result +='\n Invalid Zipcode';
                    break;
                }



                if (validZipChars.indexOf(letter) != -1)
                    continue;
			
                if( result == '' )
                {
                    focusId=10;
                    result += 'Please enter/select valid information for following field(s):';
                }
			
                document.addressForm.zip.value = '';
                // document.addressForm.zip.focus();
                result +='\n Invalid Zipcode, special characters are  not allowed - 2';
                break;
            }

        }   //  zip validation for USA
        

	
    }
	
    if(document.getElementById(11).value=='')
    {
        if( result == '' )
        {
            focusId=11;
            result = 'Please enter/select valid information for following field(s):';
        }
	 
	      
        result+= '\n Phone Number' ;
    }
    else
    {
        if( (strtindexofclbrk==0) || (strtindexofbar==0) || (strtindexofspc==0) || (lastindexofbar==phonelength) || (lastindexofspc==phonelength) || (lastindexofopbrk==phonelength) || (totallength<10) || ( strtindexofopbrk+1==strtindexofclbrk) )
        {
            if(result=='')
            {
                focusId=11;
                result = 'Please enter/select valid information for following field(s):';
            }
	
            document.addressForm.phoneNumber.value = '';
	           
            result+= '\n Invalid Phone Number';
	
        }
	
        for (var i=0; i < document.getElementById(11).value.length; i++)
        {
            var letter = (document.getElementById(11).value).charAt(i).toLowerCase();
            if (validExt.indexOf(letter) != -1)
                continue;
            if( result == '' )
            {
                focusId=11;
                result += 'Please enter/select valid information for following field(s):';
            }
            document.addressForm.phoneNumber.value = '';
            result +='\n Phone Number should be numeric';
            break;
        }
    }

    //Validate State
    if(document.addressForm.country.value=='USA') {

        //State
        if(trim(document.getElementById(8).value) =='Select')
        {
            if( result == '' )
            {
                result = 'Please enter/select valid information for following field(s):';
            }
            result+= '\n State' ;
        }
    }
    else if (document.addressForm.country.value=='CANADA') {
        if(trim(document.getElementById(8).value) =='Select')
        {
            if( result == '' )
            {
                result = 'Please enter/select valid information for following field(s):';
            }
            result+= '\n State' ;
        }
    } else {
        if(trim(document.getElementById(999).value) =='')
        {
            if( result == '' )
            {
                result = 'Please enter/select valid information for following field(s):';
            }
            result+= '\n State' ;
        }
    }



    if( document.getElementById(12).value.length > 10 )
    {
        if( result == '' )
        {
            focusId=12;
            result += 'Please enter/select valid information for following field(s):';
        }
	
        document.addressForm.phoneExt.value = '';
	       
        result +='\n Invalid phone extension, length exceeded';
    }
    for (var i=0; i < ext.length; i++)
    {
        var letter = ext.charAt(i);
        if (validExt.indexOf(letter) != -1)
            continue;
        if( result == '' )
        {
            focusId=12;
            result += 'Please enter/select valid information for following field(s):';
        }
        document.addressForm.phoneExt.value = '';
        result +='\n Invalid Phone extension';
        break;
    }
    if(result=='')
    {
        document.addressForm.opType.value='save'
        document.addressForm.action="/SampleAddressUpdate.do"
        document.addressForm.submit();
    }
    else
    {
        alert(result);
        if(focusId!=0){
            document.getElementById(focusId).focus();
        }
    }
}


function AddDate()
{
    if (document.requestform.eventDate.value != '')
    {
        var dt = new Date(document.requestform.eventDate.value );
        dt.setDate(dt.getDate() + 14);
        var curr_date = dt.getDate();
        var curr_month = dt.getMonth();
        curr_month++;
        var curr_year = dt.getFullYear();
        reminderDate = curr_month + "/" + curr_date + "/" + curr_year;
        document.requestform.wishlistReminderDate.value = reminderDate;
    }
}
// End Sample Page Javascript                          

function checkPwd()
{
    var pwd = trim(document.newPassword.newPwd.value);
    var result ='';
    var focusId=0;
    
    //Check password
    if(pwd =='')
    {
        if( result == '' )
        {
            focusId=1;
            result = 'Please enter/select valid information for following field(s):';
        }

        //document.newPassword.newPwd.focus();
        result += '\n Password';
    }
    else
    {
        if( pwd.length > 35 )
        {
            if( result == '' )
            {
                focusId=1;
                result += 'Please enter/select valid information for following field(s):';
            }
            
            document.newPassword.newPwd.value = '';
            //document.newPassword.newPwd.focus();

            result +='\n Invalid Password, length exceeded';
        }

       
    }
    
    if( trim(document.getElementById(2).value) != trim(document.getElementById(1).value) ) 
    {
        if( result == '' )
        {
            focusId=2;
            result = 'Please enter/select valid information for following field(s):';
        }
    
        //document.newPassword.newPwd.value = '';
        //document.newPassword.newPwd.focus();
        result += '\n Password and Confirm Password must be same.';
    }


    if (result=='' )
    {
        return true;
    }
    else
    {
        alert(result);
        if(focusId!=0){
            document.getElementById(focusId).value='';
            document.getElementById(focusId).focus();
            return false;
        }
    }

}
        
function totalQuantity(sizeBox)
{  
    sum = 0;
    maxSizeQty = document.order.productSizeLen.value;

    if(IsInt(sizeBox.value))
    {

        if((sizeBox.value.length) > 9)
        {
            alert('Invalid Quantity, length exceeded');
            sizeBox.value = 0;
        }
        else{
            for(var iterator = 0; iterator < maxSizeQty; iterator++)
            {
                if(document.order.elements["prodSizeQuantity"+iterator].value == ''){
                    document.order.elements["prodSizeQuantity"+iterator].value = '0';

                }
                sum = sum + parseInt(document.order.elements["prodSizeQuantity"+iterator].value,10);
            }
            if(sum > 999999999)
            {
                alert('Invalid Quantity, length exceeded');
                sizeBox.value = 0;
            }
            else{
                document.order.totQuantityTemp.value=sum;
            }
        }
    }
    else
    {
        alert('Quantity should be integer');
        sizeBox.value = 0;
        for(var iterator = 0; iterator < maxSizeQty; iterator++)
        {
            if(document.order.elements["prodSizeQuantity"+iterator].value == ''){
                document.order.elements["prodSizeQuantity"+iterator].value = '0';
            }
            // alert(sum);
            sum = sum + parseInt(document.order.elements["prodSizeQuantity"+iterator].value,10);
            document.order.totQuantityTemp.value=sum;
        }
        sizeBox.focus();
        return false;

    }


}


function check_radio(f)
{
    var i;
    var result='';
    var focus=0;
    var ok = false;
    var logo = f.logosubmit;
    var shipId=f.shippingAddressId
    var maxSizeQty = document.order.productSizeLen.value;
        
    
    
    if(maxSizeQty == 0)
    {
        var quant=trim(document.order.quantity.value)
          
        if(quant== ''|| quant=='0')
        {
            if (result=='' )
                
            {
                focus=1;
                result= 'Please provide information about\n';
            }
    
            document.order.quantity.value = '';
            //document.order.quantity.focus();
            result+= '\n Quantity';
        }
        else
        {
            if(!IsNumeric(document.order.quantity.value))
            {
                if (result=='' )
                {
                    focus=1;
                    result= 'Please provide information about\n';
                }
    
                document.order.quantity.value = '';
                //document.order.quantity.focus();
                result+= '\n Quantity should be numeric';
            }
    
            if((document.order.quantity.value.length) > 9)
            {
    
    		  
                if (result=='' )
                {
                    focus=1;
                    result= 'Please provide information about\n';
                }
    
                result+= '\n Invalid Quantity, length exceeded';
            }
        }
    }
    else
    {
        if(document.order.totQuantityTemp.value == '0')
        {
            if (result=='' )
            {
                focus=2;
                result= 'Please provide information about\n';
            }
    
            result+= '\n Total Quantity';
        }
    	
    }


    for (i = 0; i < logo.length; i++)
    {
        if (logo[i].checked)
        {
            ok = true;
            break;
        }
    }

    if (!ok)
    {
        if (result=='' )
        {
            result= 'Please provide information about\n';
        }

        result+= '\n Your Method of submitting your logo';

    }

	


    ok = false;
    var pay = f.payment;

    for (i = 0; i < pay.length; i++)
    {
        if (pay[i].checked)
        {
            ok = true;
            break;
        }
    }

    if (!ok)
    {
        if (result=='' )
        {
            result= 'Please provide information about\n';
        }

        result+= '\n Your Payment mode';

    }



    
    if (result=='' )
    {
        if(maxSizeQty > 0 )
            document.order.totQuantity.value = document.order.totQuantityTemp.value;
        if(ValidateDate('eventDate') == true){
			   
            return confirmOrder();
        }else{
            return false;
        }
    }
    else
    {
        alert(result);
        if(focus==1)
            document.order.quantity.focus();
        return false;
       
    }
}


function resetPassValidation()
{
    var login = document.getElementById("loginId").value;
    var email = document.getElementById("emailAdd").value;
    var result='';

    //Check loginId\
    if (login =='' && email =='') {
       if( result == '' ) {
            result = 'Please fill out one of the forms below.';
        }
    } else {
        if (login != '') {
            if( login.length > 35 ) {
                if( result == '' ) {
                    result += 'Please enter/select valid information for following field(s):';
                }

                result +='\n Invalid Login id, length exceeded';
            }
        } else if  (email != '') {
            // may have check here
        }
    }

    if(result == '' && login != '')
    {
        document.resetPassword.action="/resetPwd.do";
        document.resetPassword.submit();
    } else if (result == '' && email != '') {
        document.resetUserName.action="/resetPwd.do";
        document.resetUserName.submit();
    }
    else
    {
        alert(result);
    }
}


function showEmail()
{
    if(document.emailFriend.emailToFriend.checked==true)
    {
        document.emailFriend.emailAddress.style.visibility="visible";
        document.emailFriend.doEmail.style.visibility="visible";
    }
    else
    {
        document.emailFriend.emailAddress.style.visibility="hidden";
        document.emailFriend.doEmail.style.visibility="hidden";
    }
}

function mailToFriend()
{
    productId = document.emailFriend.productId.value;
    emailAdd = document.emailFriend.emailAddress.value;
    var result='';

    if( emailAdd != '' )
    {
        var check1=emailAdd.lastIndexOf("@");
        var check2=emailAdd.indexOf(".",check1);
        var check3=check2-check1;
        var check4=emailAdd.indexOf("@",0);
    }

    if(emailAdd=='') 
    {
        if( result == '' )
        {
            result = 'Please enter/select valid information for following field(s):';
        }
   
        result += '\n Email Id';
    }
    else
    {
        if(! ( check1 >= 1 && check2 > 1 && check3 > 1 &&  emailAdd.length!=check2+1 ) )
        {
            if( result == '' )
            {
                result += 'Please enter/select valid information for following field(s):';
            }

            document.emailFriend.emailAddress.value = '';

            result +='\n Invalid email address.';
        }
    }


    if(result == '')
    {
        document.emailFriend.action="/OrderPipeline/emailToFriend.jsp?productId="+productId+"&friendEmail="+emailAdd;
        document.emailFriend.submit();
    }
    else
    {
        alert(result);
    }

}

function validateUserProfile(user){
    //alert("inside validate user");
    var fname = document.getElementById(2).value;
    var lname = document.getElementById(3).value;
    var email = document.getElementById(4).value ;
    var validchars = "abcdefghijklmnopqrstuvwxyz0123456789._@";
    var validcitychars = "abcdefghijklmnopqrstuvwxyz0123456789._- ";
    var numchars = "0123456789";
    var validExt = "0123456789.()- ";
    var result='';
    var focusId=0;
    if( email != '' )
    {
        var check1=email.lastIndexOf("@");
        var check2=email.indexOf(".",check1);
        var check3=check2-check1;
        var check4=email.indexOf("@",0);
    }
    if( trim(document.getElementById(2).value)=='') 
    {
        if( result == '' )
        {
            focusId=2;
            result = 'Please enter/select valid information for following field(s):';
        }
    
        // document.userUpdateFrm.firstName.focus();
        result+= '\n First Name' ;
    }
    else
    {
        if( document.getElementById(2).value.length > 35 )
        {
            if( result == '' )
            {
                focusId=2;
                result += 'Please enter/select valid information for following field(s):';
            }
        
            document.getElementById(2).value = '';
            //document.userUpdateFrm.firstName.focus();
    
            result +='\n Invalid First Name, length exceeded';
        }
    

    }
    
    if( trim(document.getElementById(3).value)=='')
    {
        if( result == '' )
        {
            focusId=3;
            result = 'Please enter/select valid information for following field(s):';
        }
            
        //document.userUpdateFrm.lastName.focus();
        result+= '\n Last Name' ;
    }
    else
    {
        if( document.getElementById(3).value.length > 35 )
        {
            if( result == '' )
            {
                focusId=3;
                result += 'Please enter/select valid information for following field(s):';
            }
    
            document.userUpdateFrm.lastName.value = '';
            // document.userUpdateFrm.lastName.focus();
        
            result +='\n Invalid Last Name, length exceeded';
        }
 
    }
    
    
    if(document.getElementById(4).value=='')
    {
        if( result == '' )
        {
            focusId=4;
            result = 'Please enter/select valid information for following field(s):';
        }
       
        //document.billform.email.focus();
        result += '\n Email Id';
    }
    else
    {
        if(! ( check1 >= 1 && check2 > 1 && check3 > 1 &&  email.length!=check2+1 ) )
        {
            if( result == '' )
            {
                focusId=4;
                result += 'Please enter/select valid information for following field(s):';
            }
    
            document.userUpdateFrm.email.value = '';
            //document.userUpdateFrm.email.focus();
    
            result +='\n Invalid email address.';
        }
    }

    if(document.userUpdateFrm.title.value =='Select')
    {
        if( result == '' )
        {
            result = 'Please enter/select valid information for following field(s):';
        }
	
	       
        result+= '\n Title' ;
    }
	
    if(document.userUpdateFrm.department.value=='Select')
    {
        if( result == '' )
        {
            result = 'Please enter/select valid information for following field(s):';
        }
	
	       
        result+= '\n Department' ;
    }
	
	
    if(result=='')
    {
        if(user == 'rep'){
            document.userUpdateFrm.action="/companyUpdateByRep.do?mode=updateUser";
            document.userUpdateFrm.submit();
        }else{
            document.userUpdateFrm.action="/companyUpdate.do?mode=updateUser";
            document.userUpdateFrm.submit();
        }
    }
    else
    {
        alert(result);
        if(focusId!=0)
            document.getElementById(focusId).focus();
	           
    }
         


}

function validateCompanyProfile(user){

    // alert(user);
    var phno =document.getElementById(12).value;
    var i;
    var totallength=phno.length;
    var result='';
    var strtindexofopbrk=phno.indexOf("(",0);
    var strtindexofclbrk=phno.indexOf(")",0);
    var strtindexofbar=phno.indexOf("-",0);
    var strtindexofspc=phno.indexOf(" ",0);
    var lastindexofbar=phno.lastIndexOf("-");
    var lastindexofopbrk=phno.lastIndexOf("(");
    var lastindexofclbrk=phno.lastIndexOf(")");
    var lastindexofspc=phno.lastIndexOf(" ");
    var phonelength=phno.length -1;

    var faxno =document.getElementById(13).value;
    var y;
    var faxtotallength=faxno.length;
    var fstrtindexofopbrk=faxno.indexOf("(",0);
    var fstrtindexofclbrk=faxno.indexOf(")",0);
    var fstrtindexofbar=faxno.indexOf("-",0);
    var fstrtindexofspc=faxno.indexOf(" ",0);
    var flastindexofbar=faxno.lastIndexOf("-");
    var flastindexofopbrk=faxno.lastIndexOf("(");
    var flastindexofclbrk=faxno.lastIndexOf(")");
    var flastindexofspc=faxno.lastIndexOf(" ");
    var faxlength=faxno.length -1;
    var company = document.getElementById(5).value;
    var city = document.getElementById(9).value;
    var zip = document.getElementById(11).value;
    var fax = document.getElementById(13).value;
    var ext = document.companyUpdateFrm.phoneExtension.value;
    
    var validchars = "abcdefghijklmnopqrstuvwxyz0123456789._@";
    var validcitychars = "abcdefghijklmnopqrstuvwxyz0123456789._- ";
    var numchars = "0123456789";
    var validExt = "0123456789.()- ";
    var validweb = "abcdefghijklmnopqrstuvwxyz0123456789./- ";
    for( i=0;i<phno.length;i++ )
    {
        var chr =phno.charAt(i);
        if( parseInt(chr) != chr)
        {
            totallength--;
        }
    }
    
    
    for( y=0;y<faxno.length;y++ )
    {
        var chr =faxno.charAt(y);
        if( parseInt(chr) != chr)
        {
            faxtotallength--;
        }
    }
        
                
	
	
    if(trim(document.getElementById(8).value) =='')
    {
        if( result == '' )
        {
            focusId=8;
            result = 'Please enter/select valid information for following field(s):';
        }
	        
        //document.companyUpdateFrm.address1.focus();
        result+= '\n Address' ;
    }
    else
    {
        if( document.getElementById(8).value.length > 255 )
        {
            if( result == '' )
            {
                focusId=8;
                result += 'Please enter/select valid information for following field(s):';
            }
	
            document.companyUpdateFrm.address1.value = '';
            //document.companyUpdateFrm.address1.focus();
            result +='\n Invalid Address Line1, length exceeded';
        }
    }
	
	
    if( document.getElementById(21).value.length > 255 )
    {
        if( result == '' )
        {
            focusId=21;
            result += 'Please enter/select valid information for following field(s):';
        }
	
        document.companyUpdateFrm.address2.value = '';
        // document.companyUpdateFrm.address2.focus();
        result +='\n Invalid Address Line2, length exceeded';
    }
	
	
    if(trim(document.getElementById(9).value) =='')
    {
        if( result == '' )
        {
            focusId=9;
            result = 'Please enter/select valid information for following field(s):';
        }
	        
        //document.companyUpdateFrm.city.focus();
	
        result+= '\n City' ;
    }
    else
    {
        if( document.getElementById(9).value.length > 30 )
        {
            if( result == '' )
            {
                focusId=9;
                result += 'Please enter/select valid information for following field(s):';
            }
	    
            document.companyUpdateFrm.city.value = '';
            //  document.companyUpdateFrm.city.focus();
	
            result +='\n Invalid City Name, length exceeded';
        }

    }
	
    if(document.companyUpdateFrm.country.value=='Select Country')
    {
        if( result == '' )
        {
            result = 'Please enter/select valid information for following field(s):';
        }
        // document.companyUpdateFrm.country.focus();
        result+= '\n Country' ;
    }
	 
    if(trim(document.getElementById(11).value) =='')
    {
        if( result == '' )
        {
            focusId=11;
            result = 'Please enter/select valid information for following field(s):';
        }
	
        //document.companyUpdateFrm.zipcode.focus();
        result+= '\n Zip' ;
    }
    else
    {
        if( document.getElementById(11).value.length > 10 )
        {
            if( result == '' )
            {
                focusId=11;
                result += 'Please enter/select valid information for following field(s):';
            }
	    
            document.companyUpdateFrm.zipcode.value = '';
            //document.companyUpdateFrm.zipcode.focus();
            result +='\n Invalid Zipcode, length exceeded';
        }
	
        for (var i=0; i < zip.length; i++)
        {
            var letter = zip.charAt(i).toLowerCase();
            if (validweb.indexOf(letter) != -1)
                continue;
	    
            if( result == '' )
            {
                focusId=11;
                result += 'Please enter/select valid information for following field(s):';
            }
	    
            document.companyUpdateFrm.zipcode.value = '';
            // document.companyUpdateFrm.zipcode.focus();
            result +='\n Invalid Zipcode, special characters are  not allowed';
            break;
        }

        // Zip Validation for USA
        if(document.companyUpdateFrm.country.value=='USA') {
            validZipChars =  "0123456789-";
            for (var i=0; i < zip.length; i++)
            {
                var letter = zip.charAt(i).toLowerCase();

                if(letter == '-' && i != 5){
                    if( result == '' )
                    {
                        focusId=11;
                        result += 'Please enter/select valid information for following field(s):';
                    }
			
                    document.companyUpdateFrm.zipcode.value = '';
                    // document.companyUpdateFrm.zipcode.focus();
                    result +='\n Invalid Zipcode';
                    break;
                }

                if(letter != '-' && i == 5){
                    if( result == '' )
                    {
                        focusId=11;
                        result += 'Please enter/select valid information for following field(s):';
                    }
			
                    document.companyUpdateFrm.zipcode.value = '';
                    // document.companyUpdateFrm.zipcode.focus();
                    result +='\n Invalid Zipcode';
                    break;
                }



                if (validZipChars.indexOf(letter) != -1)
                    continue;
			
                if( result == '' )
                {
                    focusId=11;
                    result += 'Please enter/select valid information for following field(s):';
                }
			
                document.companyUpdateFrm.zipcode.value = '';
                // document.billform.zipcode.focus();
                result +='\n Invalid Zipcode, special characters are  not allowed';
                break;
            }

        }  //  zip validation for USA

	
    }
	
    if(document.getElementById(12).value=='')
    {
        if( result == '' )
        {
            focusId=12;
            result = 'Please enter/select valid information for following field(s):';
        }
	 
        //  document.companyUpdateFrm.phoneNumber.focus();
        result+= '\n Phone Number' ;
    }
    else
    {
        if( (strtindexofclbrk==0) || (strtindexofbar==0) || (strtindexofspc==0) || (lastindexofbar==phonelength) || (lastindexofspc==phonelength) || (lastindexofopbrk==phonelength) || (totallength<10) || ( strtindexofopbrk+1==strtindexofclbrk) )
        {
            if(result=='')
            {
                focusId=12;
                result = 'Please enter/select valid information for following field(s):';
            }
	
            document.companyUpdateFrm.phoneNumber.value = '';
            //document.companyUpdateFrm.phoneNumber.focus();
            result+= '\n Invalid Phone Number';
	
        }
	
        for (var i=0; i < document.getElementById(12).value.length; i++)
        {
            var letter = (document.getElementById(12).value).charAt(i).toLowerCase();
            if (validExt.indexOf(letter) != -1)
                continue;
            if( result == '' )
            {
                focusId=12;
                result += 'Please enter/select valid information for following field(s):';
            }
	
            document.companyUpdateFrm.phoneNumber.value = '';
            //document.companyUpdateFrm.phoneNumber.focus();
	
            result +='\n Phone Number should be numeric';
            break;
        }
	        
	        
    }
	
    if( document.companyUpdateFrm.phoneExtension.value.length > 10 )
    {
        if( result == '' )
        {
            focusId=102;
            result += 'Please enter/select valid information for following field(s):';
        }
	
        document.companyUpdateFrm.phoneExtension.value = '';
        //document.companyUpdateFrm.phoneExtension.focus();
        result +='\n Invalid phone extension, length exceeded';
    }
	
    for (var i=0; i < ext.length; i++)
    {
        var letter = ext.charAt(i);
        if (validExt.indexOf(letter) != -1)
            continue;
	        
        if( result == '' )
        {
            focusId=102;
            result += 'Please enter/select valid information for following field(s):';
        }
	        
        document.companyUpdateFrm.phoneExtension.value = '';
        // document.companyUpdateFrm.phoneExtension.focus();
	
        result +='\n Invalid Phone extension';
        break;
    }
	
	
    if( document.companyUpdateFrm.faxNumber.value.length > 0 )
    {
        if( (fstrtindexofclbrk==0) || (fstrtindexofbar==0) || (fstrtindexofspc==0) || (flastindexofbar==faxlength) || (flastindexofspc==faxlength) || (flastindexofopbrk==faxlength) || (faxtotallength<10) || ( fstrtindexofopbrk+1==fstrtindexofclbrk) )
        {
            if(result=='')
            {
                focusId=103;
                result = 'Please enter/select valid information for following field(s):';
            }
	
            document.companyUpdateFrm.faxNumber.value = '';
            //  document.companyUpdateFrm.faxNumber.focus();
            result+= '\n Invalid Fax Number';
        }
	
        for (var i=0; i < document.companyUpdateFrm.faxNumber.value.length; i++)
        {
            var letter = (document.companyUpdateFrm.faxNumber.value).charAt(i).toLowerCase();
            if (validExt.indexOf(letter) != -1)
                continue;
            if( result == '' )
            {
                focusId=103;
                result += 'Please enter/select valid information for following field(s):';
            }
	
            document.companyUpdateFrm.faxNumber.value = '';
            //document.companyUpdateFrm.faxNumber.focus();
	
            result +='\n Fax Number should be numeric';
            break;
        }
	
	
    }
	    
    if(result=='')
    {
        if(user == 'rep'){
            document.companyUpdateFrm.action="/companyUpdateByRep.do?mode=updateCompany";
            document.companyUpdateFrm.submit();
        }else{
            document.companyUpdateFrm.action="/companyUpdate.do?mode=updateCompany";
            document.companyUpdateFrm.submit();
        }
    }
    else
    {
        alert(result);
    }
}

function font(){
    document.getElementById(1).Style="color:'ff0000'" ;
    alert( document.getElementById(1).Style="color:'ff0000'");
}

function confirmOrder(){
    // alert("you are in confirm Order");
    msg="                YOU ARE ABOUT TO PLACE AN ORDER!\n\n"+
    "Please click OK below to confirm. If you are looking for a price quote\n"+
    "or information please contact a promotions specialist at 800-564-6216."
    if(confirm(msg))
        return true;
    else
        return false;
}

function pickupAction(str){
   
	
    var strId=document.fm.id.value;
    var len=document.fm.id.length;
    	
    if(str=='edit'){
        if(len > 1 ){
            if( document.fm.id[0].checked ){
				
                document.fm.action="/companyUpdate.do?mode=companyEdit&listing=yes"
                document.fm.submit();
            }
            else{
                document.fm.opType.value=str
                document.fm.action="/companyAddress.do"
                document.fm.submit();
            }
        }
        else{

            document.fm.action="/companyUpdate.do?mode=companyEdit&listing=yes"
            document.fm.submit();
        }

    }

    else{
        if(str=='delete'){
            if(confirm("Delete Selected Address "))
            {
                //alert('hiii--');
                document.fm.opType.value=str
                document.fm.action="/companyAddress.do"
                document.fm.submit();
            }else{
                return false;
            }
	
        }
        else{
            document.fm.opType.value=str
            document.fm.action="/companyAddress.do"
            document.fm.submit();
        }
	
	
    }
	

}


function pickupActionRep(str){
   
	
    var strId=document.fm.id.value;
    var len=document.fm.id.length;
    	
    if(str=='edit'){
        if(len > 1 ){
            if( document.fm.id[0].checked ){
				
                document.fm.action="/companyUpdateByRep.do?mode=companyEdit&listing=yes"
                document.fm.submit();
            }
            else{
                document.fm.opType.value=str
                document.fm.action="/companyAddressByRep.do"
                document.fm.submit();
            }
        }
        else{

            document.fm.action="/companyUpdateByRep.do?mode=companyEdit&listing=yes"
            document.fm.submit();
        }

    }

    else{
        if(str=='delete'){
            if(confirm("Delete Selected Address "))
            {
                //alert('hiii--');
                document.fm.opType.value=str
                document.fm.action="/companyAddressByRep.do"
                document.fm.submit();
            }else{
                return false;
            }
	
        }
        else{
            document.fm.opType.value=str
            document.fm.action="/companyAddressByRep.do"
            document.fm.submit();
        }
	
	
    }
	

}




function validateAddress(user){

    // alert(user)
    
    var phno =document.getElementById(11).value;
    var i;
    var totallength=phno.length;
    var result='';
    var strtindexofopbrk=phno.indexOf("(",0);
    var strtindexofclbrk=phno.indexOf(")",0);
    var strtindexofbar=phno.indexOf("-",0);
    var strtindexofspc=phno.indexOf(" ",0);
    var lastindexofbar=phno.lastIndexOf("-");
    var lastindexofopbrk=phno.lastIndexOf("(");
    var lastindexofclbrk=phno.lastIndexOf(")");
    var lastindexofspc=phno.lastIndexOf(" ");
    var phonelength=phno.length -1;

    var locat= document.getElementById(1).value;
    var fname=  document.getElementById(2).value;
    var lname= document.getElementById(3).value;
    var company = document.getElementById(4).value;
    var city = document.getElementById(7).value;
    var zip = document.getElementById(10).value;
        
    var ext = document.getElementById(12).value;
    
    var validchars = "abcdefghijklmnopqrstuvwxyz0123456789._@";
    var validcitychars = "abcdefghijklmnopqrstuvwxyz0123456789._- ";
    var numchars = "0123456789";
    var validExt = "0123456789.()- ";
    var validweb = "abcdefghijklmnopqrstuvwxyz0123456789./- ";
    for( i=0;i<phno.length;i++ )
    {
        var chr =phno.charAt(i);
        if( parseInt(chr) != chr)
        {
            totallength--;
        }
    }
    if(trim(document.getElementById(1).value)=='')
    {
        if( result == '' )
        {
            focusId=1;
            result = 'Please enter/select valid information for following field(s):';
        }
	        
	       
        result+= '\n Location' ;
    }
    else{
    }
    if(trim(document.getElementById(2).value)=='')
    {
        if( result == '' )
        {
            focusId=2;
            result = 'Please enter/select valid information for following field(s):';
        }
	        
	       
        result+= '\n First Name' ;
    }
    else{
		
    }
    if(trim(document.getElementById(3).value)=='')
    {
        if( result == '' )
        {
            focusId=3;
            result = 'Please enter/select valid information for following field(s):';
        }
	        
	       
        result+= '\n Last Name' ;
    }

         
    if(trim(document.getElementById(5).value) =='')
    {
        if( result == '' )
        {
            focusId=5;
            result = 'Please enter/select valid information for following field(s):';
        }
	        
	      
        result+= '\n Address' ;
    }

    if(trim(document.getElementById(7).value) =='')
    {
        if( result == '' )
        {
            focusId=7;
            result = 'Please enter/select valid information for following field(s):';
        }
	        
	      
        result+= '\n City' ;
    }
    else
    {
        if( document.getElementById(7).value.length > 30 )
        {
            if( result == '' )
            {
                focusId=7;
                result += 'Please enter/select valid information for following field(s):';
            }
	    
            document.addressForm.city.value = '';
	        
	
            result +='\n Invalid City Name, length exceeded';
        }
	
    }
		
  
    if(document.addressForm.country.value=='Select Country')
    {
        if( result == '' )
        {
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Country' ;
    }

    if(trim(document.getElementById(10).value) =='')
    {
        if( result == '' )
        {
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Zip' ;
    }
    else
    {
        if( document.getElementById(10).value.length > 10 )
        {
            if( result == '' )
            {
                result += 'Please enter/select valid information for following field(s):';
            }
	    
            document.addressForm.zip.value = '';
	           
            result +='\n Invalid Zipcode, length exceeded';
        }
	
        for (var i=0; i < zip.length; i++)
        {
            var letter = zip.charAt(i).toLowerCase();
            if (validweb.indexOf(letter) != -1)
                continue;
	    
            if( result == '' )
            {
                focusId=10;
                result += 'Please enter/select valid information for following field(s):';
            }
	    
            document.addressForm.zip.value = '';
	           
            result +='\n Invalid Zipcode, special characters are  not allowed';
            break;
        }

        // Zip Validation for USA
        if(document.addressForm.country.value=='USA') {            

            validZipChars =  "0123456789-";
            for (var i=0; i < zip.length; i++)
            {
                var letter = zip.charAt(i).toLowerCase();

                if(letter == '-' && i != 5){
                    if( result == '' )
                    {
                        focusId=10;
                        result += 'Please enter/select valid information for following field(s):';
                    }
			
                    document.addressForm.zip.value = '';
                    // document.billform.zipcode.focus();
                    result +='\n Invalid Zipcode';
                    break;
                }

					
                if(letter != '-' && i == 5){
                    if( result == '' )
                    {
                        focusId=10;
                        result += 'Please enter/select valid information for following field(s):';
                    }
			
                    document.addressForm.zip.value = '';
                    // document.billform.zipcode.focus();
                    result +='\n Invalid Zipcode';
                    break;
                }



                if (validZipChars.indexOf(letter) != -1)
                    continue;
			
                if( result == '' )
                {
                    focusId=10;
                    result += 'Please enter/select valid information for following field(s):';
                }
			
                document.addressForm.zip.value = '';
                // document.addressForm.zip.focus();
                result +='\n Invalid Zipcode, special characters are  not allowed';
                break;
            }

        }  //  zip validation for USA

	
    }
	
    if(document.getElementById(11).value=='')
    {
        if( result == '' )
        {
            focusId=11;
            result = 'Please enter/select valid information for following field(s):';
        }
	 
	      
        result+= '\n Phone Number' ;
    }
    else
    {
        if( (strtindexofclbrk==0) || (strtindexofbar==0) || (strtindexofspc==0) || (lastindexofbar==phonelength) || (lastindexofspc==phonelength) || (lastindexofopbrk==phonelength) || (totallength<10) || ( strtindexofopbrk+1==strtindexofclbrk) )
        {
            if(result=='')
            {
                focusId=11;
                result = 'Please enter/select valid information for following field(s):';
            }
	
            document.addressForm.phoneNumber.value = '';
	           
            result+= '\n Invalid Phone Number';
	
        }
	
        for (var i=0; i < document.getElementById(11).value.length; i++)
        {
            var letter = (document.getElementById(11).value).charAt(i).toLowerCase();
            if (validExt.indexOf(letter) != -1)
                continue;
            if( result == '' )
            {
                focusId=11;
                result += 'Please enter/select valid information for following field(s):';
            }
	
            document.addressForm.phoneNumber.value = '';
	           	
            result +='\n Phone Number should be numeric';
            break;
        }
	        
	        
    }

    if(document.addressForm.country.value=='USA') {

        //State
        if(trim(document.getElementById(8).value) =='Select')
        {
            if( result == '' )
            {
                result = 'Please enter/select valid information for following field(s):';
            }
            result+= '\n State' ;
        }
    }
    else if (document.addressForm.country.value=='CANADA') {
        if(trim(document.getElementById(8).value) =='Select')
        {
            if( result == '' )
            {
                result = 'Please enter/select valid information for following field(s):';
            }
            result+= '\n State' ;
        }
    } else {
        if(trim(document.getElementById(999).value) =='')
        {
            if( result == '' )
            {
                result = 'Please enter/select valid information for following field(s):';
            }
            result+= '\n State' ;
        }
    }
	
    if( document.getElementById(12).value.length > 10 )
    {
        if( result == '' )
        {
            focusId=12;
            result += 'Please enter/select valid information for following field(s):';
        }
	
        document.addressForm.phoneExt.value = '';
	       
        result +='\n Invalid phone extension, length exceeded';
    }
	
    for (var i=0; i < ext.length; i++)
    {
        var letter = ext.charAt(i);
        if (validExt.indexOf(letter) != -1)
            continue;
	        
        if( result == '' )
        {
            focusId=12;
            result += 'Please enter/select valid information for following field(s):';
        }
	        
        document.addressForm.phoneExt.value = '';
	      
        result +='\n Invalid Phone extension';
        break;
    }
    
    if(result=='')
    {
        document.addressForm.opType.value='save'
        if(user == 'rep'){
            document.addressForm.action="/companyAddressByRep.do"
        }
        else{
            document.addressForm.action="/companyAddress.do"
        }
        document.addressForm.submit();

    }
    else
    {
        alert(result);
        if(focusId!=0){
            document.getElementById(focusId).focus();
        }
    }

	
}

// For Rep User Registration validation

function validateRepUserRegistration(ret)
{
    var phno =document.getElementById(12).value;
    var i;
    var totallength=phno.length;
    
    var strtindexofopbrk=phno.indexOf("(",0);
    var strtindexofclbrk=phno.indexOf(")",0);
    var strtindexofbar=phno.indexOf("-",0);
    var strtindexofspc=phno.indexOf(" ",0);
    var lastindexofbar=phno.lastIndexOf("-");
    var lastindexofopbrk=phno.lastIndexOf("(");
    var lastindexofclbrk=phno.lastIndexOf(")");
    var lastindexofspc=phno.lastIndexOf(" ");
    var phonelength=phno.length -1;

    var faxno =document.getElementById(13).value;
    var y;
    var faxtotallength=faxno.length;
    var fstrtindexofopbrk=faxno.indexOf("(",0);
    var fstrtindexofclbrk=faxno.indexOf(")",0);
    var fstrtindexofbar=faxno.indexOf("-",0);
    var fstrtindexofspc=faxno.indexOf(" ",0);
    var flastindexofbar=faxno.lastIndexOf("-");
    var flastindexofopbrk=faxno.lastIndexOf("(");
    var flastindexofclbrk=faxno.lastIndexOf(")");
    var flastindexofspc=faxno.lastIndexOf(" ");
    var faxlength=faxno.length -1;  
    //binita
    var ph2no =document.getElementById(66).value;
    var m;
    var ph2totallength=ph2no.length;
    var p2strtindexofopbrk=ph2no.indexOf("(",0);
    var p2strtindexofclbrk=ph2no.indexOf(")",0);
    var p2strtindexofbar=ph2no.indexOf("-",0);
    var p2strtindexofspc=ph2no.indexOf(" ",0);
    var p2lastindexofbar=ph2no.lastIndexOf("-");
    var p2lastindexofopbrk=ph2no.lastIndexOf("(");
    var p2lastindexofclbrk=ph2no.lastIndexOf(")");
    var p2lastindexofspc=ph2no.lastIndexOf(" ");
    var ph2length=ph2no.length -1;   
    // 
    
    var str = document.getElementById(0).value ;


    var result = '';
   
    var fname = document.getElementById(3).value;
    var lname = document.getElementById(4).value;
    var company = document.getElementById(5).value;
    var city = document.getElementById(9).value;
    var zip = document.getElementById(11).value;
    var fax = document.getElementById(13).value;
    var ph2 = document.getElementById(66).value;
    var ext = document.billform.phoneExtension.value;
    var website = document.billform.webSiteAddress.value;

    var validchars = "abcdefghijklmnopqrstuvwxyz0123456789._@";
    var validcitychars = "abcdefghijklmnopqrstuvwxyz0123456789._- ";
    var numchars = "0123456789";
    var validExt = "0123456789.()- ";
    var validweb = "abcdefghijklmnopqrstuvwxyz0123456789./- ";
    var fieldFocus=0;
    var fieldName='';

    for( i=0;i<phno.length;i++ )
    {
        var chr =phno.charAt(i);
        if( parseInt(chr) != chr)
        {
            totallength--;
        }
    }


    for( y=0;y<faxno.length;y++ )
    {
        var chr =faxno.charAt(y);
        if( parseInt(chr) != chr)
        {
            faxtotallength--;
        }
    }
    //binita
    for( m=0;m<ph2no.length;m++ )
    {
        var chr =ph2no.charAt(m);
        if( parseInt(chr) != chr)
        {
            ph2totallength--;
        }
    }

    //
    if( str != '' )
    {
        var check1=str.lastIndexOf("@");
        var check2=str.indexOf(".",check1);
        var check3=check2-check1;
        var check4=str.indexOf("@",0);
    }
	
    if( trim(document.billform.empuserId.value=='Select') ){
    
        if( result == '' )
        {
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Rep Name' ;
    }
    
    if( trim(document.getElementById(3).value)=='') 
    {
        if( result == '' )
        {
            result = 'Please enter/select valid information for following field(s):';
        }

        // document.billform.firstName.focus();
        result+= '\n First Name' ;
    }
    else
    {
        if( document.getElementById(3).value.length > 35 ) 
        {
            if( result == '' )
            {
                fieldFocus=3;
                result += 'Please enter/select valid information for following field(s):';
            }
    
            document.billform.firstName.value = '';
            //document.billform.firstName.focus();

            result +='\n Invalid First Name, length exceeded';
        }

    }                 

    if( trim(document.getElementById(4).value)=='') 
    {
        if( result == '' )
        {
            fieldFocus=4;
            result = 'Please enter/select valid information for following field(s):';
        }
        
        //document.billform.lastName.focus();
        result+= '\n Last Name' ;
    }
    else
    {
        if( document.getElementById(4).value.length > 35 ) 
        {
            if( result == '' )
            {
                fieldFocus=4;
                result += 'Please enter/select valid information for following field(s):';
            }

            document.billform.lastName.value = '';
            // document.billform.lastName.focus();
    
            result +='\n Invalid Last Name, length exceeded';
        }
    }                 


    if(document.getElementById(0).value=='') 
    {
        if( result == '' )
        {
            fieldFocus=0;
            result = 'Please enter/select valid information for following field(s):';
        }
   
        //document.billform.email.focus();
        result += '\n Email Id';
    }
    else
    {
        if(! ( check1 >= 1 && check2 > 1 && check3 > 1 &&  str.length!=check2+1 ) )
        {
            if( result == '' )
            {
                fieldFocus=0;
                result += 'Please enter/select valid information for following field(s):';
            }

            document.billform.email.value = '';
            //document.billform.email.focus();

            result +='\n Invalid email address.';
        }
        else{

            for (var i=0; i < str.length; i++)
            {
                var letter = str.charAt(i).toLowerCase();
        
                if (vailidLoginEmailChars.indexOf(letter) != -1)
                    continue;
            
                if( result == '' )
            
                {
                    fieldFocus=0;
                    result += 'Please enter/select valid information for following field(s):';
                }
            
                result +='\n Invalid Email Id, special characters are  not allowed';
                document.billform.email.value = '';
                // document.billform.login.focus();

                break;
            }
  
        }
    }

    
    if(document.billform.title.value =='Select') 
    {
        if( result == '' )
        {
            fieldFocus=6;
            result = 'Please enter/select valid information for following field(s):';
        }

        //document.billform.title.focus();
        result+= '\n Title' ;
    }
    
    if(document.billform.department.value=='Select')
    {
        if( result == '' )
        {
            fieldFocus=7;
            result = 'Please enter/select valid information for following field(s):';
        }

        //document.billform.department.focus();
        result+= '\n Department' ;
    }
	
    if(trim(document.getElementById(8).value) =='') 
    {
        if( result == '' )
        {
            fieldFocus=8;
            result = 'Please enter/select valid information for following field(s):';
        }
        
        //document.billform.address1.focus();
        result+= '\n Address' ;
    }
    else
    {
        if( document.getElementById(8).value.length > 255 ) 
        {
            if( result == '' )
            {
                fieldFocus=8;
                result += 'Please enter/select valid information for following field(s):';
            }

            document.billform.address1.value = '';
            //document.billform.address1.focus();
            result +='\n Invalid Address Line1, length exceeded';
        }
    }                 


    if( document.getElementById(21).value.length > 255 ) 
    {
        if( result == '' )
        {
            fieldFocus=21;
            result += 'Please enter/select valid information for following field(s):';
        }

        document.billform.address2.value = '';
        // document.billform.address2.focus();
        result +='\n Invalid Address Line2, length exceeded';
    }


    if(trim(document.getElementById(9).value) =='') 
    {
        if( result == '' )
        {
            fieldFocus=9;
            result = 'Please enter/select valid information for following field(s):';
        }
        
        //document.billform.city.focus();

        result+= '\n City' ;
    }
    else
    {
        if( document.getElementById(9).value.length > 30 ) 
        {
            if( result == '' )
            {
                fieldFocus=9;
                result += 'Please enter/select valid information for following field(s):';
            }
    
            document.billform.city.value = '';
            //  document.billform.city.focus();

            result +='\n Invalid City Name, length exceeded';
        }
    }     
	
    if(document.billform.country.value=='Select') 
    {
        if( result == '' )
        {   
            result = 'Please enter/select valid information for following field(s):';
        }
        
        // document.billform.country.focus();

        result+= '\n Country' ;
    }


    if(trim(document.getElementById(11).value) =='')
    {
        if( result == '' )
        {
            fieldFocus=11;
            result = 'Please enter/select valid information for following field(s):';
        }

        //document.billform.zipcode.focus();
        result+= '\n Zip' ;
    }
    else
    {
        if( document.getElementById(11).value.length > 10 ) 
        {
            if( result == '' )
            {
                fieldFocus=11;
                result += 'Please enter/select valid information for following field(s):';
            }
    
            document.billform.zipcode.value = '';
            //document.billform.zipcode.focus();
            result +='\n Invalid Zipcode, length exceeded';
        }

        for (var i=0; i < zip.length; i++) 
        {
            var letter = zip.charAt(i).toLowerCase();
            if (validweb.indexOf(letter) != -1)
                continue;
    
            if( result == '' )
            {
                fieldFocus=11;
                result += 'Please enter/select valid information for following field(s):';
            }
    
            document.billform.zipcode.value = '';
            // document.billform.zipcode.focus();
            result +='\n Invalid Zipcode, special characters are  not allowed';
            break;
        }

        // Zip Validation for USA
        if(document.billform.country.value=='USA') {
            validZipChars =  "0123456789-";
            for (var i=0; i < zip.length; i++)
            {
                var letter = zip.charAt(i).toLowerCase();

                if(letter == '-' && i != 5){
                    if( result == '' )
                    {
                        fieldFocus=11;
                        result += 'Please enter/select valid information for following field(s):';
                    }
			
                    document.billform.zipcode.value = '';
                    // document.billform.zipcode.focus();
                    result +='\n Invalid Zipcode';
                    break;
                }

                if(letter != '-' && i == 5){
                    if( result == '' )
                    {
                        fieldFocus=11;
                        result += 'Please enter/select valid information for following field(s):';
                    }
			
                    document.billform.zipcode.value = '';
                    // document.billform.zipcode.focus();
                    result +='\n Invalid Zipcode';
                    break;
                }


                if (validZipChars.indexOf(letter) != -1)
                    continue;
			
                if( result == '' )
                {
                    fieldFocus=11;
                    result += 'Please enter/select valid information for following field(s):';
                }
			
                document.billform.zipcode.value = '';
                // document.addressForm.zipcode.focus();
                result +='\n Invalid Zipcode, special characters are  not allowed';
                break;
            }

        }  //  zip validation for USA


    }

    if(document.getElementById(12).value=='') 
    {
        if( result == '' )
        {
            fieldFocus=12;
            result = 'Please enter/select valid information for following field(s):';
        }
 
        //  document.billform.phoneNumber.focus();
        result+= '\n Phone Number' ;
    }
    else
    {
        if( (strtindexofclbrk==0) || (strtindexofbar==0) || (strtindexofspc==0) || (lastindexofbar==phonelength) || (lastindexofspc==phonelength) || (lastindexofopbrk==phonelength) || (totallength<10) || ( strtindexofopbrk+1==strtindexofclbrk) )
        {
            if(result=='')
            {
                fieldFocus=12;
                result = 'Please enter/select valid information for following field(s):';
            }

            document.billform.phoneNumber.value = '';
            //document.billform.phoneNumber.focus();
            result+= '\n Invalid Phone Number';

        }

        for (var i=0; i < document.getElementById(12).value.length; i++) 
        {
            var letter = (document.getElementById(12).value).charAt(i).toLowerCase();
            if (validExt.indexOf(letter) != -1)
                continue;
            if( result == '' )
            {
                fieldFocus=12;
                result += 'Please enter/select valid information for following field(s):';
            }

            document.billform.phoneNumber.value = '';
            //document.billform.phoneNumber.focus();

            result +='\n Phone Number should be numeric';
            break;
        }
        
        
    }

    if( document.billform.phoneExtension.value.length > 10 ) 
    {
        if( result == '' )
        {
            fieldFocus=33;
            result += 'Please enter/select valid information for following field(s):';
        }

        document.billform.phoneExtension.value = '';
        result +='\n Invalid phone extension, length exceeded';
    }

    for (var i=0; i < ext.length; i++) 
    {
        var letter = ext.charAt(i);
        if (validExt.indexOf(letter) != -1)
            continue;
        
        if( result == '' )
        {
            fieldFocus=33;
            result += 'Please enter/select valid information for following field(s):';
        }
        
        document.billform.phoneExtension.value = '';
        result +='\n Invalid Phone extension';
        break;
    }


    if( document.billform.faxNumber.value.length > 0 )
    {
        if( (fstrtindexofclbrk==0) || (fstrtindexofbar==0) || (fstrtindexofspc==0) || (flastindexofbar==faxlength) || (flastindexofspc==faxlength) || (flastindexofopbrk==faxlength) || (faxtotallength<10) || ( fstrtindexofopbrk+1==fstrtindexofclbrk) )
        {
            if(result=='')
            {
                fieldFocus=13;
                result = 'Please enter/select valid information for following field(s):';
            }
            document.billform.faxNumber.value = '';
            result+= '\n Invalid Fax Number';
        }

        for (var i=0; i < document.billform.faxNumber.value.length; i++) 
        {
            var letter = (document.billform.faxNumber.value).charAt(i).toLowerCase();
            if (validExt.indexOf(letter) != -1)
                continue;
            if( result == '' )
            {
                fieldFocus=13;
                result += 'Please enter/select valid information for following field(s):';
            }

            document.billform.faxNumber.value = '';
            result +='\n Fax Number should be numeric';
            break;
        }


    }                       
    if( document.billform.phoneNumber2.value.length > 0 )
    {
        if( (p2strtindexofclbrk==0) || (p2strtindexofbar==0) || (p2strtindexofspc==0) || (p2lastindexofbar==ph2length) || (p2lastindexofspc==ph2length) || (p2lastindexofopbrk==ph2length) || (ph2totallength<10) || ( p2strtindexofopbrk+1==p2strtindexofclbrk) )
        {
            if(result=='')
            {
                fieldFocus=66;
                result = 'Please enter/select valid information for following field(s):';
            }
            document.billform.phoneNumber2.value = '';
            result+= '\n Invalid Phone Number2';
        }

        for (var i=0; i < document.billform.phoneNumber2.value.length; i++) 
        {
            var letter = (document.billform.phoneNumber2.value).charAt(i).toLowerCase();
            if (validExt.indexOf(letter) != -1)
                continue;
            if( result == '' )
            {
                fieldFocus=66;
                result += 'Please enter/select valid information for following field(s):';
            }
            document.billform.phoneNumber2.value = '';
            result +='\n Phone Number2 should be numeric';
            break;
        }
    }                       
    //


    if( document.billform.webSiteAddress.value.length > 0 )
    {
        for (var i=0; i < website.length; i++) 
        {
            var letter = website.charAt(i);
            if (validweb.indexOf(letter) != -1)
                continue;

            if( result == '' )
            {
                fieldFocus=44;
                result += 'Please enter/select valid information for following field(s):';
            }
            document.billform.webSiteAddress.value = '';
            result +='\n Invalid Web site address';
            break;
        }

        if( document.billform.webSiteAddress.value.length > 255 ) 
        {
            if( result == '' )
            {
                fieldFocus=44;
                result += 'Please enter/select valid information for following field(s):';
            }
            document.billform.webSiteAddress.value = '';
            result +='\n Invalid Web site address, length exceeded';
        }

    }                       
    if(document.billform.businessType.value =='Select')
    {
        if( result == '' )
        {   
            fieldFocus=14;
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Business Type ' ;
    }

    if(document.billform.businessType.value=='33')
    {
        if(document.billform.businessTypeOther.value =='')
        {
            if(result=='')
            {
                fieldFocus=14;
                result = 'Please enter/select valid information for following field(s):';
            }
            result+= '\n Specify type of business in other box';
        }                           
    }


    if(document.billform.promotionalPurchases.value=='Select')
    {
        if( result == '' )
        {   
            fieldFocus=15;
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Promotional Purchases ' ;
    }

    if(document.billform.numberOfEmployees.value=='Select') 
    {
        if( result == '' )
        {   
            fieldFocus=16;
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Number of Employees';
    }

    if(document.billform.source.value=='') 
    {
        if( result == '' )
        {   
            fieldFocus=17;
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n How did you hear about us?';
    }

    if(document.billform.source.selectedIndex==7) 
    {
        if(trim(document.getElementById(56).value)=='')
        {
            if( result == '' )
            {
                fieldFocus=56;
                result = 'Please enter/select valid information for following field(s):';
            }
            result+= '\n Referral Name?';
        }
    }

    if(document.billform.source.selectedIndex==8) 
    {
        if(trim(document.getElementById(57).value)=='')
        {
            if( result == '' )
            {
                fieldFocus=57;
                result = 'Please enter/select valid information for following field(s):';
            }
            result+= '\n Salesperson Name?';
        }
                        
    }
 
    if (result == '')
    {   
        document.billform.login.value = document.billform.email.value;
        document.billform.action="/repUserSignup.do";
        document.billform.submit();
    }
    else
    {
        alert ( result );
        
    }
}
function validateRepLogRegistration()
{  
    var result = '';
    var fieldFocus=0;
    var fieldName='';
    
    if(document.getElementById(2222).value=='0') 
    {
        if( result == '' )
        {
            fieldFocus=2222;
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Rep List';
    }
    
    if( trim(document.getElementById(200).value=='Select') ){
    
        if( result == '' )
        {
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Register Type' ;
    
    }

    if(document.getElementById(17).value=='') 
    {
        if( result == '' )
        {   
            fieldFocus=17;
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n How did you hear about us?';
    }
    if(document.getElementById(71).value=='')
    {
        if( result == '' )
        {
            fieldFocus=71;
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Call Result';
    }
    if(document.getElementById(17).selectedIndex==7) 
    {
        if(trim(document.getElementById(56).value)=='')
        {
            if( result == '' )
            {
                fieldFocus=56;
                result = 'Please enter/select valid information for following field(s):';
            }
            result+= '\n Referral Name?';
        }
    }
	
    if(document.getElementById(17).selectedIndex==8) 
    {
        if(trim(document.getElementById(57).value)=='')
        {
            if( result == '' )
            {
                fieldFocus=57;
                result = 'Please enter/select valid information for following field(s):';
            }
            result+= '\n Salesperson Name?';
        }
    }
    if (result == '')
    {   
        document.billform.login.value = document.billform.email.value;
        document.billform.action="/repUserSignup1.do";
        document.billform.submit();
    }
    else
    {
        alert ( result );
        
    }
}
function imprintAdditionalPopup(productId,productName){
    var link ="/OrderPipeline/additionalImprintInformation.jsp?productId="+productId+"&productName="+productName
    window.open(link  ,'ImprintDetail' , 'width=453,height=600,scrollbars=yes');
}  




function makeEditable()
{

    var selectedValue = trim(document.billform.source.value);

    if(selectedValue=="REF - Referral/Word of Mouth")
    {
        document.getElementById("salespersonRow").style.visibility = "hidden"
        document.getElementById("salespersonRow").style.position = "absolute"
        var row = document.getElementById("salespersonRow");
        row.style.display = 'none'
        document.getElementById("howYouHearOtherRow").style.position = "absolute"
        var row = document.getElementById("howYouHearOtherRow");
        row.style.display = 'none'
		

        document.getElementById("referralRow").style.visibility = "visible"
        document.getElementById("referralRow").style.position = "relative"
        var rowRef = document.getElementById("referralRow");
        rowRef.style.display = ''
    }
    else if(selectedValue=="Already working with a Salesperson")
    {
        document.getElementById("referralRow").style.visibility = "hidden"
        document.getElementById("referralRow").style.position = "absolute"
        var row = document.getElementById("referralRow");
        row.style.display = 'none';
        document.getElementById("howYouHearOtherRow").style.position = "absolute"
        var row = document.getElementById("howYouHearOtherRow");
        row.style.display = 'none'
		
        document.getElementById("salespersonRow").style.visibility = "visible"
        document.getElementById("salespersonRow").style.position = "relative"
        var rowSales = document.getElementById("salespersonRow");
        rowSales.style.display = ''

    }else if(selectedValue=="Other")
    {
        document.getElementById("referralRow").style.visibility = "hidden"
        document.getElementById("referralRow").style.position = "absolute"
        var row = document.getElementById("referralRow");
        row.style.display = 'none';
        document.getElementById("salespersonRow").style.position = "absolute"
        var row = document.getElementById("salespersonRow");
        row.style.display = 'none'
		
        document.getElementById("howYouHearOtherRow").style.visibility = "visible"
        document.getElementById("howYouHearOtherRow").style.position = "relative"
        var rowSales = document.getElementById("howYouHearOtherRow");
        rowSales.style.display = ''

    }
    else
    {
        document.getElementById("referralRow").style.visibility = "hidden"
        var row = document.getElementById("referralRow");
        row.style.display = 'none';
        document.getElementById("salespersonRow").style.visibility = "hidden"
        var rowSales = document.getElementById("salespersonRow");
        rowSales.style.display = 'none';
        document.getElementById("howYouHearOtherRow").style.visibility = "hidden"
        var rowSales = document.getElementById("howYouHearOtherRow");
        rowSales.style.display = 'none';
    }
}


function makeEditableRep()
{
    if(document.billform.source.selectedIndex==7)
    {
        document.getElementById("salespersonRow").style.visibility = "hidden"
        document.getElementById("salespersonRow").style.position = "absolute"
        var row = document.getElementById("salespersonRow");
        row.style.display = 'none'
        document.getElementById("howYouHearOtherRow").style.position = "absolute"
        var row = document.getElementById("howYouHearOtherRow");
        row.style.display = 'none'
		
		
        document.getElementById("referralRow").style.visibility = "visible"
        document.getElementById("referralRow").style.position = "relative"
        var rowRef = document.getElementById("referralRow");
        rowRef.style.display = ''
    }
    else if(document.billform.source.selectedIndex==8)
    {
        document.getElementById("referralRow").style.visibility = "hidden"
        document.getElementById("referralRow").style.position = "absolute"
        var row = document.getElementById("referralRow");
        row.style.display = 'none';
        document.getElementById("howYouHearOtherRow").style.position = "absolute"
        var row = document.getElementById("howYouHearOtherRow");
        row.style.display = 'none'
		
        document.getElementById("salespersonRow").style.visibility = "visible"
        document.getElementById("salespersonRow").style.position = "relative"
        var rowSales = document.getElementById("salespersonRow");
        rowSales.style.display = ''

    }else if(document.billform.source.selectedIndex==21)
    {
        document.getElementById("referralRow").style.visibility = "hidden"
        document.getElementById("referralRow").style.position = "absolute"
        var row = document.getElementById("referralRow");
        row.style.display = 'none';
        document.getElementById("salespersonRow").style.position = "absolute"
        var row = document.getElementById("salespersonRow");
        row.style.display = 'none'
		
        document.getElementById("howYouHearOtherRow").style.visibility = "visible"
        document.getElementById("howYouHearOtherRow").style.position = "relative"
        var rowSales = document.getElementById("howYouHearOtherRow");
        rowSales.style.display = ''

    }
    else
    {
        document.getElementById("referralRow").style.visibility = "hidden"
        var row = document.getElementById("referralRow");
        row.style.display = 'none';
        document.getElementById("salespersonRow").style.visibility = "hidden"
        var rowSales = document.getElementById("salespersonRow");
        rowSales.style.display = 'none';
        document.getElementById("howYouHearOtherRow").style.visibility = "hidden"
        var rowSales = document.getElementById("howYouHearOtherRow");
        rowSales.style.display = 'none';
    }
}
	
function displayOtherDepartment()
{
    if(document.billform.department.value=='13')
    {
        document.getElementById("otherDepartment").style.visibility = "visible"
        var rowRef = document.getElementById("otherDepartment");
        rowRef.style.display = ''
    }
    else
    {
        document.getElementById("otherDepartment").style.visibility = "hidden"
        var row = document.getElementById("otherDepartment");
        row.style.display = 'none';
    }
}

function displayOtherBusiness()
{
    if(document.billform.businessType.value=='33')
    {
        document.getElementById("otherBusiness").style.visibility = "visible"
        var rowRef = document.getElementById("otherBusiness");
        rowRef.style.display = ''
    }
    else
    {
        document.getElementById("otherBusiness").style.visibility = "hidden"
        var row = document.getElementById("otherBusiness");
        row.style.display = 'none';
    }
}


function displayOtherTitle()
{
    if(document.billform.title.value=='16')
    {
        document.getElementById("otherTitle").style.visibility = "visible"
        var rowRef = document.getElementById("otherTitle");
        rowRef.style.display = ''
    }
    else
    {
        document.getElementById("otherTitle").style.visibility = "hidden"
        var row = document.getElementById("otherTitle");
        row.style.display = 'none';
    }
}

function setValue()
{
    document.billform.login.focus();
    makeEditable();
    displayOtherTitle();
    displayOtherDepartment();
}



function charges(){
    if(document.requestform.SampleCharges!=null)
    {
        if (document.requestform.SampleCharges.checked) {
            document.requestform.chargedSample.value="1"
        	
        }else{
            document.requestform.chargedSample.value="0"
	  

        }
    }
}

function validateBusinessInfo(user)
{

    var website = document.businessUpdateForm.webSiteAddress.value;
    var fieldFocus=0;
    var validweb = "abcdefghijklmnopqrstuvwxyz0123456789./- ";
  
    var result = '';
  
    if( document.businessUpdateForm.webSiteAddress.value.length > 0 )
    {
        for (var i=0; i < website.length; i++) 
        {
            var letter = website.charAt(i);

            if (validweb.indexOf(letter) != -1)
                continue;

            if( result == '' )
            {    
                fieldFocus=44;
                result += 'Please enter/select valid information for following field(s):';
            }
            document.businessUpdateForm.webSiteAddress.value = '';
            result +='\n Invalid Web site address';
            break;
        }

        if( document.businessUpdateForm.webSiteAddress.value.length > 255 ) 
        {
            if( result == '' )
            {
                fieldFocus=44;
                result += 'Please enter/select valid information for following field(s):';
            }
            document.businessUpdateForm.webSiteAddress.value = '';
            result +='\n Invalid Web site address, length exceeded';
        }
    }                       
    if(document.getElementById(14).value =='Business type')
    {
        if( result == '' )
        {
            fieldFocus=14;
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Business Type ' ;
    }
    if(document.getElementById(15).value=='Select')
    {
        if( result == '' )
        {
            fieldFocus=15;
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Promotional Purchases ' ;
    }

    if(document.getElementById(16).value=='Select') 
    {
        if( result == '' )
        {   
            fieldFocus=16;
            result = 'Please enter/select valid information for following field(s):';
        }
        result+= '\n Number of Employees';
    }
    if(result=='')
    {
        if(user == 'rep'){
            document.businessUpdateForm.action="/businessUpdate.do?mode=businessUpdate&rep=yes";
        }
        else
        {
            document.businessUpdateForm.action="/businessUpdate.do?mode=businessUpdate";
        }
        document.businessUpdateForm.submit();
    }
    else
    {
        alert(result);
   
    }
}

// JavaScript Document

function selectedTempWishlist()
{
    if(document.requestform.selectIntendedUseList.selectedIndex>0)
    {
        document.requestform.wishlistUse.value = document.requestform.selectIntendedUseList.options[document.requestform.selectIntendedUseList.selectedIndex].value;
        getIntendedUseList(document.requestform.selectIntendedUseList.selectedIndex)
    }
}




////////////////////////////// validate Sample Request Starts

function validateSampleRequest()
{
    var result='';
    var focus=0;
    Samplecharges()
    ///Color Box validation
    var wishlist ="";
    for (counter = 0; counter < document.sampleForm.wishlistCreate.length; counter++)
    {
        if (document.sampleForm.wishlistCreate[counter].checked)
            wishlist = document.sampleForm.wishlistCreate[counter].value;
    }

    if( trim(wishlist)=='' )
    {
        if(result=='')
        {
            result=' Please enter valid information in following field(s):';
        }
        result+= '\n  Select or Create a Project' ;
    }


    if (document.sampleForm.colorChoice != null)
    {
        if( trim(document.sampleForm.colorChoice.value)=='NA' )
        {
            if(result=='')
            {
                focus=1;
                result=' Please enter valid information in following field(s):';
            }
            result+= '\n  Color Choice' ;
        }
    }



    if (wishlist=="new")
    {
        if (trim(document.sampleForm.wishlistName.value)=='')
        {
            if(result=='')
            { 
                focus=2;
                result=' Please enter valid information in following field(s):';
            }
            result+= '\n  Project Name' ;
        }
	
        if (trim(document.sampleForm.budgetRange.value)=='NA')
        {
            if(result=='')
            { 
                focus=3;
                result=' Please enter valid information in following field(s):';
            }
            result+= '\n  Budget Range' ;
        }

        if (trim(document.sampleForm.eventDate.value)=='')
        {
            if(result=='')
            { 
                focus=4;
                result=' Please enter valid information in following field(s):';
            }
            result+= '\n  Event Date' ;
        }
		
		
        if (trim(document.sampleForm.intendedUseCategory.value)=='NA')
        {
            if(result=='')
            { 
                focus=3;
                result=' Please enter valid information in following field(s):';
            }
            result+= '\n  Intended Use' ;
        }


    }
    else{
        if (wishlist=="existing"){
            if (trim(document.sampleForm.wishlistSelected.value)=='NA')
            {
                if(result=='')
                {
                    focus=3;
                    result=' Please enter valid information in following field(s):';
                }
                result+= '\n  Existing Project Name' ;
            }
        }
    }
	
	
    /////////////Shipping validation -----
    if( trim(document.sampleForm.shippingMethod.value)=='NA' )
    {
        if(result=='')
        {
            focus=1;
            result=' Please enter valid information in following field(s):';
        }
        result+= '\n  Shipping Method' ;
    }

    if(trim(document.sampleForm.shippingMethod.value != 'UPS Ground'))
    {
        if(trim(document.sampleForm.userShippingAccountNumber.value) == '')
        {
            if(result=='')
            {
                focus=6;
                result='Please enter valid information in following field(s):';
            }
            result+= '\n  Shipping Account Number ';
        }
        else
        {
            if( trim(document.sampleForm.userShippingAccountNumber.value.length) > 50 )
            {
                if( result == '' )
                {
                    focus=6;
                    result += 'Please enter/select valid information for following field(s):';
                }
                    
                document.sampleForm.userShippingAccountNumber.value='';
                result +='\n Shipping account number, length exceeded';
            }
        }
    }
    var shipId=trim(document.sampleForm.shippingAddressId.value);
    if(shipId=='NA') {
        if( result == '' ) {
            result += 'Please enter/select valid information for following field(s):';
        }
        result +='\n  select a shipping address ';
    }
    /////////////Shipping validation -----
    var keyLength = document.sampleForm.wishlistNotes.value.length;
    if(keyLength > 120) {
        if( result == '' ) {
            result += 'Please enter/select valid information for following field(s):';
        }
        result +='\n  ADD NOTES maximum character count 120.';
    }
    
    if(result=='')
    {
        var validEventDate = 0;
        if (wishlist=="new")
        {
            if (!isEventDate(trim(document.sampleForm.eventDate.value)))
            {
                validEventDate = -1;
            }
        }
        if (validEventDate == 0)
        {
            document.sampleForm.action="/SampleCreated.do";
            document.sampleForm.submit();
        }
        else
        {
            alert("Please enter a valid Event date MM/DD/YYYY");
        }

    }
    else
    {
        alert(result);
    }
}

function SampleRequestCreateNewWishlist()
{
    document.getElementById("newProjectRow").style.backgroundColor="#EDEDEF";


    document.getElementById("newProjectRow1").style.color="#000000";
    document.getElementById("newProjectRow2").style.color="#000000";
    document.getElementById("newProjectRow3").style.color="#000000";
    document.getElementById("newProjectRow4").style.color="#000000";
    document.getElementById("newProjectRow5").style.color="#000000";
		
		
    document.sampleForm.wishlistSelected.options[0].selected=true;
    document.sampleForm.wishlistSelected.disabled=true;

    document.sampleForm.wishlistName.disabled=false;
    document.sampleForm.budgetRange.disabled=false;
    document.sampleForm.eventDate.disabled=false;
    document.sampleForm.intendedUseCategory.disabled=false;
    document.sampleForm.intendedUseSubCategory.disabled=false;
		
}

function SampleRequestSelectedOldWishlist()
{
    document.getElementById("newProjectRow").style.backgroundColor="#DBDCE0";
    document.getElementById("newProjectRow1").style.color="#BBBBBC";
    document.getElementById("newProjectRow2").style.color="#BBBBBC";
    document.getElementById("newProjectRow3").style.color="#BBBBBC";
    document.getElementById("newProjectRow4").style.color="#BBBBBC";
    document.getElementById("newProjectRow5").style.color="#BBBBBC";

    document.sampleForm.wishlistSelected.disabled=false;
    document.sampleForm.wishlistName.disabled=true;
    document.sampleForm.budgetRange.options[0].selected=true;
    document.sampleForm.budgetRange.disabled=true;
    document.sampleForm.eventDate.disabled=true;
    document.sampleForm.intendedUseCategory.options[0].selected=true;
    document.sampleForm.intendedUseCategory.disabled=true;
    document.sampleForm.intendedUseSubCategory.options[0].selected=true;
    document.sampleForm.intendedUseSubCategory.disabled=true;

}	

function SampleRequestOnLoad(){
    var wishlistChoice='';
    for (counter = 0; counter < document.sampleForm.wishlistCreate.length; counter++)
    {
        if (document.sampleForm.wishlistCreate[counter].checked)
            wishlistChoice = document.sampleForm.wishlistCreate[counter].value;
    }
    if (wishlistChoice != null && wishlistChoice!='')
    {
        if (wishlistChoice == 'existing'){
            selectedOldWishlist();
        }
        if (wishlistChoice == 'new'){
            document.sampleForm.wishlistSelected.options[0].selected=true;
            document.sampleForm.wishlistSelected.disabled=true;
            document.sampleForm.wishlistName.disabled=false;
            document.sampleForm.budgetRange.disabled=false;
            document.sampleForm.eventDate.disabled=false;
            document.sampleForm.intendedUseCategory.disabled=false;
            document.sampleForm.intendedUseSubCategory.disabled=false;
        }
    }
}

function displayShippingAccountNumberRow(repOver)
{
    repOver = repOver || ''
    if((document.sampleForm.shippingMethod.value!= 'UPS Ground' || repOver !='') && document.sampleForm.shippingMethod.value!= 'NA' )
    {
        document.sampleForm.userShippingAccountNumber.disabled=false;
        document.getElementById("shippingAcc").style.visibility = "visible"
        document.getElementById("shippingAcc").style.position = "relative"
        document.getElementById("ShippingAccNumRow").style.visibility = "visible"
        document.getElementById("ShippingAccNumRow").style.position = "relative"
        document.getElementById("ShippingAccNumCol").style.visibility = "visible"
        document.getElementById("ShippingAccNumCol").style.position = "relative"
        document.getElementById("ShippingAccNumValueCol").style.visibility = "visible"
        document.getElementById("ShippingAccNumValueCol").style.position = "relative"
        document.getElementById("ShippingAccNumRowBlank").style.visibility = "visible"
        document.getElementById("ShippingAccNumRowBlank").style.position = "relative"
        document.getElementById("ShippingAccNumColBlank").style.visibility = "visible"
        document.getElementById("ShippingAccNumColBlank").style.position = "relative"
    }
    else
    {

        document.sampleForm.userShippingAccountNumber.disabled=true;
        document.getElementById("shippingAcc").style.visibility = "hidden"
        document.getElementById("shippingAcc").style.position = "absolute"
        document.getElementById("ShippingAccNumRow").style.visibility = "hidden"
        document.getElementById("ShippingAccNumRow").style.position = "absolute"
        document.getElementById("ShippingAccNumCol").style.visibility = "hidden"
        document.getElementById("ShippingAccNumCol").style.position = "absolute"
        document.getElementById("ShippingAccNumValueCol").style.visibility = "hidden"
        document.getElementById("ShippingAccNumValueCol").style.position = "absolute"
        document.getElementById("ShippingAccNumRowBlank").style.visibility = "hidden"
        document.getElementById("ShippingAccNumRowBlank").style.position = "absolute"
        document.getElementById("ShippingAccNumColBlank").style.visibility = "hidden"
        document.getElementById("ShippingAccNumColBlank").style.position = "absolute"
    }

}

function Samplecharges(){
    if(document.sampleForm.SampleCharges!=null)
    {
        if (document.sampleForm.SampleCharges.checked) {
            document.sampleForm.SampleCharges.value="1"
        }else{
            document.sampleForm.SampleCharges.value="0"
        }
    }
}

function SampleAddDate()
{
    if (document.sampleForm.eventDate.value != '')
    {
        var dt = new Date(document.sampleForm.eventDate.value );
        dt.setDate(dt.getDate() + 14);
        var curr_date = dt.getDate();
        var curr_month = dt.getMonth();
        curr_month++;
        var curr_year = dt.getFullYear();
        reminderDate = curr_month + "/" + curr_date + "/" + curr_year;
        document.sampleForm.wishlistReminderDate.value = reminderDate;
    }
}

function isEventDate(dtStr){		
    var daysInMonth = DaysArray(12)
    var pos1=dtStr.indexOf(dtCh)
    var pos2=dtStr.indexOf(dtCh,pos1+1)
    var strMonth=dtStr.substring(0,pos1)
    var strDay=dtStr.substring(pos1+1,pos2)
    var strYear=dtStr.substring(pos2+1)
    strYr=strYear
    if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
    if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
    for (var i = 1; i <= 3; i++) {
        if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
    }
    month=parseInt(strMonth)
    day=parseInt(strDay)
    year=parseInt(strYr)
    if (pos1==-1 || pos2==-1){
        return false
    }
    if (strMonth.length<1 || month<1 || month>12){
        return false
    }
    if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
        return false
    }
    if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
        return false
    }
    return true
}

////////////////////////////// validate sample request ends