/**************************************************************************************************
*           *       @       Created By              :       Vinod Kumar Keshri                    *
*           *       @       Modified By             :       Sudeep Jain                    	      *
*           *       @       Date Of Creation        :       05-03-2010                            *
*           *       @       Date Of Modification    :        15/10/10         					  *
*           *       @       Project Name            :       etradearticle                         *
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate radio button, Start
**************************************************************************************************/
function checkRadio(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return btn[cnt].value;
    else return null;
}
/************************************************************************************************** 
* Function to validate radio button, End 
**************************************************************************************************/  

/************************************************************************************************** 
* Function to validate the user, Start 
**************************************************************************************************/
function validateUser(){
	var alphaExp = /^[a-z A-Z]+$/;
	var emailExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var email = document.form.email.value;
	var password = document.form.password.value;
	var repassword = document.form.repassword.value;
	var firstName = document.form.firstName.value;
	var lastName = document.form.lastName.value;
	var address1 = document.form.address1.value;
	var city = document.form.city.value;
	var state = document.form.state.value;
	var country = document.form.country.value;
	var phone = document.form.phone.value;
	var cellphone = document.form.cellphone.value;
	var hearabout = document.form.hearabout.value;
	if(email==''){
		document.getElementById('createUserDiv').innerHTML = "Enter email.";
		document.getElementById('createUserDiv').style.display="block";
		document.form.email.focus();
		return false;
	}
	if(!email.match(emailExp)){
		document.getElementById('createUserDiv').innerHTML = "Enter valid email.";
		document.getElementById('createUserDiv').style.display="block";
		document.form.email.focus();
		return false;
	}
	if(password==''){
		document.getElementById('createUserDiv').innerHTML = "Enter password.";
		document.getElementById('createUserDiv').style.display="block";
		document.form.password.focus();
		return false;
	}
	if(repassword==''){
		document.getElementById('createUserDiv').innerHTML = "Enter Re-password.";
		document.getElementById('createUserDiv').style.display="block";
		document.form.repassword.focus();
		return false;
	}
	if(password!=repassword){
		document.getElementById('createUserDiv').innerHTML = 'Password and Re-password did not match.';
		document.getElementById('createUserDiv').style.display = 'block';
		document.form.password.focus();
		document.form.password.value='';
		document.form.repassword.value='';
		return false;
	}
	if(firstName==''){
		document.getElementById('createUserDiv').innerHTML = "Enter first name.";
		document.getElementById('createUserDiv').style.display="block";
		document.form.firstName.focus();
		return false;
	}
	if(!firstName.match(alphaExp)){
		document.getElementById('createUserDiv').innerHTML = "First name should be character.";
		document.getElementById('createUserDiv').style.display="block";
		document.form.firstName.focus();
		return false;
	}
	if(lastName==''){
		document.getElementById('createUserDiv').innerHTML = "Enter last name.";
		document.getElementById('createUserDiv').style.display="block";
		document.form.lastName.focus();
		return false;
	}
	if(!lastName.match(alphaExp)){
		document.getElementById('createUserDiv').innerHTML = "Last name should be character.";
		document.getElementById('createUserDiv').style.display="block";
		document.form.lastName.focus();
		return false;
	}
	if(address1==''){
		document.getElementById('createUserDiv').innerHTML = "Enter address.";
		document.getElementById('createUserDiv').style.display="block";
		document.form.address1.focus();
		return false;
	}
	if(city==''){
		document.getElementById('createUserDiv').innerHTML = "Enter city.";
		document.getElementById('createUserDiv').style.display="block";
		document.form.city.focus();
		return false;
	}
	if(state==''){
		document.getElementById('createUserDiv').innerHTML = "Enter state.";
		document.getElementById('createUserDiv').style.display="block";
		document.form.state.focus();
		return false;
	}
	if(country==''){
		document.getElementById('createUserDiv').innerHTML = "Select country.";
		document.getElementById('createUserDiv').style.display="block";
		document.form.country.focus();
		return false;
	}
	if(phone==''){
		document.getElementById('createUserDiv').innerHTML = "Enter phone number.";
		document.getElementById('createUserDiv').style.display="block";
		document.form.phone.focus();
		return false;
	}
	if(isNaN(phone)){
		document.getElementById('createUserDiv').innerHTML = "Phone number should be numeric.";
		document.getElementById('createUserDiv').style.display="block";
		document.form.phone.focus();
		return false;
	}
	if(cellphone==''){
		document.getElementById('createUserDiv').innerHTML = "Enter mobile number.";
		document.getElementById('createUserDiv').style.display="block";
		document.form.cellphone.focus();
		return false;
	}
	if(isNaN(cellphone)){
		document.getElementById('createUserDiv').innerHTML = "Mobile number should be numeric.";
		document.getElementById('createUserDiv').style.display="block";
		document.form.cellphone.focus();
		return false;
	}
	if(hearabout==''){
		document.getElementById('createUserDiv').innerHTML = "Select hear about.";
		document.getElementById('createUserDiv').style.display="block";
		document.form.hearabout.focus();
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to validate the user, End 
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate forgot password, Start 
**************************************************************************************************/
function forgotPassword(){
	var emailExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var email = document.form.email.value;
	if(email==''){
		document.getElementById('forgotPassDiv').innerHTML = "User Id.";
		document.getElementById('forgotPassDiv').style.display="block";
		document.form.email.focus();
		return false;
	}
	if(!email.match(emailExp)){
		document.getElementById('forgotPassDiv').innerHTML = "Enter valid email.";
		document.getElementById('forgotPassDiv').style.display="block";
		document.form.email.focus();
		return false;
	}
}
/************************************************************************************************** 
* Function to validate forgot password, End 
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate forgot password, Start 
**************************************************************************************************/
function adminProfile(){
	var emailExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var admin = document.form.admin.value;
	var email = document.form.email.value;
	if(admin==''){
		document.getElementById('adminProfileDiv').innerHTML = "Enter user name.";
		document.getElementById('adminProfileDiv').style.display="block";
		document.form.admin.focus();
		return false;
	}
	if(email==''){
		document.getElementById('adminProfileDiv').innerHTML = "Enter email.";
		document.getElementById('adminProfileDiv').style.display="block";
		document.form.email.focus();
		return false;
	}
	if(!email.match(emailExp)){
		document.getElementById('adminProfileDiv').innerHTML = "Enter valid email.";
		document.getElementById('adminProfileDiv').style.display="block";
		document.form.email.focus();
		return false;
	}
}
/************************************************************************************************** 
* Function to validate forgot password, End 
**************************************************************************************************/

/************************************************************************************************** 
* Function to update user, Start 
**************************************************************************************************/
function updateUser(){
	var alphaExp = /^[a-z A-Z]+$/;
	var firstName = document.form.firstName.value;
	var lastName = document.form.lastName.value;
	var address1 = document.form.address1.value;
	var city = document.form.city.value;
	var state = document.form.state.value;
	var country = document.form.country.value;
	var phone = document.form.phone.value;
	var cellphone = document.form.cellphone.value;
	var hearabout = document.form.hearabout.value;
	if(firstName==''){
		document.getElementById('updateUserDiv').innerHTML = "Enter first name.";
		document.getElementById('updateUserDiv').style.display="block";
		document.form.firstName.focus();
		return false;
	}
	if(!firstName.match(alphaExp)){
		document.getElementById('updateUserDiv').innerHTML = "First name should be character.";
		document.getElementById('updateUserDiv').style.display="block";
		document.form.firstName.focus();
		return false;
	}
	if(lastName==''){
		document.getElementById('updateUserDiv').innerHTML = "Enter last name.";
		document.getElementById('updateUserDiv').style.display="block";
		document.form.lastName.focus();
		return false;
	}
	if(!lastName.match(alphaExp)){
		document.getElementById('updateUserDiv').innerHTML = "Last name should be character.";
		document.getElementById('updateUserDiv').style.display="block";
		document.form.lastName.focus();
		return false;
	}
	if(address1==''){
		document.getElementById('updateUserDiv').innerHTML = "Enter address.";
		document.getElementById('updateUserDiv').style.display="block";
		document.form.address1.focus();
		return false;
	}
	if(city==''){
		document.getElementById('updateUserDiv').innerHTML = "Enter city.";
		document.getElementById('updateUserDiv').style.display="block";
		document.form.city.focus();
		return false;
	}
	if(state==''){
		document.getElementById('updateUserDiv').innerHTML = "Enter state.";
		document.getElementById('updateUserDiv').style.display="block";
		document.form.state.focus();
		return false;
	}
	if(country==''){
		document.getElementById('updateUserDiv').innerHTML = "Select country.";
		document.getElementById('updateUserDiv').style.display="block";
		document.form.country.focus();
		return false;
	}
	if(phone==''){
		document.getElementById('updateUserDiv').innerHTML = "Enter phone number.";
		document.getElementById('updateUserDiv').style.display="block";
		document.form.phone.focus();
		return false;
	}
	if(isNaN(phone)){
		document.getElementById('updateUserDiv').innerHTML = "Phone number should be numeric.";
		document.getElementById('updateUserDiv').style.display="block";
		document.form.phone.focus();
		return false;
	}
	if(cellphone==''){
		document.getElementById('updateUserDiv').innerHTML = "Enter mobile number.";
		document.getElementById('updateUserDiv').style.display="block";
		document.form.cellphone.focus();
		return false;
	}
	if(isNaN(cellphone)){
		document.getElementById('updateUserDiv').innerHTML = "Mobile number should be numeric.";
		document.getElementById('updateUserDiv').style.display="block";
		document.form.cellphone.focus();
		return false;
	}
	if(hearabout==''){
		document.getElementById('updateUserDiv').innerHTML = "Select hear about.";
		document.getElementById('updateUserDiv').style.display="block";
		document.form.hearabout.focus();
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to update user, End 
**************************************************************************************************/

/************************************************************************************************** 
* Function to change the admin password , Start 
**************************************************************************************************/
function changePasswordValidate(){
	var oldPassword = document.form.oldPassword.value;
	var newPassword = document.form.newPassword.value;
	var rePassword = document.form.rePassword.value;
	if(oldPassword==''){
		document.getElementById('changePasswordDiv').innerHTML = "Enter old password.";
		document.getElementById('changePasswordDiv').style.display="block";
		document.form.oldPassword.focus();
		return false;
	}
	if(newPassword==''){
		document.getElementById('changePasswordDiv').innerHTML = 'Enter new password.';
		document.getElementById('changePasswordDiv').style.display = 'block';
		document.form.newPassword.focus();
		return false;
	}
	if(rePassword==''){
		document.getElementById('changePasswordDiv').innerHTML = 'Enter Re-password.';
		document.getElementById('changePasswordDiv').style.display = 'block';
		document.form.rePassword.focus();
		return false;
	}
	if(newPassword!=rePassword){
		document.getElementById('changePasswordDiv').innerHTML = 'New password and Re-password did not match.';
		document.getElementById('changePasswordDiv').style.display = 'block';
		document.form.newPassword.focus();
		document.form.newPassword.value='';
		document.form.rePassword.value='';
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to change the admin password , End
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate category, Start 
**************************************************************************************************/
function validateCategory(){
	var catID = document.form.catID.value;
	var category = document.form.category.value;
	if(catID==''){
		document.getElementById('categoryDiv').innerHTML = "Enter category code.";
		document.getElementById('categoryDiv').style.display="block";
		document.form.catID.focus();
		return false;
	}
	if(category==''){
		document.getElementById('categoryDiv').innerHTML = "Enter category.";
		document.getElementById('categoryDiv').style.display="block";
		document.form.category.focus();
		return false;
	}
	var radio_choice = false;
	for (counter = 0; counter < document.form.type.length; counter++){
		if (document.form.type[counter].checked)
			radio_choice = true; 
	}
	if (!radio_choice){
		document.getElementById('categoryDiv').innerHTML = "Select category type.";
		document.getElementById('categoryDiv').style.display="block";
		/*document.form.type.focus();*/
		return (false);
	}
	return true;
}
/************************************************************************************************** 
* Function to validate category, End
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate subcategory, Start 
**************************************************************************************************/
function validateSubCategory(){
	var cat_ID = document.form.cat_ID.value;
	if(cat_ID==''){
		document.getElementById('subCategoryDiv').innerHTML = "Select category.";
		document.getElementById('subCategoryDiv').style.display="block";
		document.form.cat_ID.focus();
		return false;
	}
	var subCatID = document.form.subCatID.value;
	if(subCatID==''){
		document.getElementById('subCategoryDiv').innerHTML = "Enter subcategory code.";
		document.getElementById('subCategoryDiv').style.display="block";
		document.form.subCatID.focus();
		return false;
	}
	var subCategory = document.form.subCategory.value;
	if(subCategory==''){
		document.getElementById('subCategoryDiv').innerHTML = "Enter subcategory.";
		document.getElementById('subCategoryDiv').style.display="block";
		document.form.subCategory.focus();
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to validate subcategory, End
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate user login, Start 
**************************************************************************************************/
function validateUserLogin(){
	var emailExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var email = document.form.email.value;
	var password = document.form.password.value;	
	if(email==''){
		document.getElementById('userLoginDiv').innerHTML = "Enter user Id.";
		document.getElementById('userLoginDiv').style.display="block";
		document.form.email.focus();
		return false;
	}
	if(!email.match(emailExp)){
		document.getElementById('userLoginDiv').innerHTML = "Enter valid email.";
		document.getElementById('userLoginDiv').style.display="block";
		document.form.email.focus();
		return false;
	}
	if(password==''){
		document.getElementById('userLoginDiv').innerHTML = "Enter password.";
		document.getElementById('userLoginDiv').style.display="block";
		document.form.password.focus();
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to validate user login, End 
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate admin login, Start 
**************************************************************************************************/
function validateAdminLogin(){
	var admin = document.form.admin.value;
	var password = document.form.password.value;	
	if(admin==''){
		document.getElementById('adminLoginDiv').innerHTML = "Enter User Id.";
		document.getElementById('adminLoginDiv').style.display="block";
		document.form.admin.focus();
		return false;
	}
	if(password==''){
		document.getElementById('adminLoginDiv').innerHTML = "Enter password.";
		document.getElementById('adminLoginDiv').style.display="block";
		document.form.password.focus();
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to validate admin login, End 
**************************************************************************************************/

/************************************************************************************************** 
* Function to limit text, Start 
**************************************************************************************************/
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}
/************************************************************************************************** 
* Function to limit text, End
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate user upload photo, Start
**************************************************************************************************/
function validateUserPhoto(){
	var photo = document.form.photo.value;
	if(photo==''){
		document.getElementById('uploadUserPhotoDiv').innerHTML = "Please browse image.";
		document.getElementById('uploadUserPhotoDiv').style.display="block";
		document.form.photo.focus();
		return false;
	}
	return true;	
}
/************************************************************************************************** 
* Function to validate user upload photo, End
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate submit article, Start 
**************************************************************************************************/
function submitArticle(){
	var cat_ID = document.form.cat_ID.value;
	var subCat_ID = document.form.subCat_ID.value;
	var title = document.form.title.value;
	var description = document.form.description.value;
	tinyMCE.triggerSave();
	var longDesc = document.getElementById('longDesc').value;
	//var longDesc = tinyMCE.getInstanceById('longDesc').contentDocument.body.innerHTML;
	//var longDesc = document.form.longDesc.value;
	var resourse = document.form.resourse.value;
	var keywords = document.form.keywords.value;
	if(cat_ID==''){
		document.getElementById('submitArticleDiv').innerHTML = "Please select category.";
		document.getElementById('submitArticleDiv').style.display="block";
		document.form.cat_ID.focus();
		return false;
	}
	if(subCat_ID==''){
		document.getElementById('submitArticleDiv').innerHTML = "Please select subcategory.";
		document.getElementById('submitArticleDiv').style.display="block";
		document.form.subCat_ID.focus();
		return false;
	}
	if(title==''){
		document.getElementById('submitArticleDiv').innerHTML = "Please enter title.";
		document.getElementById('submitArticleDiv').style.display="block";
		document.form.title.focus();
		return false;
	}
	if(description==''){
		document.getElementById('submitArticleDiv').innerHTML = "Please enter short description.";
		document.getElementById('submitArticleDiv').style.display="block";
		document.form.description.focus();
		return false;
	}
	if(longDesc==''){
		document.getElementById('submitArticleDiv').innerHTML = "Please enter description.";
		document.getElementById('submitArticleDiv').style.display="block";
		document.form.longDesc.focus();
		return false;
	}
	if(resourse==''){
		document.getElementById('submitArticleDiv').innerHTML = "Please enter comments.";
		document.getElementById('submitArticleDiv').style.display="block";
		document.form.resourse.focus();
		return false;
	}
	if(keywords==''){
		document.getElementById('submitArticleDiv').innerHTML = "Please enter keywords.";
		document.getElementById('submitArticleDiv').style.display="block";
		document.form.keywords.focus();
		return false;
	}
	if(!document.form.agree.checked){
		document.getElementById('submitArticleDiv').innerHTML = "Please check the terms and conditions.";
		document.getElementById('submitArticleDiv').style.display="block";
		document.form.agree.focus();
		return false; 
	}
	return true;
}
/************************************************************************************************** 
* Function to validate submit article, End 
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate user account, Start
**************************************************************************************************/
function validateUserAccount(){
	var radio_choice = false;
	for (counter = 0; counter < document.form.articleAccount.length; counter++){
		if (document.form.articleAccount[counter].checked)
			radio_choice = true; 
	}
	if (!radio_choice){
		document.getElementById('accountDiv').innerHTML = "Select account type.";
		document.getElementById('accountDiv').style.display="block";
		/*document.form.articleAccount.focus();*/
		return (false);
	}
	return true;	
}
/************************************************************************************************** 
* Function to validate user account, End
**************************************************************************************************/

/************************************************************************************************** 
* Function to redirect page, Start
**************************************************************************************************/ 
function redirectPage(pageName){
	window.location.href=(pageName);	
}
/************************************************************************************************** 
* Function to redirect page, End 
**************************************************************************************************/ 

/************************************************************************************************** 
* Function to show the preview, Start
**************************************************************************************************/ 
function popup(path,winname,W,H,M,S,b,f){
	var brd = b||0;
	var tsz = 20;
	f = f||0;
	var c=(document.all&&navigator.userAgent.indexOf("Win")!=-1)?1:0
	var w=window.screen.width / 2; var h=window.screen.height / 2;
	var W=W||w; W=(typeof(W)=='string'?Math.ceil(parseInt(W)*w/100):W); W+=(brd*2+2)*c; W += f;
	var H=H||h; H=(typeof(H)=='string'?Math.ceil(parseInt(H)*h/100):H); H+=(tsz+brd+2)*c; H += f;
	var X=X||Math.ceil((w-W/2))
	var Y=Y||Math.ceil((h-H/2))

	var hPopup = window.open(path, null, "left="+X+",top="+Y+",width="+W+",height="+H+",menubar="+M+",toolbar=0,scrollbars="+S+",resizable=0");
	hPopup.focus();
}

function preview(){
	popup('preview.php', 'preview', 650, 500, 0, 1);
}

function getPreviewCategory(){
	f = document.form;
	return f.cat_ID.options[f.cat_ID.selectedIndex].text;
}

function getPreviewSubCategory(){
	f = document.form;
	return f.subCat_ID.options[f.subCat_ID.selectedIndex].text;
}

function getTitle(){
	return document.form.title.value;
}

function getDescription(){
	return document.form.description.value;
}

function getLongDesc(){
	var intra_editor = tinyMCE.getInstanceById('longDesc').contentDocument.body.innerHTML;
	return intra_editor;
}

function getResource(){
	return document.form.resourse.value;
}

function getKeywords(){
	return document.form.keywords.value;
}
/************************************************************************************************** 
* Function to show the preview, End
**************************************************************************************************/ 

/************************************************************************************************** 
* Function to validate compose mail, Start 
**************************************************************************************************/
function validateCompose(){
	var subject = document.form.subject.value;
	tinyMCE.triggerSave();
	var longDesc = document.getElementById('longDesc').value;
	if(subject==''){
		document.getElementById('composeDiv').innerHTML = "Please write subject befor sending mail.";
		document.getElementById('composeDiv').style.display="block";
		document.form.subject.focus();
		return false;
	}
	if(longDesc==''){
		document.getElementById('composeDiv').innerHTML = "Please write your message.";
		document.getElementById('composeDiv').style.display="block";
		document.form.longDesc.focus();
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to validate compose mail, End
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate send mail, Start 
**************************************************************************************************/
function validateSendMail(){
	var email = document.form.email.value;
	var subject = document.form.subject.value;
	tinyMCE.triggerSave();
	var longDesc = document.getElementById('longDesc').value;
	if(email==''){
		document.getElementById('composeDiv').innerHTML = "Please enter email.";
		document.getElementById('composeDiv').style.display="block";
		document.form.email.focus();
		return false;
	}
	if(subject==''){
		document.getElementById('composeDiv').innerHTML = "Please write subject befor sending mail.";
		document.getElementById('composeDiv').style.display="block";
		document.form.subject.focus();
		return false;
	}
	if(longDesc==''){
		document.getElementById('composeDiv').innerHTML = "Please write your message.";
		document.getElementById('composeDiv').style.display="block";
		document.form.longDesc.focus();
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to validate send mail, End
**************************************************************************************************/

/************************************************************************************************** 
* Function to bookmarksite, Start 
**************************************************************************************************/
function bookmarksite(title,url){
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all)// ie
		window.external.AddFavorite(url, title);
}
/************************************************************************************************** 
* Function to bookmarksite, End
**************************************************************************************************/
/************************************************************************************************** 
* Function to validate user login, Start 
**************************************************************************************************/
function validateUserLogin(){
	var emailExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var email = document.form.email.value;
	var password = document.form.password.value;	
	if(email==''){
		document.getElementById('userLoginDiv').innerHTML = "Enter user Id.";
		document.getElementById('userLoginDiv').style.display="block";
		document.form.email.focus();
		return false;
	}
	if(!email.match(emailExp)){
		document.getElementById('userLoginDiv').innerHTML = "Enter valid email.";
		document.getElementById('userLoginDiv').style.display="block";
		document.form.email.focus();
		return false;
	}
	if(password==''){
		document.getElementById('userLoginDiv').innerHTML = "Enter password.";
		document.getElementById('userLoginDiv').style.display="block";
		document.form.password.focus();
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to validate user login, End 
**************************************************************************************************/

/************************************************************************************************** 
* Function to validate comment, Start 
**************************************************************************************************/
function checkcomment(){
    var emailExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    var name = document.form.name.value;
	var email = document.form.email.value;
	var subject = document.form.subject.value;
	var comments = document.form.comments.value;
	if(name==''){
		document.getElementById('commentDiv').innerHTML = "Enter Name.";
		document.getElementById('commentDiv').style.display="block";
		document.form.name.focus();
		return false;
	}
	if(email==''){
		document.getElementById('commentDiv').innerHTML = "Enter Email.";
		document.getElementById('commentDiv').style.display="block";
		document.form.email.focus();
		return false;
	}
	if(!email.match(emailExp)){
		document.getElementById('commentDiv').innerHTML = "Enter valid email.";
		document.getElementById('commentDiv').style.display="block";
		document.form.email.focus();
		return false;
	}
	if(subject==''){
		document.getElementById('commentDiv').innerHTML = "Enter Subject.";
		document.getElementById('commentDiv').style.display="block";
		document.form.subject.focus();
		return false;
	}
	if(comments==''){
		document.getElementById('commentDiv').innerHTML = "Enter Comments.";
		document.getElementById('commentDiv').style.display="block";
		document.form.email.focus();
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to validate comment, End 
**************************************************************************************************/
/************************************************************************************************** 
* Function to validate Topic, Start 
**************************************************************************************************/
function checktopic(){
   
    var emailExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var topic = document.form.topic.value;
	var name = document.form.name.value;
	var emails = document.form.emails.value;
	if(name==''){
		document.getElementById('topicdiv').innerHTML = "Enter Your Name.";
		document.getElementById('topicdiv').style.display="block";
		document.form.name.focus();
		return false;
	}
	if(emails==''){
		document.getElementById('topicdiv').innerHTML = "Enter your mail id.";
		document.getElementById('topicdiv').style.display="block";
		document.form.emails.focus();
		return false;
	}
	if(!emails.match(emailExp)){
		document.getElementById('topicdiv').innerHTML = "Enter Valid Email.";
		document.getElementById('topicdiv').style.display="block";
		document.form.emails.focus();
		return false;
	}
	if(topic==''){
		document.getElementById('topicdiv').innerHTML = "Enter Topic Name.";
		document.getElementById('topicdiv').style.display="block";
		document.form.topic.focus();
		return false;
	}
	
	return true;
}
/************************************************************************************************** 
* Function to validate Topic, End 
**************************************************************************************************/
/************************************************************************************************** 
* Function to validate Topic, Start 
**************************************************************************************************/
function checkarticle(){
   
    var emailExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var to = document.form.to.value;
	var email = document.form.email.value;
	if(to==''){
		document.getElementById('articlediv').innerHTML = "Enter mail id to whom you want to send mail.";
		document.getElementById('articlediv').style.display="block";
		document.form.to.focus();
		return false;
	}
	if(to==''){
		document.getElementById('articlediv').innerHTML = "Enter mail id to whom you want to send mail.";
		document.getElementById('articlediv').style.display="block";
		document.form.to.focus();
		return false;
	}
	if(email==''){
		document.getElementById('articlediv').innerHTML = "Please enter your email id .";
		document.getElementById('articlediv').style.display="block";
		document.form.email.focus();
		return false;
	}
	if(!email.match(emailExp)){
		document.getElementById('articlediv').innerHTML = "Enter valid email.";
		document.getElementById('articlediv').style.display="block";
		document.form.email.focus();
		return false;
	}
	return true;
}
/************************************************************************************************** 
* Function to validate Topic, End 
**************************************************************************************************/

/* Refrence for editor
http://tinymce.moxiecode.com/punbb/viewtopic.php?id=321
var intra_editor = tinyMCE.getInstanceById('typed_intra_txt').contentDocument.body.innerHTML;

tinyMCE.triggerSave();
var intra_editor = document.getElementById('typed_intra_txt').value;

if (document.all){
   checkcontentIE();
}else{
   checkcontentFF();
}*/

