/* 
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
$(function(){
    fnAutoLoad();
});

/**
* <p>Functions to execute on Page Load</p>
*/
function fnAutoLoad(){
    try{
        /* Add Form Submit Blocker */
         
        $("#frmNL").submit(function(){
            fnCheckFormValues();
            return false;
        });
    }catch(e){

    }
}

/**
* <p>Used to chech values in forms</p>
*/
function fnCheckFormValues(){
    mfnRemoveErrorClass();
    var lStrMessages="";

    
    if(lStrMessages==""){
        fnSubmitForm();
    }

}

/**
* <p>Used to submit the form</p>
*/
function fnSubmitForm(){
    try{
		
		$("#frmNL input[type=submit], #frmNL input[type=reset]").attr({
												"disabled":"disabled"
												});
		
        var ajaxCall = new AjaxCall();
        ajaxCall.DataType="json";
        ajaxCall.FormName="frmNL";
        ajaxCall.FormSubmitPage="services/newsletter.php";
        ajaxCall.FunctionOnScuccess="fnSubmitForm_Success";
        ajaxCall.fnAjax();
        mfnShowMessage("Please wait.. " + gStrAjaxImgSmall, "INF", 0);
    }catch(e){

    }
}

/**
* <p>Function to execute after the success of the form submit</p>
*/
function fnSubmitForm_Success()
{
    try{
        if(gObjAjaxCallReturnValue.succ==0){
			
			$("#frmNL input[type=submit], #frmNL input[type=reset]").removeAttr("disabled");
			
            mfnShowMessage(gObjAjaxCallReturnValue.mess,"ERR");
            mfnAddErrorClass(gObjAjaxCallReturnValue);
        }
        else if(gObjAjaxCallReturnValue.succ==1){
			var lStrContentToShow = "<div style='background-color:#E6E6FA; border-color: #E6E6FA; color: #202020; padding: 5px;     font-size: 12px; font-weight: bold;' >" + gObjAjaxCallReturnValue.mess + "</div>";
			$(""+lStrContentToShow+"").insertAfter("#frmNL input[type=reset]")
            mfnShowMessage(gObjAjaxCallReturnValue.mess);
        }
    } catch(e){

    }
}
