/* specific form validation 
   author: Yanay.
   
	 for: openrg/supportf.html

*/

// include the generic validation functions. 
// make sure path is right:

function include(script_filename) {
    document.write('<' + 'script');
    document.write(' language="javascript"');
    document.write(' type="text/javascript"');
    document.write(' src="' + script_filename + '">');
    document.write('</' + 'script' + '>');
}
include('../validate_generic.js');


var focus_set;

//-------------------------------------------------------------------------------------------
// why += checkWebsite(theForm.company_url, "Company Website");

function vForm(theForm) {
	var why = "";
    		focus_set = false;  // when 1st focus is set (1st error detected) - do not keep moving the focus around.
		
		why += notEmpty(theForm.name, "Name", true);
		why += checkTags(theForm.name,"Name");

		why += checkTags(theForm.title,"Title");

		why += notEmpty(theForm.company_name, "Company Name", false);
		why += checkTags(theForm.company_name,"Company Name");

    		why += checkPhone(theForm.phone);

		why += checkEmail(theForm._from_address);
		why += checkTags(theForm._from_address,"Email Address");

		why += mustSelect(theForm._to_address, "Support Zone");
		why += mustSelect(theForm.Platform, "Platform");
		why += mustSelect(theForm._version, "Product Version");

		why += notEmpty(theForm.Problem_summary, "Problem Summary", true);
		why += checkTags(theForm.Problem_summary, "Problem Summary");

		why += notEmpty(theForm.Problem_Description, "Problem Description", false);
		why += checkTags(theForm.Problem_Description, "Problem Description");
		

    
		
		if(why!="") { display_errors( why ); return false; }

		return true;
}
//-------------------------------------------------------------------------------------------
// This function check & replace all tag signs in the form to prevent scripts
//
function checkTags(input,name){
        var list='';
		if (input.value.match(/<|>/)){
			list+="["+name+"] use forbiden chars \"<\" or \">\"\n";
			input.parentNode.parentNode.className = fields_error_class;
		}
	return list;			
}





