function gblResizePopupPage(URL, l, t, w, h){
	w=Math.min(w, screen.width);
	h=Math.min(h, screen.height);
	var windowprops = "location=no,scrollbars=no,menubar=no,toolbar=no,resizable=1" + ",left=" + l + ",top=" + t + ",width=" + w + ",height=" + h;
	popup = window.open(URL, "MenuPopup", windowprops);
	popup.focus();
}

function showStateDropDown() {
	if(document.getElementById("CountryID").value == 318 || document.getElementById("CountryID").value == 139) {
		document.getElementById("StateDiv").style.display = "block";
	} else {
		document.getElementById("StateDiv").style.display = "none";
	}
}

//*************************************************************************************
// Word count function
function lclGetWordCount(strInput){
//check the number of words in the param string
	var wordCount=0;
	if (strInput==null){
		var cleanString ="";
	}else{
		var cleanString=strInput;
	}
	
	//initialWhitespaceRExp= /^[^A-Za-z0-9]+/gi; //use for complex whitespace
	//nonAlphanumericsRExp=/[^A-Za-z0-9]+/gi;    // and for delimiters
	
	//currString = strInput.replace(initialWhitespaceRExp, " ");
	//cleanString = currString.replace(nonAlphanumericsRExp, " ");
	var re = /\s+/gi
	cleanString = cleanString.replace(re, " ");
	//remove trailing spaces
	if (cleanString.charAt(cleanString.length-1)==" " && cleanString.length > 1){
		cleanString = cleanString.substring(0, cleanString.length-2);
		//alert('truncated');
	}
	splitString=cleanString.split(" ");
	wordCount=splitString.length;
	
	return(wordCount);
}


function lclDynCheckWord(elementID, wordCountContainerID, wordLimitMsgID, oObject) {
	//display no of words in the textarea and display 	message if the exceed the limit
	element = document.getElementById(elementID);
	
	wordCountContainer = document.getElementById(wordCountContainerID);
	wordCountContainer.style.display="block";
	//wordLimitMsgContainer = document.getElementById(wordLimitMsgID);
	//submitBttn = document.getElementById(submitBttnID);
	var strInput = element.value;
	
	currWordCount = lclGetWordCount(strInput);				//get the number of word
	
	wordCountContainer.innerHTML= currWordCount + " of 600 words (25 minimum) ";
	
	var upperLimit = 600;
	var lowerLimit = 25;
	if (currWordCount < lowerLimit || currWordCount >= upperLimit){
		wordCountContainer.style.color="#C00";
	} else {
		wordCountContainer.style.color="#666";
	}
}

function lclEliminateLastWord(strText) {
	var strArray = new Array();
	strArray = strText.split(" ");
	var strOutput = "";
	for(i=1; i<strArray.length;i++) {
		strOutput += strArray[i-1] + " ";
	}
	return strOutput;
}
//*************************************************************************************=======

