var FinalErrorMessage="";
var Focus_array=[];
var i=0;

function Validate_email_index_from()
{
    Focus_array=[];
    i=0;

    FinalErrorMessage="";
    
    if(document.getElementById("text_email").value!="")
    {
        Validation_email("text_email");
    }
    else
    {
        // alert("Enter your valid email ID");
        SetErrorMessage_custom("Enter your email ID","text_email");
    }



    // return false;
    if(FinalErrorMessage!="")
    {
        alert(FinalErrorMessage);
    }
    if(FinalErrorMessage.length!="")
    {
        try{
            document.getElementById(Focus_array[0]).focus();
        }catch(e)
        {
        //alert(Focus_array[0]);
        }
        return false;
    }

    else
    {
        return true;
    }

    return false;
}
function OrderFomValidation()
{

    Focus_array=[];
    i=0;
    
    FinalErrorMessage="";
   // RequireValidation_integer("txt_quantity");
    
	RequiredValidation_product("chk");
    RequiredValidation_string("txt_billing_contact_name");
    RequiredValidation_string("txt_baddress1");

    RequiredValidation_string("txt_bcity");
    RequiredValidation_string("txt_bstate");
    RequiredValidation_string("txt_bcountry");
    RequireValidation_integer("txt_bzipcode");
    RequiredValidation_string("txt_bcontactnumber");

    

    RequiredValidation_string("txt_shipping_contact_name");
    RequiredValidation_string("txt_saddress1");
    RequiredValidation_string("txt_scity");
    RequiredValidation_string("txt_sstate");
    RequiredValidation_string("txt_scountry");
    RequireValidation_integer("txt_szipcode");
    RequiredValidation_string("txt_scontactnumber");

	

 

    //alert("1"+FinalErrorMessage+"0");
    CheckCardNumber();

     

    if(document.getElementById("chk_newsletters").checked || document.getElementById("txt_email").value!="")
    {
        Validation_email("txt_email");
    }
    else
    {
        SetErrorMessage_custom("","txt_email");
    }



    // return false;
    if(FinalErrorMessage.length!="")
    {
        try{
            document.getElementById(Focus_array[0]).focus();
        }catch(e)
        {
        //alert(Focus_array[0]);
        }
        return false;
    }
     
    else
    {
        return true;
    }

    return false;
    
}


function RequiredValidation_string(id)
{
    if(IsEmpty(id))
    {
		SetErrorMessage(id);
    }
    else
    {
		SetErrorMessage_custom("",id);
    }
}
function RequiredValidation_product(id)
{
    try{
    if(document.getElementById("chk1").checked || document.getElementById("chk2").checked || document.getElementById("chk3").checked || document.getElementById("chk4").checked )
    {
		SetErrorMessage_custom("",id);
		
    }
    else
    {
		SetErrorMessage(id);
		
    }
    }catch(e){}
}

function RequireValidation_integer(id)
{
	
	if(IsEmpty(id))
    {		
        SetErrorMessage(id);
    }
    else
    {
		
        if(!IsInteger(id))   // If not a integer
        {
			SetErrorMessage_custom("Invalid Number",id);
        }
        else
        {
            SetErrorMessage_custom("",id);
        }

    }
}
function updateProductDetails()
{

    Focus_array=[];
    i=0;

    FinalErrorMessage="";

    var id="product_price";

    if(IsEmpty(id))
    {
        SetErrorMessage(id);
    }
    else
    {
        if(!isFloatvalue(id))   // If not a integer

        {
            SetErrorMessage_custom("Invalid Price",id);
        }
        else
        {
            SetErrorMessage_custom("",id);
        }

    }

    return Final();
}

function Final()
{
    if(FinalErrorMessage.length!="")
    {
        try{
            document.getElementById(Focus_array[0]).focus();
        }catch(e)
        {
        //alert(Focus_array[0]);
        }
        return false;
    }

    else
    {
        return true;
    }

    return false;
}

