// JavaScript Document
function createXMLHttpRequest() {
	try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
	try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
	try { return new XMLHttpRequest(); } catch(e) {}
	alert("XMLHttpRequest not supported");
	return null;
}
var xhReq = createXMLHttpRequest();	  
var xhReq2 = createXMLHttpRequest();
var xhReq3 = createXMLHttpRequest();

function loaddiv()
{
	// loading div
	window.scrollTo(0,0);
	var loading_box = document.createElement('div');	
	loading_box.className = "map_loading";
	loading_box.id = "map_loading_box";
	loading_box.style.left = '0px';			
	height=document.body.scrollHeight;
	width = screen.width;	
	width = width+'px';
  	height = height+10+'px';
	loading_box.style.width = width;
	loading_box.style.top = '0px';
	loading_box.style.height = height;
	loading_box.innerHTML = '<table width="'+width+'" height="'+height+'" align="center"><tr><td style="font-family: Arial, Verdana, Helvetica; color:#000000; FONT-WEIGHT: bold; FONT-SIZE: 25px;" valign="middle" align="center">&nbsp;</td></tr></table>';
	document.body.appendChild(loading_box);
	// end
}

//function to chk whether given given text field is empty or not
function isValidEntry(element,msg) 
{  
   if(element.value.length == 0 ||  trim(element.value) == '')
	{
		alert("Please enter the "+ msg);
		element.focus();
		return false;
	}
	return true;
} // closing the function isValidEntry()

//function to chk for valid URL
function isValidURL(element, msg, required)
{
	if(element.value == "")
	{
		var rval = trim(required);
		if (rval.toLowerCase() == "yes" || rval == 1)
		{
			alert("Please enter "+msg);
			element.focus();
			return false;
		}
	}
	if(element.value != "")
	{
		// if (!(/^[www]\w+([\.-]?\w+)*(\.\w{2,3}.*/i.test(element.value)))))
		var oRegExp = /[^:]+:\/\/[^:\/]+(:[0-9]+)?\/?.*/;
		if (!oRegExp.test(element.value))
		{
			alert('\r\n The URL you have entered is invalid.\n Please check it for accuracy.');
			element.focus();
			element.select();
			return false;
		}
	}
	return true;
}
//function to chk for valid email
function isValidEmail(VarEmail)
{
		if(VarEmail.value == "" || VarEmail.length == 0)
		{
			alert("Please enter Email Address");
			VarEmail.focus();
			return false;
		}	
		if(VarEmail.value!="")
        {

			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(VarEmail.value)))
			{
				alert("Invalid Email address!")
				VarEmail.focus();
				VarEmail.value = "";
				return false;
			}
        } 
		return true;
}

function isValidEmailNoAlert(VarEmail)
{
	if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(VarEmail.value)))		
		return false;
	else	
		return true;	
}

//function to chk for valid email
function isValidName(Obj, msg)
{
	if(Obj.value == "" || Obj.length == 0)
	{
		alert("Please enter "+msg);
		Obj.focus();
		return false;
	}	
	else if(Obj.value != "")
	{
		val = Obj.value;	
		var m = /^[a-zA-Z]+([a-zA-Z0-9]+)+$/.test(val);			
		if(!m)
		{
			alert("Invalid "+msg+"");
			Obj.value = '';
			Obj.focus();
			return false;
		}	
	} 
	return true;
}

//function to chk for valid email
function isValidChar(Obj, msg)
{
	if(Obj.value == "" || Obj.length == 0)
	{
		alert("Please enter "+msg);
		Obj.focus();
		return false;
	}	
	else if(Obj.value != "")
	{
		val = Obj.value;	
		var m = /^[a-zA-Z]+([a-zA-Z]+)+$/.test(val);			
		if(!m)
		{
			alert("Invalid "+msg+"");
			Obj.focus();
			Obj.value = "";
			return false;
		}	
	} 
	return true;
}

function isValidPassword(Obj, msg, number)
{	
	if(trim(Obj.value) == "" || Obj.value.length == 0)
	{
		alert("Please enter "+msg);
		Obj.focus();
		return false;
	}	
	else if(Obj.value.length <= number )
	{
		alert(msg+" should be greater than "+number+" characters.");
		Obj.focus();
		return false;			
	} 
	return true;
}

function validateChangePwd(oldp,newp,renewp)
{	
	if(!isValidEntry(oldp,"Old Password"))
		return false;
	else 	if(!isValidPassword(newp,"New Password",6))
		return false;
	else if(oldp.value == newp.value)	
	{
		alert("Old and New Passwords should not be same");
		newp.focus();
		return false;
	}
	else if(newp.value != renewp.value)	
	{
		alert("New passwords should be same");
		renewp.focus();
		return false;
	}
	return true;
}

function check_phonenum(e)/// validation to enter only numbers
{
  if(window.event)
  {
		if((e.keyCode > 1 && e.keyCode < 47 && e.keyCode!=8  && e.keyCode!=45) ||(e.keyCode > 58 && e.keyCode < 255) ) 
		return false;
  }
  else if(e.which)
   {
		if((e.which > 1 && e.which < 47 && e.keyCode!=8  && e.keyCode!=45) ||(e.which > 58 && e.which < 255) ) 
		return false;
   }
   return true;
}


function check_alpha1(e)/// validation to enter only numbers
{
  if(window.event)
  {
		if((e.keyCode > 1 && e.keyCode < 47 && e.keyCode!=8) ||(e.keyCode > 58 && e.keyCode < 255) ) 
		return false;
  }
  else if(e.which)
   {
		if((e.which > 1 && e.which < 47 && e.keyCode!=8) ||(e.which > 58 && e.which < 255) ) 
		return false;
   }
   return true;
}


function checknum(e)// validation to enter only alphabets
{
	if(window.event)
	{
		if((e.keyCode>32 && e.keyCode<=64) ||  (e.keyCode>=91 && e.keyCode<=95) 
		|| (e.keyCode==96) || (e.keyCode>=123 && e.keyCode<=127)) 
		return false;
	}//if
	else if(e.which)
	{
		if((e.which>32 && e.which<=64) ||  (e.which>=91 && e.which<=95) 
		|| (e.which==96) || (e.which>=123 && e.which<=127)) 
		return false;
	}//else if
	return true;
}
/*
3. SELECT VALIDATION

Usage:
Element  name of the control, like frm.firstname
Message  Field Name that we want to display in alert message.

if(!isValidSelect(frm.country,'Country'))
return;
*/
function isValidSelect(element,msg) 
{
	if(element.value == "-1" || element.value == "" || element.value == 0) 
	{
		alert("Please select "+msg+" from the list");
		element.focus();
		return false;
	}
	return true;
}


function isValidSelect1(element,msg) 
{
	if(element == "-1" || element == "" || element == 0) 
	{
		alert("Please select "+msg+" from the list");
		element.focus();
		return false;
	}
	return true;
}

function isValidSelect2(element,msg) 
{
		
	if(element.value == "-1") 
	{
		alert("Please select "+msg+" from the list");
		element.focus();
		return false;
	}
	return true;
}

/*

4. PHONE NUMBER VALIDATION
Usage: 
Element  name of the control, like frm.phone
Message  Field Name that we want to display in alert message.
Required  Set this to yes if the field is mandatory, otherwise no.

 if(!isValidPhone(frm.phone,'Phone Number','yes'))
 return;
*/
function isValidPhone(element, msg, required,len)
{	
	var VarPhone = element.value;
	if (VarPhone== "")
	{	
		var rval = trim(required);
		if (rval.toLowerCase() == "yes" || rval == 1)
		{
			alert("Please enter "+msg);
			element.focus();
			return false;
		}
	}
	if (VarPhone != "")
	{
		var Phno;
		Phno=VarPhone;
		var valid = "-0123456789()";
		var hyphencount = 0;
		for (var i=0; i < Phno.length; i++) 
		{
			temp = "" + Phno.substring(i, i+1);
			if (valid.indexOf(temp) == "-1")
			{
				alert("Invalid characters in your "+msg+". Please try again.");
				element.focus();
				element.value = "";
				return false;
			}
		}
		if(Phno.length<len)
		{
			alert(""+msg+" require minimum of "+len+" numbers");
			element.focus();
			element.value = "";
			return false;
		}
     } 
	 return true;      
}

//validation for fax
function isValidFax(element, msg,len)
{	
	var VarPhone = element.value;
	if (VarPhone != "")
	{
		var Phno;
		Phno=VarPhone;
		var valid = "-0123456789()";
		var hyphencount = 0;
		for (var i=0; i < Phno.length; i++) 
		{
			temp = "" + Phno.substring(i, i+1);
			if (valid.indexOf(temp) == "-1")
			{
				alert("Invalid characters in your "+msg+". Please try again.");
				element.focus();
				return false;
			}
		}
		if(Phno.length<len)
		{
			alert(""+msg+" require minimum of "+len+" characters");
			element.focus();
			return false;
		}
     } 
	 return true;      
}

//function to show the hand cursor for the image n buttons
//Page : ho_registration.php
function fnShowHand(frm,ctrl_id)
{
	var Cursor='hand';

	if (!document.all){ Cursor='pointer'; }
	
	//for mouseover
	
	document.getElementById(ctrl_id).style.cursor=Cursor;	
}


//function to show the hand cursor for the image
//Page : ho_registration.php
function fnRemoveHand(frm,ctrl_id)
{
	var Cursor='hand';

	if (!document.all){ Cursor='pointer'; }
	
	//for mouseout
	
	document.getElementById(ctrl_id).style.cursor='default';	
}

// function to trim leading & trailing spaces
function trim(strText) { 
    // this will get rid of leading spaces 
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);

    // this will get rid of trailing spaces 
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);

   return strText;
} 


//Function to goto next when <ENTER> key is pressed
function fnGoto_Next(from_field,to_field,num_char)
{
	if(from_field.value.length == num_char)
		to_field.focus();
	return true;
}



/*
2. NUMBER VALIDATION
Usage:
Element  name of the control, like frm.number
Message  Field Name that we want to display in alert message.
Required  Set this to yes if the field is mandatory, otherwise no.

 if(!isValidNumber(frm.num,'Roll Number','yes'))
 return;
*/
function isValidNumber(element, msg, required)
{  
	var VarNumber = element.value;
	if(VarNumber == "")
	{
		var rval = trim(required);
		if (rval.toLowerCase() == "yes" || rval == 1)
		{
			alert("Please enter "+msg);
			element.focus();
			return false;
		}
	}
	if (VarNumber != "")
	{
		var Num;
		Num=VarNumber;
		var valid = "0123456789";
		var hyphencount = 0;
		
		for (var i=0; i < Num.length; i++) 
		{
			temp = "" + Num.substring(i, i+1);
			if (valid.indexOf(temp) == "-1")
			{
			  alert("Invalid characters in your "+msg+".  Please try again.");
			  element.focus();
			  element.value = "";
			  return false;
			}
	   } // end for loop
	   
		if(VarNumber < 1)
		{
			alert(msg+" is not a valid number");
			element.focus();
			return false;
		}
    }   // end if
    return true; 
}  // end function
//zip code
function isValidZip(element, msg, required)
{  
	var VarNumber = element.value;
	if(VarNumber == "")
	{
		var rval = trim(required);
		if (rval.toLowerCase() == "yes" || rval == 1)
		{
			alert("Please enter "+msg);
			element.focus();
			return false;
		}
	}
	if (VarNumber != "")
	{
		var Num;
		Num=VarNumber;
		var valid = "0123456789";
		var hyphencount = 0;
		
		for (var i=0; i < Num.length; i++) 
		{
			temp = "" + Num.substring(i, i+1);
			if (valid.indexOf(temp) == "-1")
			{
			  alert("Invalid characters in your "+msg+".  Please try again.");
			  element.focus();
			  return false;
			}
	   } // end for loop
	  
		if(VarNumber.length < 3 && VarNumber.length > 5)
		{
			alert(msg+" is not a valid Zip");
			element.focus();
			return false;
		}	
		
    }   // end if
    return true; 
}  // end function
//enter only digits
function check_alpha1(e)/// validation to enter only numbers
{
  if(window.event)
  {
		if((e.keyCode > 1 && e.keyCode < 47 && e.keyCode!=8) ||(e.keyCode > 58 && e.keyCode < 255) ) 
		return false;
  }
  else if(e.which)
   {
		if((e.which > 1 && e.which < 47 && e.which!=8) ||(e.which > 58 && e.which < 255) ) 
		return false;
   }
   return true;
}

                                         
//function to allow only alphanumeric values
function checknum(e)
{
	if(window.event)
	{
		if((e.keyCode>32 && e.keyCode<=64) ||  (e.keyCode>=91 && e.keyCode<=95) 
		|| (e.keyCode==96) || (e.keyCode>=123 && e.keyCode<=127)) 
		return false;
	}//if
	else if(e.which)
	{
		if((e.which>32 && e.which<=64) ||  (e.which>=91 && e.which<=95) 
		|| (e.which==96) || (e.which>=123 && e.which<=127)) 
		return false;
	}//else if
	return true;
}

//to validate URL
function isValidURL(url){ 
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/; 
    if(RegExp.test(url)){ 
        return true; 
    }else{ 
        return false; 
    } 
} 

function isValidEmail_2(element, required)

{

	var VarEmail = element.value;

	if(VarEmail == "")

	{

		var rval = trim(required);

		if (rval.toLowerCase() == "yes" || rval == 1)

		{
			
			alert("Please enter Email Address");

			element.className = "chcolor";
			VarEmail.focus();

			return false;

		}

	}	

	if(VarEmail != "")

	{

		var emailStr = VarEmail;

		 

		var emailPat=/^(.+)@(.+)$/

		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"

		var validChars="\[^\\s" + specialChars + "\]"

		var firstChars=validChars

		var quotedUser="(\"[^\"]*\")"

		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/

		var atom="(" + firstChars + validChars + "*" + ")"

		var word="(" + atom + "|" + quotedUser + ")"

		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")

		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

		var matchArray=emailStr.match(emailPat)

		if (matchArray==null) 

		{

			 alert("Email address seems to be incorrect (check @ and .'s)");

			 element.className = "chcolor";
			 VarEmail.focus();

			 return false;

		}

		var user=matchArray[1]

		var domain=matchArray[2]

		if (user.match(userPat)==null) 

		{

			alert("The Email doesn't seem to be valid.");

			element.className = "chcolor";
			VarEmail.focus();

			return false;

		}

		var IPArray=domain.match(ipDomainPat)

	

		if (IPArray!=null) 

		{

			for (var i=1;i<=4;i++) 

			{

				if (IPArray[i]>255) 

				{

					 alert("Destination IP address is invalid!");

					 element.className = "chcolor";
					 
					 VarEmail.focus();

					 return false;

				}

			}

		}

		var domainArray=domain.match(domainPat)

		if (domainArray==null) 

		{

			alert("The domain name doesn't seem to be valid.");

			element.className = "chcolor";
			
			VarEmail.focus();

			return false;

		}

		var atomPat=new RegExp(atom,"g");

		var domArr=domain.match(atomPat);

		if (!isNaN(domArr[1]))

		{
			alert("The domain name doesn't seem to be valid and hostname and category (like .gov, .mil, .org).");

			element.className = "chcolor";
			
			VarEmail.focus();

			return false;

		}

		if( domArr[1] != 'gov' &&  domArr[1] != 'mil' && domArr[1] != 'org')
		{
			alert("The domain name doesn't seem to be valid and hostname and category (like .gov, .mil, .org).");

			element.className = "chcolor";
			
			VarEmail.focus();

			return false;

		}
		

		var len=domArr.length;

		if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) 

		{

		   var errStr = "The address must end in a three-letter domain, or two letter country.";

		   document.getElementById("errormsg").innerHTML = errStr;

		   element.className = "chcolor";

		   return false;

		}

		if (domArr[domArr.length-1].length==2 && len<3) 

		{

			var errStr = "This address ends in two characters, which is a country";

			errStr    += " code.  Country codes must be preceded by ";

			errStr	  += "a hostname and category (like .gov, .mil, .org)";

			document.getElementById("errormsg").innerHTML = errStr;

			element.className = "chcolor";

			return false;

		}

		if (domArr[domArr.length-1].length==3 && len<2) 

		{

			 var errStr="This address is missing a hostname!";

			 document.getElementById("errormsg").innerHTML = errStr;

			 element.className = "chcolor";

			 return false;

		}

	}

	return true;

}
//

function MM_openBrWindow(theURL,winName,features)
{ 
  window.open(theURL,winName,features);
}

//function to chk whether file extension correct or not
//element to check
//ext --- extension to check
//msg --- to display message
function isValidExtension(element,ext,msg) 
{
  	var ext2 = ext.toLowerCase(); 
	var imgpath = element.value;
	if(imgpath!="")
	{
		// code to get File Extension..
		var arr1 = new Array;
		arr1 = imgpath.split("\\");
		var len = arr1.length;
		var img1 = arr1[len-1];
		var filext = img1.substring(img1.lastIndexOf(".")+1);
		var ext1 = filext.toLowerCase(); 
		// Checking Extension
		if(ext1 != ext2)
		{
			alert(msg);
			element.value = "";
			return false;
		}
	}
	return true;
}

//function for paging
function page_submit(frm,page_name,pg,limit,sortby,sortoption,search_key)
{	
	frm.pg.value=pg;		
	if(limit != '')	
		frm.limit.value = limit;	
	if(frm.sortby)
		frm.sortby.value = sortby;
	if(frm.sortoption)
		frm.sortoption.value = sortoption;	
	if(frm.search_key)
		frm.search_key.value = search_key;			
	if(page_name!='')
		frm.action=page_name;
	frm.submit();
}

function page_submit_inner(frm,page_name,pg,limit,sortby,sortoption,search_key)
{	
	frm.pg_inner.value = pg;		
	if(frm.limit_inner != '')	
		frm.limit_inner.value = limit;	
	if(frm.sortby_inner)
		frm.sortby_inner.value = sortby;
	if(frm.sortoption_inner)
		frm.sortoption_inner.value = sortoption;	
	if(frm.search_key_inner)
		frm.search_key_inner.value = search_key;			
	if(page_name!='')
		frm.action=page_name;
	frm.submit();
}


function testAtleatOne(ele)
{
	var len = ele.length;
	var selected = false;
	if(ele.length)
	{
		for(var i=0;i<len;i++)
		{
			if(ele[i].checked==true)
			{
				selected=true;
				break;
			}
		}
	}	
	else
	{
		if(ele.checked==true)
			selected = true;
	}		
	return selected;
}

function selectAllNone(ele,type)
{
	if(ele)
	{
		var len = ele.length;
		if(ele.length)
		{
			for(var i=0;i<len;i++)		
				ele[i].checked = type;		
		}
		else
			ele.checked = type;	
	}
}

function formValues(frm)
{
	var cnt = frm.length;	
	var args = 'flag=true';
	for(var i=0; i<cnt;i++)
	{
		elem = frm.elements[i];
		if((elem.type == 'radio' && elem.checked) || (elem.type == 'checkbox' && elem.checked))
			args += "&"+frm.elements[i].name+"="+elem.value;
		else if(elem.type != 'radio' && elem.type != 'checkbox')
			args += "&"+elem.name+"="+elem.value;		
	}
	return args;
}

function checkprice(elm,msg,required)
{
	val = elm.value;	
	if(required)
	{
		if(val == '')
		{
				alert("Please enter "+msg);
				elm.focus();
				return false;
		}
	}
	if(val != '')
	{
		var m = /^[-+]?[0-9\.]+(\.[0-9]+)?$/.test(val);			
		if(!m)
		{
			alert("Please enter valid "+msg);
			elm.value = '';
			elm.focus();
			return false;
		}	
	}
	return true;
}


function popup_window(page,width,height)
{
	window.open(page,"","height="+height+",width="+width+",top=50,left=100,menubar=no,resizable=yes,scrollbars=yes");
}

function popup_window_re(page,width,height)
{
	window.open(page,"","height="+height+",width="+width+",top=50,left=100,menubar=no,resizable=0,scrollbars=no");
}

function createXMLHttpRequest() 
{
   try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
   try { return new XMLHttpRequest(); } catch(e) {}
   alert("XMLHttpRequest not supported");
   return null;
}

function getSize(frm,element)
{
	var myFSO = new ActiveXObject("Scripting.FileSystemObject");
	var filepath =frm.element.value;
	var thefile = myFSO.getFile(filepath);
	return  thefile.size;	
}

var Base64 = {
 
	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
 
	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = Base64._utf8_encode(input);
 
		while (i < input.length) {
 
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);
 
			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;
 
			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}
 
			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
 
		}
 
		return output;
	},
 
	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
 
		while (i < input.length) {
 
			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));
 
			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;
 
			output = output + String.fromCharCode(chr1);
 
			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}
 
		}
 
		output = Base64._utf8_decode(output);
 
		return output;
 
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}

function getSelectedRadio(frm,group1) 
{
    var found_it //initial value is null because we gave it no other value
    for (var i=0; i<frm.group1.length; i++) 
	{
        if (frm.group1[i].checked)
		{
        	found_it = frm.group1[i].value //set found_it equal to checked button's value
        }
		else
			found_it = '';
    }
   	return found_it;
} // Ends the "getSelectedRadio" function

//validate US type Phone
function isValidUSPhone(element)
{
	var numberstring = element.value.replace(/\D/g,'');
	var sVar = numberstring.toString();
	var sReturn = '';
	var iCommas;
	var iCommaAfter;
	var j = 0;		
	iCommaAfter = 3;
	for( i = 0; i < sVar.length; i++)
	{
		if( i == iCommaAfter )
		{
			sReturn = sReturn + '-';
			if(iCommaAfter)
			{
				if(iCommaAfter == 6)
					iCommaAfter = 10;
				iCommaAfter = iCommaAfter + 3;
			}
		}
		sReturn = sReturn + sVar.charAt(i);
	}
	//alert(sReturn);
	var resstring= sReturn;
	if(resstring.length == 14)
		resstring = resstring.substring(0, resstring.length-2);			
	var oRegExp = /(^\d{3}-\d{3}-\d{4}$)/;
	if (!oRegExp.test(resstring))
	{				
		element.value = resstring;
		return false;
	}
	element.value = resstring;		
	return true;
}

function geturl()
{		
	var URL = unescape(location.href)	// get current URL in plain ASCII	
	var pos = URL.indexOf('www');
	if(pos == -1)
	{
			
		URL = URL.replace('http://','');		
		URL = "http://www."+URL;		
		return URL;
	}
	else
		return '';	
}

function sethttps()
{		
	var URL = unescape(location.href)	// get current URL in plain ASCII	
	var pos = URL.indexOf('www');
	if(pos == -1)
	{
			
		URL = URL.replace('http://','');		
		URL = "https://www."+URL;		
		return URL;
	}
	else
		return '';	
}


function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}


