// JavaScript Document
/**
 * @uses:	This file contains form validations for the forms in index-beta.php page.
 * 
 * @author: CIPL/SW/013
 * @dated:	Tuesday August 07, 2007
 * 
 * @filename: index-beta.js
 * 
 * @modified date:
 * @reason to modify:
 * @modified by:
 */
//ADD COMMENT
function Comment_Add_fn() {
	if (validForm('frmIndexBeta', 'comment')) {
		document.frmIndexBeta.action = "index-beta.php?mode=comment";
		document.frmIndexBeta.submit();
	} else return false;
}

//
function Reply_Add_fn() {
	if (validForm('frmApply', 'reply')) {
		document.frmApply.action = "index-beta.php?mode=reply";
		document.frmApply.submit();
	} else return false;
}

//STAY TUNED
function Stay_Tuned_fn() {
	if (validForm('frmIndexBeta', 'stay')) {
		document.frmIndexBeta.action = "index-beta.php?mode=stay";
		document.frmIndexBeta.submit();
	} else return false;
}

//SET VALUES
function Name_onClick_fn() {
	if (document.frmIndexBeta.tb_name.value == "Desired Name")
		document.frmIndexBeta.tb_name.value = '';
	if (document.frmIndexBeta.tb_email.value == "")
		document.frmIndexBeta.tb_email.value = 'Email';
}
function Email_onClick_fn() {
	if (document.frmIndexBeta.tb_name.value == "")
		document.frmIndexBeta.tb_name.value = 'Desired Name';
	if (document.frmIndexBeta.tb_email.value == "Email")
		document.frmIndexBeta.tb_email.value = '';
}
function Name_onKeyPress_fn() {
	if (document.frmIndexBeta.tb_name.value == "")
		document.frmIndexBeta.tb_name.value = 'Desired Name';
}
function Email_onKeyPress_fn() {
	if (document.frmIndexBeta.tb_email.value == "")
		document.frmIndexBeta.tb_email.value = 'Email';
}

//SHOW REPLY
function View_Reply_fn(divId, tdId) {
	document.getElementById(divId).style.display = "block";
	document.getElementById(tdId).innerHTML = '<table border="0" cellspacing="0" cellpadding="0"><tr><td class="pages-text-blue" style="padding-left: 5px">Hide Reply</td><td><input name="image" type="image" onclick="return Hide_Reply_fn(\'' + divId + '\', \'' + tdId + '\');" src="images/grey-arrow_down.gif" width="15" height="15" /></td></tr></table>';
	return false;
}

//HIDE REPLY
function Hide_Reply_fn(divId, tdId) {
	document.getElementById(divId).style.display = "none";
	document.getElementById(tdId).innerHTML = '<table border="0" cellspacing="0" cellpadding="0"><tr><td class="pages-text-blue" style="padding-left: 5px">View Reply</td><td><input name="image" type="image" onclick="return View_Reply_fn(\'' + divId + '\', \'' + tdId + '\');" src="images/grey-arrow_right.gif" width="15" height="15" /></td></tr></table>';
	return false;
}

//DISPLAY WINDOW
function displayWindow(cmtid)
		    {
		        var w, h, l, t;
		        w = 710;
		        h = 325;
		        l = screen.width/4;
		        t = screen.height/4;  
		        
		        l = l - 100;
				t = t - 50;              
                              
		       document.frmApply.hi_cmtid.value = cmtid;
			   displayFloatingDiv('windowReply','Reply', w, h, l, t);     		        
		    }

//FIELD VALIDATION
function validForm(frmName, strOpt){
	if (strOpt == 'stay') {
		if(!validBlank (frmName, "tb_name" , "Please insert Desired Name!!!"))
			return false;
		if(document.frmIndexBeta.tb_name.value == "Desired Name") {
			alert("Please insert Desired Name!!!")
			return false;
		}
		if(!validBlank (frmName, "tb_email" , "Please insert Email Address!!!"))
			return false;
		if(document.frmIndexBeta.tb_email.value == "Email") {
			alert("Please insert Email Address!!!")
			return false;
		}
		if(!validEmail (frmName, "tb_email" , "Please insert valid Email"))
			return false;
	} else if(strOpt == 'comment') {
		if(!validBlank (frmName, "tb_uname" , "Please insert Username!!!"))
			return false;
		if(!validBlank (frmName, "ta_comment" , "Please insert Comment!!!"))
			return false;
	} else if(strOpt == 'reply') {
		if(document.getElementById('tb_rname').value == "") {
			alert("Please insert Name!!!");
			document.getElementById('tb_rname').focus();
			return false; 
		}
		if(document.getElementById('ta_reply').value == "") {
			alert("Please insert Reply!!!");
			document.getElementById('ta_reply').focus();
			return false;
		}
	} 
	
	return true;
}