// global var to handle the window
var iwWin = null;

function handleWindow(url, isHome)
{
	//if (isHome) {
		//if (iwWin && iwWin.open) {
			//iwWin.close();
//		} else {
//			self.close();
//		}
//	} else {
		// not an entry page .. just open the windo
		iwWin = window.open(url, 'myWin');
//	}
}

/*
 * Suggest an answer form
 * require comments
 */
function validateSuggestionForm() {
	var frm = document.getElementById('suggestFrm');
	var _result = true;
		
	if (isEmpty(frm.comments.value) || checkLimit(frm.comments.value, 2000)) {
		alert("Please provide your comments. Maximum 2000 characters");
		frm.comments.focus();	
		_result = false;	
	}
	
	if (_result) {
		Modalbox.show('/iw/form/process.php/email-suggest',
			{
				title: 'Suggest An Answer', 
				width: 600, 
				params:Form.serialize('suggestFrm') 
			} 
		);
	}
}

/*
 * Contact Form
 * require email, comments
 */
function validateContactForm() {
	var frm = document.getElementById('contactFrm');
	var _result = true;
		
	if (isEmpty(frm.email.value) || !checkEmail(frm.email.value)) {
		alert("Please provide a valid e-mail address");
		frm.email.focus();
		_result = false;	
	}
	else if (isEmpty(frm.comments.value) || checkLimit(frm.comments.value, 2000)) {
		alert("Please provide your comments. Maximum 2000 characters");
		frm.comments.focus();	
		_result = false;	
	}
	
	if (_result) {
		Modalbox.show('/iw/form/process.php/email-contact',
			{
				title: 'Contact Induction Works', 
				width: 600, 
				params:Form.serialize('contactFrm') 
			} 
		);
	}
}

