﻿
function ClearForm() 
{
    location.href = "contacts.asp?reason=" + document.form.ctype.value
}
function SubmitPage() 
{

    if (document.form.ctype.value == "contact" || document.form.ctype.value == "sales")
    {
		if (document.form.first_name.value == "" ||
			document.form.last_name.value == "" ||
			document.form.company_name.value == "" ||
			document.form.phone_number.value == "" ||
			document.form.email_address.value == "" ||
			document.form.message.value == "")
			{
				alert("Please fill in all required fields");
				return false;
            }
    } else if(document.form.ctype.value == "support")
    {
		if (document.form.first_name.value == "" ||
			document.form.last_name.value == "" ||
			document.form.company_name.value == "" ||
			document.form.phone_number.value == "" ||
			document.form.email_address.value == "" ||
			document.form.message.value == "" ||
			document.form.status.value == "" ||
			document.form.reason.value == "" ||
			document.form.subject.value == "" ||
			document.form.message.value == "")
			{
				alert("Please fill in all required fields");
				return false;
			}
	}
	else
	{
	    
	}
}
function LoadFormType(cType)
{	
	// ADDED BY MATT TO FIX SUBMITAL ERRORS
	try{
		if(cType == "contact" || cType == "sales" || cType == "training")
		{
			if(CheckControl("Support_Status"))
			{
			    document.getElementById("Support_Status").style.display = "none";
			    document.getElementById("Support_Status").style.position = "absolute";
			}
			if(CheckControl("Support_CaseReason"))
			{
			    document.getElementById("Support_CaseReason").style.display= "none";
			    document.getElementById("Support_CaseReason").style.position = "absolute";
			}
			if(CheckControl("Support_Priority"))
			{
			    document.getElementById("Support_Priority").style.display= "none";
			    document.getElementById("Support_Priority").style.position = "absolute";
			}
			if(CheckControl("Support_Category"))
			{
			    document.getElementById("Support_Category").style.display= "none";
			    document.getElementById("Support_Category").style.position = "absolute";
			}
			if(CheckControl("Support_Subject"))
			{
			    document.getElementById("Support_Subject").style.display= "none";
			    document.getElementById("Support_Subject").style.position = "absolute";			
            }
			if(CheckControl("trMessage"))
			{
			    document.getElementById("trMessage").style.display= "none";
			    document.getElementById("trMessage").style.position = "absolute";
			}
			if(CheckControl("trDesiredTraning"))
			{
			    document.getElementById("trDesiredTraning").style.display= "none";
			    document.getElementById("trDesiredTraning").style.position = "absolute";
			}
			if(CheckControl("ReqMarkCompany"))
			{
			    document.getElementById("ReqMarkCompany").style.display= "none";
			    document.getElementById("ReqMarkCompany").style.position = "absolute";
			}
			
			if(cType == "contact" || cType == "sales")
			{
			    if(CheckControl("trMessage"))
			    {
				    document.getElementById("trMessage").style.display= "";
				    document.getElementById("trMessage").style.position = "relative";			    
			    }
			    
				//THIS CODE WILL DISABLE VALIDATOR CONTROLS, NEED TO PASS CLIENT ID OF CONTROLS TO BELOW CODE...
				if(CheckControl(iTrainingCID))
			    {
				    var myVal = document.getElementById(iTrainingCID);
				    ValidatorEnable(myVal, false);  
	            }
	            if(CheckControl(iCompanyNameCID))
			    {
				    var myVal2 = document.getElementById(iCompanyNameCID);
				    ValidatorEnable(myVal2, false); 
	            }                 
	            if(CheckControl(iMessageCID))
			    {
				    var myVal3 = document.getElementById(iMessageCID);
				    ValidatorEnable(myVal3, true);
	            }
				
				  
				//END CODE
			}
			else if(cType == "training")
			{
			    if(CheckControl("trDesiredTraning"))
			    {
				    document.getElementById("trDesiredTraning").style.display= "";
				    document.getElementById("trDesiredTraning").style.position = "relative";
				}
			    if(CheckControl("ReqMarkCompany"))
			    {
				    document.getElementById("ReqMarkCompany").style.display= "";
				    document.getElementById("ReqMarkCompany").style.position = "relative";
                }
				//THIS CODE WILL DISABLE VALIDATOR CONTROLS, NEED TO PASS CLIENT ID OF CONTROLS TO BELOW CODE...
	//			    var myVal = document.getElementById(iMessageCID);
	//                ValidatorEnable(myVal, false);  
	            
	            if(CheckControl(iTrainingCID))
			    {
				    var myVal = document.getElementById(iTrainingCID);
				    ValidatorEnable(myVal, true);  
	            }
	            if(CheckControl(iCompanyNameCID))
			    {
				    var myVal2 = document.getElementById(iCompanyNameCID);
				    ValidatorEnable(myVal2, true);                  
	            }
	            if(CheckControl(iMessageCID))
			    {
				    var myVal3 = document.getElementById(iMessageCID);
				    ValidatorEnable(myVal3, false);  
				}
				//END CODE
			}
	       
		} 
		else if(cType == "support") 
		{	
		    if(CheckControl("Support_Status"))
            {	    
			    document.getElementById("Support_Status").style.display= "";
			    document.getElementById("Support_Status").style.position = "relative";
			}
			if(CheckControl("Support_CaseReason"))
            {
			    document.getElementById("Support_CaseReason").style.display= "";
			    document.getElementById("Support_CaseReason").style.position = "relative";
			}
			if(CheckControl("Support_Priority"))
            {
                document.getElementById("Support_Priority").style.display= "";
			    document.getElementById("Support_Priority").style.position = "relative";
			}
			if(CheckControl("Support_Category"))
            {
                document.getElementById("Support_Category").style.display= "";
			    document.getElementById("Support_Category").style.position = "relative";
			}
			if(CheckControl("Support_Subject"))
            {
                document.getElementById("Support_Subject").style.display= "";
			    document.getElementById("Support_Subject").style.position = "relative";
			}
			if(CheckControl("trMessage"))
            {
                document.getElementById("trMessage").style.display= "";
			    document.getElementById("trMessage").style.position = "relative";
			}
			if(CheckControl("trDesiredTraning"))
			{
			    document.getElementById("trDesiredTraning").style.display= "none";
			    document.getElementById("trDesiredTraning").style.position = "absolute";
			}
			if(CheckControl("ReqMarkCompany"))
			{
			    document.getElementById("ReqMarkCompany").style.display= "none";
			    document.getElementById("ReqMarkCompany").style.position = "absolute";
			}
			//THIS CODE WILL DISABLE VALIDATOR CONTROLS, NEED TO PASS CLIENT ID OF CONTROLS TO BELOW CODE...
			if(CheckControl(iTrainingCID))
            {
			    var myVal = document.getElementById(iTrainingCID);
			    ValidatorEnable(myVal, false);  
	        }
	        if(CheckControl(iCompanyNameCID))
            {    
			    var myVal2 = document.getElementById(iCompanyNameCID);
			    ValidatorEnable(myVal2, false);                  
	        }
	        if(CheckControl(iMessageCID))
            {    
			    var myVal3 = document.getElementById(iMessageCID);
			    ValidatorEnable(myVal3, true);  
			}
			//END CODE
	        
		}
		else
		{
		    if(CheckControl("trMessage"))
            {
			    document.getElementById("trMessage").style.display= "";
			    document.getElementById("trMessage").style.position = "relative";
			}
			//THIS CODE WILL DISABLE VALIDATOR CONTROLS, NEED TO PASS CLIENT ID OF CONTROLS TO BELOW CODE...
			if(CheckControl(iTrainingCID))
            {
                var myVal = document.getElementById(iTrainingCID);
			    ValidatorEnable(myVal, false);  
	        }
	        if(CheckControl(iCompanyNameCID))
            {    
			    var myVal2 = document.getElementById(iCompanyNameCID);
			    ValidatorEnable(myVal2, false);                  
	        }
	        if(CheckControl(iMessageCID))
            {    
			    var myVal3 = document.getElementById(iMessageCID);
			    ValidatorEnable(myVal3, true);  
			}
			//END CODE
		}

	//ADDED BY MATT TO FIX SUBMITTAL ERRORS
	}catch(e){}
}

// ADDED BY DHRUPIT TO CHECK EXISTANCE OF CONTROL
function CheckControl(ccontrol)
{
    if(document.getElementById(ccontrol))
    {
        return true;
    }
    else
    {
        return false;
    }
}
