
function goToPage(url) {
    document.location = url;
}

function submitThisPage(page) {
    document.getElementById("form1").p.value = page;
    document.getElementById("form1").submit();
}

function submitSearch(isInitialSortOption) {
    if (isInitialSortOption) {
        document.getElementById("form1").SortOption[0].selected=true;
    }
    document.getElementById("form1").p.value = 1;
    document.getElementById("form1").submit();
}

function  _checkForm_Answer(_CF_this) {     
    var mode = _CF_this.mode.value;
    var code = _CF_this.code.value;
    
    if (mode == 0) { 
        // QNA category - SELECT 
 	    if  (!_CF_hasValue(_CF_this.CategoryID, "SELECT" )) {
		    if  (!_CF_onError(_CF_this, _CF_this.CategoryID, _CF_this.CategoryID.value, "SELECT", "Category is required"))	{
	            return false; 
            }
        }   

        // Subject
        if (!_CF_hasValue(_CF_this.Subject, "TEXT" )) {
  	        if (!_CF_onError(_CF_this, _CF_this.Subject, _CF_this.Subject.value, "TEXT", "Please enter Subject")) {
    	        return false; 
            }   
        }
    }
    // Name
    if (!_CF_hasValue(_CF_this.Name, "TEXT" )) {
  	    if (!_CF_onError(_CF_this, _CF_this.Name, _CF_this.Name.value, "TEXT", "Please enter Name")) {
    	    return false; 
    	}
    }
    // Email
    if (!_CF_hasValue(_CF_this.Email, "TEXT" ) || !_validEmail(_CF_this.Email.value)) {
  	    if (!_CF_onError(_CF_this, _CF_this.Email, _CF_this.Email.value, "TEXT", "Please enter valid E-mail address")) {
    	    return false; 
    	}
    }
    // Password
    //if (_CF_this.Password != null) {
	//    if (!_CF_hasValue(_CF_this.Password, "PASSWORD" )) {
  	//        if (!_CF_onError(_CF_this, _CF_this.Password, _CF_this.Password.value, "PASSWORD", "Please enter password")) {
    //	        return false; 
    //        }
    //    } 
    //}   
    
    // Question
	//if (!_CF_hasValue(_CF_this.Content, "TEXT" )) {
  	//    if (!_CF_onError(_CF_this, _CF_this.Content, _CF_this.Content.value, "TEXT", "Please enter Content")) {
    //	    return false; 
    //    }
    //}     

//    if (document.getElementById(_CF_this.FCKEditorBody.value) != null) {
//        var contents = document.getElementById(_CF_this.FCKEditorBody.value).getHTML();
//        alert(contents)
//        if (contents == null || contents.length == 0) {
//            alert("Please enter Content");
//            document.getElementById(_CF_this.FCKEditorBody.value).FocusDocument();
//            return false;
//        } else {
//            if (contents.length > 8000) {
//                alert(" The text that you have entered is too long( " + len + " characters). \n Please shorten it to 8000 characters long.");
//                return false;
//            }
//        }
//    }

    var editorID = document.getElementById("FCKEditorBody").value;
    var oEditor = FCKeditorAPI.GetInstance(editorID) ; //'ctl00_content_main_FCKeditor1'
    if (oEditor != null) {
        var contents = oEditor.GetHTML();
        if (contents == null || contents.length == 0) {  
            alert("Please enter Content");
            oEditor.Focus();
            return false;
        } else {
            if (contents.length > 8000) {
                alert(" The text that you have entered is too long( " + len + " characters). \n Please shorten it to 8000 characters long.");
                return false;
            }
        }        
    }
    
    // EnterCode
    //if (mode == 0 || mode == 1) { 
	    if (!_CF_hasValue(_CF_this.Code, "TEXT" )) {
  	        if (!_CF_onError(_CF_this, _CF_this.Code, _CF_this.Code.value, "TEXT", "Please enter character")) {
    	        return false; 
            }
        } else {
            if (_CF_this.Code.value != code) {
                alert("Incorrect character.Please enter correct character.");
                _CF_this.Code.value = "";
                _CF_this.Code.focus();
                return false; 
            }
        } 
    //}    
    return true;
}

  function resizeEditor(editorID, isNew)
  {
    //alert(editorID);
    var editor = document.getElementById(editorID);
    editor.SetHeight('400');
    
    if(isNew == 1) 
   {
      editor.setHTML('');
   } 
  }

function FCKeditor_OnComplete( editorInstance )
{
    document.getElementById("FCKEditorBody").value = editorInstance.Name;
}

function initFCKEditor() {
    var editorID = document.getElementById("FCKEditorBody").value;
    var oEditor = FCKeditorAPI.GetInstance(editorID) ; //'ctl00_content_main_FCKeditor1'
    oEditor.SetHTML("");
}


function enableForm(w) {
    if (w == '1') {
        document.getElementById("CategoryID").disabled = false;
        document.getElementById("Subject").disabled = false;
    }
    document.getElementById("Name").disabled = false;
    document.getElementById("Email").disabled = false;
    document.getElementById("Code").disabled = false;
}