// JavaScript Document
function checkEmail(email)
{
	var reEmail = /^([A-Za-z0-9._])+@(\w)+(\.)(fr|com|com\.cn|net|cn|net\.cn|org|biz|info|gov|gov\.cn|edu|edu\.cn)/;
	if (!email.match(reEmail)&&email!="")
	{
		return false;
	}
	else return true;
}	
function checkbeforesubmit(formname){
	var errorMsg = "";

	form = document.forms[formname];

	rad_opinion_option = form.elements['rad_opinion_option'];
	sender_email = form.elements["sender_email"];
	/*
	txt_opinion_des1  = form.elements['txt_opinion_des1'];
	txt_opinion_des2  = form.elements['txt_opinion_des2'];
	txt_opinion_des3  = form.elements['txt_opinion_des3'];
	*/

	is_option_selected = false;
	
	for (counter = 0; counter < rad_opinion_option.length; counter++)
    {
        // If a radio button has been selected it will return true
        // (If not it will return false)
        if (rad_opinion_option[counter].checked)
        {
            is_option_selected = true;
            break; 
        }
    }
	
    if( is_option_selected == false ){
		errorMsg += Data_Message_Array["JS_FORM_BUG_OPTION_MISSING"] + "\n";
	}
	if(sender_email.value==''){
		errorMsg += Data_Message_Array["JS_FORM_CONTACT_EMAIL_MISSING"] + "\n";
	}else if(checkEmail(sender_email.value)==false){
		errorMsg += Data_Message_Array["JS_FORM_CONTACT_EMAIL_FORMAT"] + "\n";
	}

	/*
    if( (txt_opinion_des1.value=='') && (txt_opinion_des2.value=='') && (txt_opinion_des3.value=='') ){
		errorMsg += Data_Message_Array["JS_FORM_BUG_CONTENT_MISSING"] + "\n";
	}
	*/
	
	if( errorMsg != "" ){
		alert( errorMsg );
		errorMsg = "";
		return false;
	}
	else{
		
		document.getElementById("SubmitButton").disabled = true;
		
		document.getElementById("div_ajax_sending").style.display = "inline";
//		document.getElementById("div_ajax_sent").style.display = "none";

		xajax_PostFormOpinion(xajax.getFormValues(formname)); 
		return false;		
	}
}