/* to open a page in popup*/
function popup(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}


// Removes leading whitespaces
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trimboth( value ) {
	
	return LTrim(RTrim(value));
	
}
//return true if value is alphnumeric
function isAlphanumeric(value)	{
		return (/^[A-Za-z0-9 ]+$/.test(value));
}
//return true if value is alphabets
function isAlphabets(value)	{
		return (/^[A-Za-z ]+$/.test(value));
}

//return true if value is phone number
function isPhone(value){
		return (/^[0-9\s+\(\)]+$/.test(value));
		//return (/^\d+\s\d+$/.test(value));
}

//return true if value is number
function isNumeric(value){
		return (/^[0-9]+$/.test(value));
	
}

//return length of value
function isFixlen(value) {
	
		pvalue = trimboth(value);
		return  pvalue.length;
}

//to validate an email address
function validEmail(obj)
	{
		var str=obj.value;
		var a;
		var len=str.length;
		var reg=new RegExp("@");
		var ind=str.search(reg);
		var c,d=0;
		var b=0;
		for(a=0;a<=str.length;a++)
		{
	
			if(str.charAt(a)=="@")
			{
				b++;
			}
			
		}
	
		if(b>1)
			{
				alert("Please enter a valid Email ID.");
				obj.focus();
				return false;
			}
		else
			{
				for(a=0;a<=str.length;a++)
				{
					if(str.charAt(a)==".")
					{
						d=a;
					}
				
				}
				if((ind>d)||(ind==-1)||(d==0)||(ind+1==d)||(d+1==len))
				{
					alert ("Please enter a valid Email ID.");
					obj.focus();
					return false;
				}
				else
				{
					return true;
				}
			}
		
						
	}//function end vaild enmail

function fixHeight() {
 var maxH = 0;
 
 // find the highest column

 var d = document.getElementById("body_outer");
  var d1 = document.getElementById("left_outer");
    var d2 = document.getElementById("right_shadow");

 
 
	h = d.offsetHeight;
	if(h < 490) {
		h = 490;
	}
	
	d1.style.height = (h-30)+"px";
	d2.style.height = (h-144)+"px";

} 

function vaidateNewsletters(objFrm) {

	if(objFrm.subscriber_name.value == "") {
			alert("Please enter Name.");
			objFrm.subscriber_name.focus();
			return false;
		}else if(!isAlphabets(objFrm.subscriber_name.value)){
			alert("Name is not valid.\nOnly alphabets and space are allowed.");
			objFrm.subscriber_name.value = trimboth(objFrm.subscriber_name.value);
			objFrm.subscriber_name.focus();
			return false;
		}

		if(objFrm.email.value == "" ) {
	
			alert("Please enter Email ID.");
			objFrm.email.value = trimboth(objFrm.email.value);
			objFrm.email.focus();
			return false;
	
		} else if(validEmail(objFrm.email) == false) {
	
			return false;
		}
	
		objFrm.submit();
		return true;
	
} // -->
	