// JavaScript Document
// ------------- This is Script For Admin Pages----------------------//

//newslettervalidation

function newslettervalidation(){
    var emailid = document.newsletter.emailid.value;
    if (emailid == "")
    { 
        alert ("Please enter the Email Address");
        document.newsletter.emailid.focus();
        return false;
    }	
    if (!validateEmail(document.newsletter.emailid.value,1,1)) 
    {
        document.newsletter.emailid.focus();
        return false;
    }
}
function newartist_validation()
{
    var name = document.newartist.artist_name.value;
    if (name == "")
    { 
        alert ("Please enter the Artist Name");
        document.newartist.artist_name.focus();
        return false;
    }	
    var email = document.newartist.artist_email.value;
    if (email == "")
    { 
        alert ("Please enter the Email Address");
        document.newartist.artist_email.focus();
        return false;
    }	
    if (!validateEmail(document.newartist.artist_email.value,1,1)) 
    {
        document.newartist.artist_email.focus();
        return false;
    }
}

function createalbum_validate()
{
    var name= document.album.album_name.value;
    if (name== "" )
    { 
        alert ("Please enter Album Name");
        document.album.album_name.focus();
        return false;
    }
    var price= document.album.price.value;
    if (price== "" )
    { 
        alert ("Please enter Album Price");
        document.album.price.focus();
        return false;
    }
    if (isNaN(document.album.price.value))
    { 
        alert ("Price must be Numeric");
        document.album.price.focus();
        return false;
    }
    var invalidChars = '\/\'\\ ";:?!()[]\{\}^|,-+*';
    for (i=0; i<invalidChars.length; i++) {
        if (price.indexOf(invalidChars.charAt(i),0) > -1) {
            alert('Album Price must be Numeric');
            document.frm_accountinfo.price.focus();
            return false;
        }		 
    }
}
//Login Validation
function login_validate(){
    if(document.Login.UserName.value == "")
    {
        alert("Plase enter the Username.");
        document.Login.UserName.focus();
        return false;
    }
    if(document.Login.Password.value == "")
    {
        alert("Plase enter the password.");
        document.Login.Password.focus();
        return false;
    }
}

// To Validate Password Field in changepassword file
function pass_validate()
{
    var oldpassword = document.ChangePass.oldpassword.value;
    if (oldpassword == "" )
    { 
        alert ("Please enter Your Old Password");
        document.ChangePass.oldpassword.focus();
        return false;
    }
    var newpassword = document.ChangePass.newpassword.value;
    if (newpassword == "" )
    { 
        alert ("Please enter Your New Password");
        document.ChangePass.newpassword.focus();
        return false;
    }
    /*		 var newpassword = document.ChangePass.newpassword.value;
    if (document.ChangePass.newpassword.value.length < 6)
    { 
        alert ("New Password must be greater than 5 character");
        document.ChangePass.newpassword.focus();
        return false;
    }
    */		 var Conpassword2 = document.ChangePass.Conpassword2.value;
    if (Conpassword2 == "" )
    { 
        alert ("Please enter Your Confirm Password");
        document.ChangePass.Conpassword2.focus();
        return false;
    }
    var Conpassword2 = document.ChangePass.Conpassword2.value;
    if (document.ChangePass.Conpassword2.value != document.ChangePass.newpassword.value)
    { 
        alert ("Paasword and Confirm Password must be same");
        document.ChangePass.Conpassword2.focus();
        return false;
    }
}

//
function calldel(m)
{
    if(!confirm(m))
    {
        return false;
    }
    else
        return true;
}

// Valid Email  Script
function validateEmail(addr,man,db) {
    if (addr == '' && man) {
        if (db) alert('Email address is mandatory');
        return false;
    }
    var invalidChars = '\/\'\\ ";:?!()[]\{\}^|,';
    for (i=0; i<invalidChars.length; i++) {
        if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
            if (db) alert('Email address contains invalid characters');
            return false;
        }
    }
    for (i=0; i<addr.length; i++) {
        if (addr.charCodeAt(i)>127) {
            if (db) alert("Email address contains non ascii characters.");
            return false;
        }
    }

    var atPos = addr.indexOf('@',0);
    if (atPos == -1) {
        if (db) alert('Email address must contain an @');
        return false;
    }
    if (atPos == 0) {
        if (db) alert('Email address must not start with @');
        return false;
    }
    if (addr.indexOf('@', atPos + 1) > - 1) {
        if (db) alert('Email address must contain only one @');
        return false;
    }
    if (addr.indexOf('.', atPos) == -1) {
        if (db) alert('Email address must contain a period in the domain name');
        return false;
    }
    if (addr.indexOf('@.',0) != -1) {
        if (db) alert('period must not immediately follow @ in email address');
        return false;
    }
    if (addr.indexOf('.@',0) != -1){
        if (db) alert('period must not immediately precede @ in email address');
        return false;
    }
    if (addr.indexOf('..',0) != -1) {
        if (db) alert('two periods must not be adjacent in email address');
        return false;
    }
    var suffix = addr.substring(addr.lastIndexOf('.')+1);
    if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
        if (db) alert('invalid primary domain in email address');
        return false;
    }
    return true;
}

/////Member Validation
//script for add member
function member_reg(type)
{	
    var firstname = document.CustomersForm.firstname.value;
    if (firstname == "" )
    { 
        alert ("Please enter the First Name");
        document.CustomersForm.firstname.focus();
        return false;
    }
    var lastname = document.CustomersForm.lastname.value; 
    if (lastname == "")
    { 
        alert ("Please enter the Last Name");
        document.CustomersForm.lastname.focus();
        return false;
    }

    var address1 = document.CustomersForm.address.value;
    if (address1 == "" )
    { 
        alert ("Please enter the Address");
        document.CustomersForm.address.focus();
        return false;
    }
    var city=document.CustomersForm.city.value;
    if (city=="" )
    { 
        alert ("Please enter the City Name");
        document.CustomersForm.city.focus();
        return false;
    }
    var state = document.CustomersForm.state.value;
    if (state == "")
    { 
        alert ("Please Choose the State Name");
        document.CustomersForm.state.focus();
        return false;
    }
    var zipcode = document.CustomersForm.zipcode.value;
    if (zipcode == "" )
    { 
        alert ("Please enter the Post Code");
        document.CustomersForm.zipcode.focus();
        return false;
    }	
    if (isNaN(document.CustomersForm.zipcode.value))
    { 
        alert ("Post Code must be numeric");
        document.CustomersForm.zipcode.focus();
        return false;
    }	
    var country=document.CustomersForm.country.value;
    if (country == "")
    { 
        alert ("Plese Enter Country");
        document.CustomersForm.country.focus();
        return false;
    }
    var phoneno = document.CustomersForm.phoneno.value;
    if (phoneno == "")
    { 
        alert ("Please enter the Phone Number");
        document.CustomersForm.phoneno.focus();
        return false;
    }	
    if (isNaN(document.CustomersForm.phoneno.value))
    { 
        alert ("Phone Number must be numeric");
        document.CustomersForm.phoneno.focus();
        return false;
    }	

    if(type != "edit")
    {
        var emailid = document.CustomersForm.emailid.value;
        if (emailid == "")
        { 
            alert ("Please enter the Email Address");
            document.CustomersForm.emailid.focus();
            return false;
        }	
        if (!validateEmail(document.CustomersForm.emailid.value,1,1)) 
        {
            document.CustomersForm.emailid.focus();
            return false;
        }	
        var  password= document.CustomersForm.password.value;
        if (password == "")
        { 
            alert ("Please enter the password");
            document.CustomersForm.password.focus();
            return false;
        }	
        var  confirmpass= document.CustomersForm.confirmpass.value;
        if (confirmpass == "")
        { 
            alert ("Please enter the Confirm Password");
            document.CustomersForm.confirmpass.focus();
            return false;
        }	
        if (password != confirmpass)
        { 
            alert ("Password and Confirm Password must be the same");
            document.CustomersForm.confirmpass.focus();
            return false;
        }	
    }
}

/////Member Login Validation
//script for add member
function member_login()
{	
    var  Username= document.loginform.username.value;
    if (Username == "")
    { 
        alert ("Please enter the Email Address");
        document.loginform.username.focus();
        return false;
    }
    if (!validateEmail(document.loginform.username.value,1,1)) 
    {
        document.loginform.username.focus();
        return false;
    }
    var  password= document.loginform.password.value;
    if (password == "")
    { 
        alert ("Please enter the password");
        document.loginform.password.focus();
        return false;
    }	
}


//script for Store Search validation member
function searchvalidate()
{	
    var  searchstr= document.search_frm.searchstr.value;
    if (searchstr == "")
    { 
        alert ("Please enter the Search Term");
        document.search_frm.searchstr.focus();
        return false;
    }	
}


// To Validate Password Field in changepassword file
function pass_validate()
{
    var Old = document.frm_change.Old.value;
    if (Old == "" )
    { 
        alert ("Please enter Your Old Password");
        document.frm_change.Old.focus();
        return false;
    }
    var Password = document.frm_change.Password.value;
    if (Password == "" )
    { 
        alert ("Please enter Your New Password");
        document.frm_change.Password.focus();
        return false;
    }
    var Conpassword2 = document.frm_change.Conpassword2.value;
    if (Conpassword2 == "" )
    { 
        alert ("Please enter Your Confirm Password");
        document.frm_change.Conpassword2.focus();
        return false;
    }
    var Conpassword2 = document.frm_change.Conpassword2.value;
    if (document.frm_change.Conpassword2.value != document.frm_change.Password.value)
    { 
        alert ("Paasword and Confirm Password must be same");
        document.frm_change.Conpassword2.focus();
        return false;
    }
}


function opencart(rows)
{
    var len=document.frm_cart.ONE.length;
    if(rows == 1)
    {
        quantity = document.frm_cart.ONE.value;
        stockvalue = document.frm_cart.STOCK.value;
        original = document.frm_cart.STOCK1.value;
        if( (quantity == ""))
        {
            alert("Type the valid quantity");
            document.frm_cart.ONE.focus();
            document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
            return false;
        }
        else if((quantity == 0))
        {
            alert("Type the valid quantity");
            document.frm_cart.ONE.focus();
            document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
            return false;
        }

        else if(isNaN(quantity))
        {
            alert("Type the valid quantity");
            document.frm_cart.ONE.focus();
            document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
            return false;
        }
        else if((quantity.indexOf("-") >= 0))
        {
            alert("Type the valid quantity");
            document.frm_cart.ONE.focus();
            document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
            return false;
        }
        else if((quantity.indexOf(".") >= 0))
        {
            alert("Type the valid quantity");
            document.frm_cart.ONE.focus();
            document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
            return false;
        }
        else if((quantity > 65535))
        {
            alert("Type the valid quantity");
            document.frm_cart.ONE.focus();
            document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
            return false;
        }
        //			if(parseInt(quantity) > parseInt(stockvalue)){
        //						alert("Quantity is out of stock");
        //						document.frm_cart.ONE.focus();
        //						document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
        //						return false;
        //				}		 
    }
    else
    {
        var flag=0;
        for(var index=0;index<rows;index++)
        {
            quantity = document.frm_cart.ONE[index].value;
            stockvalue = document.frm_cart.STOCK[index].value;
            original = document.frm_cart.STOCK1[index].value;
            if( (quantity == ""))
            {
                alert("Type the valid quantity");
                document.frm_cart.ONE[index].focus();
                document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
                return false;
            }
            else if((quantity == 0))
            {
                alert("Type the valid quantity");
                document.frm_cart.ONE[index].focus();
                document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
                return false;
            }

            else if(isNaN(quantity))
            {
                alert("Type the valid quantity");
                document.frm_cart.ONE[index].focus();
                document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
                return false;
            }
            else if((quantity.indexOf("-") >= 0))
            {
                alert("Type the valid quantity");
                document.frm_cart.ONE[index].focus();
                document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
                return false;
            }
            else if((quantity.indexOf(".") >= 0))
            {
                alert("Type the valid quantity");
                document.frm_cart.ONE[index].focus();
                document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
                return false;
            }
            else if((quantity > 65535))
            {
                alert("Type the valid quantity");
                document.frm_cart.ONE[index].focus();
                document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
                return false;
            }
            //	if(parseInt(quantity) > parseInt(stockvalue)){
            //						alert("Quantity is out of stock");
            //						document.frm_cart.ONE[index].focus();
            //						document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
            //						return false;
            //				}
            //						
        }
    }
}

function val()
{
    if(document.checkout_frm.varEmail.value == "")
    {
        alert("Please enter the Email Address");
        document.checkout_frm.varEmail.focus();
        return false;
    }
    if (!validateEmail(document.checkout_frm.varEmail.value,1,1)) 
    {
        document.checkout_frm.varEmail.focus();
        return false;
    }
    if(document.checkout_frm.ConfirmEmail.value == "")
    {
        alert("Please enter the Confirm - Email Address");
        document.checkout_frm.ConfirmEmail.focus();
        return false;
    }
    if(document.checkout_frm.varEmail.value!= document.checkout_frm.ConfirmEmail.value)
    {
        alert("Please enter correct Confirm - Email Address");
        document.checkout_frm.ConfirmEmail.focus();
        return false;
    }
    /*//------script for billing address --------------------------//
    if(document.checkout_frm.varFirstName.value == "")
    {
        alert("Please enter the First Name");
        document.checkout_frm.varFirstName.focus();
        return false;
    }
    if(document.checkout_frm.varLastName.value == "")
    {
        alert("Please enter the Last Name");
        document.checkout_frm.varLastName.focus();
        return false;
    }
    if(document.checkout_frm.varAddress.value == "")
    {
        alert("Please enter the  Address");
        document.checkout_frm.varAddress.focus();
        return false;
    }
    if(document.checkout_frm.varCity.value == "")
    {
        alert("Please enter the City");
        document.checkout_frm.varCity.focus();
        return false;
    }
    if(document.checkout_frm.varState.value == "Choose")
    {
        alert("Please select the State");
        document.checkout_frm.varState.focus();
        return false;
    }

    if(document.checkout_frm.varPostcode.value =="")
    {
        alert("Please enter the Zip Code");
        document.checkout_frm.varPostcode.focus();
        return false;
    }	
    if(isNaN(document.checkout_frm.varPostcode.value))
    {
        alert("Zip Code Must ber Numeric");
        document.checkout_frm.varPostcode.focus();
        return false;
    }
    if(document.checkout_frm.varPhoneNo.value == "")
    {
        alert("Please enter the Phone Number");
        document.checkout_frm.varPhoneNo.focus();
        return false;
    }
    if(isNaN(document.checkout_frm.varPhoneNo.value))
    {
        alert("Phone Number Must ber Numeric");
        document.checkout_frm.varPhoneNo.focus();
        return false;
    }
    //--------------Code for shipping address section-------------------//
    if(document.checkout_frm.varShipFirstName.value == "")
    {
        alert("Please enter the Shipping First Name");
        document.checkout_frm.varShipFirstName.focus();
        return false;
    }

    if(document.checkout_frm.varShipLastName.value == "")
    {
        alert("Please enter the Shipping Last Name");
        document.checkout_frm.varShipLastName.focus();
        return false;
    }
    if(document.checkout_frm.varShipAddress.value == "")
    {
        alert("Please enter the Shipping Address");
        document.checkout_frm.varShipAddress.focus();
        return false;
    }
    if(document.checkout_frm.varShipCity.value == "")
    {
        alert("Please enter the Shipping City");
        document.checkout_frm.varShipCity.focus();
        return false;
    }
    if(document.checkout_frm.varShipState.value == "Choose")
    {
        alert("Please enter the Shipping State");
        document.checkout_frm.varShipState.focus();
        return false;
    }

    if(document.checkout_frm.varShipZip.value =="")
    {
        alert("Please enter the Shipping Zip Code");
        document.checkout_frm.varShipZip.focus();
        return false;
    }	
    if(isNaN(document.checkout_frm.varShipZip.value))
    {
        alert("Shipping Zip Code Must ber Numeric");
        document.checkout_frm.varShipZip.focus();
        return false;
    }
    if(document.checkout_frm.varShipPhone.value == "")
    {
        alert("Please enter the Shipping Phone Number");
        document.checkout_frm.varShipPhone.focus();
        return false;
    }
    if(isNaN(document.checkout_frm.varShipPhone.value))
    {
        alert("Shipping Phone Number Must ber Numeric");
        document.checkout_frm.varShipPhone.focus();
        return false;
    }
    if(document.checkout_frm.cardholder_name.value == "")
    {
        alert("Please enter the Card name");
        document.checkout_frm.cardholder_name.focus();
        return false;
    }
    if(document.checkout_frm.txt_cctype.value == "")
    {
        alert("Please Choose the Card Type");
        document.checkout_frm.txt_cctype.focus();
        return false;
    }
    if(document.checkout_frm.card_number.value == "")
    {
        alert("Please enter the Card No");
        document.checkout_frm.card_number.focus();
        return false;
    }
    if(isNaN(document.checkout_frm.card_number.value))
    {
        alert("Card  Number Must ber Numeric");
        document.checkout_frm.card_number.focus();
        return false;
    }
    if(document.checkout_frm.card_exp_month.value == "")
    {
        alert("Please Choose the Expired Month");
        document.checkout_frm.card_exp_month.focus();
        return false;
    }
    if(document.checkout_frm.card_exp_year.value == "")
    {
        alert("Please Choose the Expired Year");
        document.checkout_frm.card_exp_year.focus();
        return false;
    }
    if(document.checkout_frm.cvvcode.value == "")
    {
        alert("Please enter the cvv code");
        document.checkout_frm.cvvcode.focus();
        return false;
    }
    if(isNaN(document.checkout_frm.cvvcode.value))
    {
        alert("Cvv Code Must ber Numeric");
        document.checkout_frm.cvvcode.focus();
        return false;
    }
    */
}

function openwindow(field,value){
    //alert(document.viewcart.chk_list.length);
    //var len;
    len = document.frm_cart.chk_list.length;
    //len=len+1;
    len2=0;
    //alert(len);
    for (i = 0; i < len; i++) 
    {
        var chkname	=	document.frm_cart.chk_list[i].checked;
        //alert(chkname);
        //alert(len2);
        if (chkname == false) 
        {
            len2 = len2 + 1;
        }

    }
    if(len == len2)
    {
        //alert(len2);
        alert("Please Select Atleast one");
        return false;
    }

    document.frm_cart.action="viewcart.php?fun=del";

    document.frm_cart.submit();

}

////Artists Validation
function artists_validation()
{	
    var band_name = document.artistsregister.band_name.value;
    if (band_name == "" )
    { 
        alert ("Please enter the Label Name");
        document.artistsregister.band_name.focus();
        return false;
    }
    var country=document.artistsregister.genre.value;
    if (country == "")
    { 
        alert ("Please Choose Genre");
        document.artistsregister.genre.focus();
        return false;
    }	
    var firstname = document.artistsregister.firstname.value;
    if (firstname == "" )
    { 
        alert ("Please enter the First Name");
        document.artistsregister.firstname.focus();
        return false;
    }
    var surname = document.artistsregister.surname.value; 
    if (surname == "")
    { 
        alert ("Please enter the Surname");
        document.artistsregister.surname.focus();
        return false;
    }
    var emailid = document.artistsregister.email.value;
    if (emailid == "")
    { 
        alert ("Please enter the Email Address");
        document.artistsregister.email.focus();
        return false;
    }	
    if (!validateEmail(document.artistsregister.email.value,1,1)) 
    {
        document.artistsregister.email.focus();
        return false;
    }
    var password1 = document.artistsregister.password1.value; 
    if (password1 == "")
    { 
        alert ("Please enter the Password");
        document.artistsregister.password1.focus();
        return false;
    }
    var password2 = document.artistsregister.password2.value; 
    if (password2 == "")
    { 
        alert ("Please retype the Password");
        document.artistsregister.password2.focus();
        return false;
    }
    if (password1 != password2)
    { 
        alert ("Password and Retype Password must be the same");
        document.artistsregister.password2.focus();
        return false;
    }


    var address1 = document.artistsregister.address1.value;
    if (address1 == "" )
    { 
        alert ("Please enter the Address Line1");
        document.artistsregister.address1.focus();
        return false;
    }
    var address2 = document.artistsregister.address2.value;
    if (address2 == "" )
    { 
        alert ("Please enter the Address Line2");
        document.artistsregister.address2.focus();
        return false;
    }	 
    var postcode = document.artistsregister.postcode.value;
    if (postcode == "" )
    { 
        alert ("Please enter the Post Code");
        document.artistsregister.postcode.focus();
        return false;
    }	
    if (isNaN(document.artistsregister.postcode.value))
    { 
        alert ("Post Code must be numeric");
        document.artistsregister.postcode.focus();
        return false;
    }		
    var country=document.artistsregister.country.value;
    if (country == "")
    { 
        alert ("Plese Choose the Country");
        document.artistsregister.country.focus();
        return false;
    }	
}

function artist_validate()
{	

    var  Username= document.artist.artist_username.value;
    if (Username == "")
    { 
        alert ("Please enter the Email Address");
        document.artist.artist_username.focus();
        return false;
    }	

    if (!validateEmail(document.artist.artist_username.value,1,1)) 
    {
        document.artist.artist_username.focus();
        return false;
    }
    var  password= document.artist.artist_password.value;
    if (password == "")
    { 
        alert ("Please enter the password");
        document.artist.artist_password.focus();
        return false;
    }	
}

function forgotpwd_validate()
{		 
    var emailid = document.forgot.emailaddress.value;
    if (emailid == "")
    { 
        alert ("Please enter the Email Address");
        document.forgot.emailaddress.focus();
        return false;
    }	
    if (!validateEmail(document.forgot.emailaddress.value,1,1)) 
    {
        document.forgot.emailaddress.focus();
        return false;
    }

}

////Artists Account Validation
function accounttype()
{	
    var primary = document.artistsaccount.primary.value;
    var standard=document.artistsaccount.standard.value;
    var premier = document.artistsaccount.premier.value;
    if (primary == "0" && standard == "0" && premier == "0" )
    { 
        alert ("Please enter the Number of Accounts");
        document.artistsaccount.primary.focus();
        return false;
    }
    /*var country=document.artistsaccount.primary.value;
    if (country == "")
    { 
        alert ("Plese Choose Genre");
        document.artistsaccount.primary.focus();
        return false;
    }	
    var firstname = document.artistsaccount.firstname.value;
    if (firstname == "" )
    { 
        alert ("Please enter the First Name");
        document.artistsaccount.primary.focus();
        return false;
    }
    */
}

////Artists Validation
function artistprofile_validation()
{	
    /*var band_name = document.artistsregister.band_name.value;
    if (band_name == "" )
    { 
        alert ("Please enter the Label Name");
        document.artistsregister.band_name.focus();
        return false;
    }
    */
    var country=document.artistsregister.genre.value;
    if (country == "")
    { 
        alert ("Please Choose Genre");
        document.artistsregister.genre.focus();
        return false;
    }	
    var firstname = document.artistsregister.firstname.value;
    if (firstname == "" )
    { 
        alert ("Please enter the First Name");
        document.artistsregister.firstname.focus();
        return false;
    }
    var surname = document.artistsregister.surname.value; 
    if (surname == "")
    { 
        alert ("Please enter the Surname");
        document.artistsregister.surname.focus();
        return false;
    }	
    var emailid = document.artistsregister.email.value;
    if (emailid == "")
    { 
        alert ("Please enter the Email Address");
        document.artistsregister.email.focus();
        return false;
    }	
    if (!validateEmail(document.artistsregister.email.value,1,1)) 
    {
        document.artistsregister.email.focus();
        return false;
    }
    var address1 = document.artistsregister.address1.value;
    if (address1 == "" )
    { 
        alert ("Please enter the Address Line1");
        document.artistsregister.address1.focus();
        return false;
    }
    var address2 = document.artistsregister.address2.value;
    if (address2 == "" )
    { 
        alert ("Please enter the Address Line2");
        document.artistsregister.address2.focus();
        return false;
    }	 
    var postcode = document.artistsregister.postcode.value;
    if (postcode == "" )
    { 
        alert ("Please enter the Post Code");
        document.artistsregister.postcode.focus();
        return false;
    }	
    if (isNaN(document.artistsregister.postcode.value))
    { 
        alert ("Post Code must be numeric");
        document.artistsregister.postcode.focus();
        return false;
    }		
    var country=document.artistsregister.country.value;
    if (country == "")
    { 
        alert ("Plese Choose the Country");
        document.artistsregister.country.focus();
        return false;
    }	
    /*  var country=document.artistsregister.rec_company.value;
    if (country == "")
    { 
        alert ("Plese enter the record company");
        document.artistsregister.rec_company.focus();
        return false;
    }
    */
}

function addtrackvalidation()
{	

    var  track_name= document.artisttrack.track_name.value;
    if (track_name == "")
    { 
        alert ("Please enter the Track Name");
        document.artisttrack.track_name.focus();
        return false;
    }	
    var  track_name= document.artisttrack.artist_name.value;
    if (track_name == "")
    { 
        alert ("Please choose the Artist Name");
        document.artisttrack.artist_name.focus();
        return false;
    }	

    if (document.artisttrack.release_date.value!= "" )
    { 
        var dtCh= "-";
        var minYear=1900;
        var maxYear=2100;

        function isInteger(s){
            var i;
            for (i = 0; i < s.length; i++){   
                // Check that current character is number.
                var c = s.charAt(i);
                if (((c < "0") || (c > "9"))) return false;
            }
            // All characters are numbers.
            return true;
        }

        function stripCharsInBag(s, bag){
            var i;
            var returnString = "";
            // Search through string's characters one by one.
            // If character is not in bag, append to returnString.
            for (i = 0; i < s.length; i++){   
                var c = s.charAt(i);
                if (bag.indexOf(c) == -1) returnString += c;
            }
            return returnString;
        }

        function daysInFebruary (year){
            // February has 29 days in any year evenly divisible by four,
            // EXCEPT for centurial years which are not also divisible by 400.
            return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
        }
        function DaysArray(n) {
            for (var i = 1; i <= n; i++) {
                this[i] = 31
                if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
                if (i==2) {this[i] = 29}
            } 
            return this
        }

        function isDate(dtStr){
            var daysInMonth = DaysArray(12)
            var pos1=dtStr.indexOf(dtCh)
            var pos2=dtStr.indexOf(dtCh,pos1+1)
            var strDay=dtStr.substring(0,pos1)
            var strMonth=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){
                alert("The date format should be : dd-mm-yyyy")
                return false
            }
            if (strMonth.length<1 || month<1 || month>12){
                alert("Please enter a valid month")
                return false
            }
            if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
                alert("Please enter a valid day")
                return false
            }
            if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
                alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
                return false
            }
            if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
                alert("Please enter a valid date")
                return false
            }
            return true
        }


        var dt=document.artisttrack.release_date
        if (isDate(dt.value)==false){
            dt.focus();
            return false;
        }

    }

    return true;

}


function extractNumber(obj, decimalPlaces, allowNegative)
{
    var temp = obj.value;

    // avoid changing things if already formatted correctly
    var reg0Str = '[a-z][0-9]@*';
    if (decimalPlaces > 0) {
        reg0Str += '\\.?[a-z][0-9]@{0,' + decimalPlaces + '}';
    } else if (decimalPlaces < 0) {
        reg0Str += '\\.?[a-z][0-9]@*';
    }
    reg0Str = allowNegative ? '^-?' + reg0Str : '^' + reg0Str;
    reg0Str = reg0Str + '$';
    var reg0 = new RegExp(reg0Str);
    if (reg0.test(temp)) return true;

    // first replace all non numbers
    var reg1Str = '[^a-z0-9@' + (decimalPlaces != 0 ? '.' : '') + (allowNegative ? '-' : '') + ']';
    var reg1 = new RegExp(reg1Str, 'g');
    temp = temp.replace(reg1, '');

    if (allowNegative) {
        // replace extra negative
        var hasNegative = temp.length > 0 && temp.charAt(0) == '-';
        var reg2 = /-/g;
        temp = temp.replace(reg2, '');
        if (hasNegative) temp = '-' + temp;
    }

    if (decimalPlaces != 0) {
        var reg3 = /\./g;
        var reg3Array = reg3.exec(temp);
        if (reg3Array != null) {
            // keep only first occurrence of .
            //  and the number of places specified by decimalPlaces or the entire string if decimalPlaces < 0
            var reg3Right = temp.substring(reg3Array.index + reg3Array[0].length);
            reg3Right = reg3Right.replace(reg3, '');
            reg3Right = decimalPlaces > 0 ? reg3Right.substring(0, decimalPlaces) : reg3Right;
            temp = temp.substring(0,reg3Array.index) + '.' + reg3Right;
        }
    }

    obj.value = temp;
}
