	/******* Code by Zaheer Hussain **********/
	
	function isAllSpaces(myStr){
		while (myStr.substring(0, 1) == " ") {
			myStr = myStr.substring(1, myStr.length);
		}
	
		if(myStr == ""){
			return true;
		}
		return false;
	} // end fn isAllSpaces

	
	function isValidDate(year, month, day){
		myDate = new Date(month + "/" + day + "/" + year);
		if(parseInt(myDate.getDate()) != parseInt(day)){
			return false;
		}
		else
			return true;
	} // end fn isValidDate

	function isValidTime(sy, sm, sd, shh, smm, sampm, ey, em, ed, ehh, emm, eampm){
		if(sampm == "pm")
			shh = shh + 12;
			
		if(eampm == "pm")
			ehh = ehh + 12;
			
		myStartTime = new Date(sy, sm, sd, shh, smm, 00);
		myEndTime =   new Date(ey, em, ed, shh, smm, 00);
		
		if(Date.parse(myStartTime) < Date.parse(myEndTime)){
			return false;
		}
		
		return true;
		
	}//end fn isValidTime
		
/*	function isValidTime(myTimeField) {
		timeValue = myTimeField.value.toUpperCase();
		timeValue = ReplaceText(timeValue," ","");
		if(timeValue.indexOf("PM") != -1 || timeValue.indexOf("AM") != -1){
			//mTime = timeValue.substring(0,timeValue.length-2);
			//ampm = timeValue.substring(timeValue.length -2, timeValue.length);
			//timeValue = mTime + " " + ampm
			timeValue=ReplaceText(timeValue,"PM"," PM")
			timeValue=ReplaceText(timeValue,"AM"," AM")
		}
		myTime = new Date("12/12/2000 " + timeValue)
		if (myTime == "NaN" || myTime == "Invalid Date"){
			alert("Not a valid time. (Use hh:mm AM)");
			myTimeField.focus();
			return false;
		}
		return timeValue;
	} // end fn isValidTime	
*/

function isSpecialChar(myString){
		var MyStr = '<>;/\\*&^%$#!"~+=:;,?';
		for (i=0; i<myString.length; i++) {
			var MyChar = myString.substring(i,i+1);
			if (MyStr.indexOf(MyChar) != -1) {
				return true;
			}
		}
		return false;
	} // end fn isSpecialChar

function isEmail(s){
	if(s.length == 0)
		return false;
	if	(	(s.indexOf("@") <= 0) || 
			(s.indexOf("@") == s.length -1) || 
			(s.indexOf("@") != s.lastIndexOf("@")) || 
			(s.indexOf(".") <= 0) || 
			(s.indexOf(" ") > -1) || 
			(s.lastIndexOf(".") == s.length -1) ||
			(s.lastIndexOf(".") < s.indexOf("@")) ||
			(s.indexOf("..") != -1) ||
			(isSpecialChar(s)) ||
			(s.charAt(s.indexOf("@") + 1) == ".") ||
			(s.charAt(s.indexOf("@") - 1) == ".")			
		) return false;
	else return true;
} //end fn isEmail
function checkForNums(theForm)
	{
		var nfound = 0;
		var alphas = " .ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()-+`~,";
		var myValue = theForm.value.toUpperCase();
		for(count=0;count<= myValue.length-1;count++)
			{
			if (alphas.indexOf(myValue.substring(count, count+1)) == -1)
				{
				//alert(alphas.indexOf(myValue.substring(count, count+1));
				nfound++;
				}
			}
		return nfound;
	}
	
function CheckAlphas(mValue)
	{
		var notFound=0;
		var n="0123456789";
		for (c=0; c<=mValue.length-1; c++)
			{
			if (n.indexOf(mValue.substring(c,c+1)) == -1)
				notFound++;
			}
		return notFound;
		}

	//function checks whether any checkboxed is checked or not
	function checkAllChecked(theform){
		numBoxes = 0;
		checkedBoxes = 0;
		for(i = 0; i < theform.elements.length; i++){
			if(theform.elements[i].name == "del[]" ||theform.elements[i].id == "del" || theform.elements[i].name == "del"){
				numBoxes++;
				if(theform.elements[i].checked){
					checkedBoxes++;
				}
			}
		}
		if(checkedBoxes > 0 ){
			return true;
		}
		else{
			return false;
		}
		
	}

// fucntion to manipulate the check boxe
	function checkall(theform)
	{
		if(theform.deleteall.checked)
		{
			for(i=0; i < theform.elements.length; i++)
				if(theform.elements[i].type == "checkbox")
					theform.elements[i].checked = 1;
		}
		else 
		{
			for(i=0; i < theform.elements.length; i++)
				if(theform.elements[i].type == "checkbox")
					theform.elements[i].checked = 0;

		}
		
	}
	function isInt(myString){
	var i;
	var MyStr = "0123456789";
	if(myString.length==1 && myString.value==0){
		return false;
	}
	for (i=0; i<myString.length; i++){
		var MyChar = myString.substring(i,i+1);
		if (MyStr.indexOf(MyChar) == -1){
			return false;
		}
	}
	return true;
}

function isValidURL(s){
	if(s.length == 0)
		return false;

	if ( s.substring(0,7) == "http://" )
		s = s.substring(7, s.length);
	if	(	(s.indexOf(".") <= 0) || 
			(s.indexOf(" ") > -1) || 
			(s.lastIndexOf(".") == s.length -1) ||
			(s.indexOf("..") != -1) ||
			(isSpecialChar1(s))
		) return false;
	else return true;
} //end fn isURL

function checkClicked(theForm){
	var length = theForm.inID.length;
	var checked = 0;
	for(i=0; i<length; i++){
		if(theForm.inID[i].selected)
			checked++;
	}
	
	return checked;
}//end Check Clicked

function ReplaceText(TextValue,Replace,ReplaceWith){
		var l_space=true;
	    var l_Index=0;
	    while (l_space){
			l_Index=TextValue.indexOf(Replace,l_Index);
	        if (l_Index==-1){
				l_space=false;
			}
	        else{
			TextValue=TextValue.substring(0,l_Index)+ReplaceWith+TextValue.substring(l_Index+Replace.length,TextValue.length);
			l_Index=l_Index+ReplaceWith.length;
			}
		}
    return TextValue;
}// end fn ReplaceText

//check word length function by MSHaider
function checkWordLen(val,limit)
{
	if(val.length > 0)
	{
		arrString = val.split(" ");
		for(var i=0; i<arrString.length; i++)
		{
			if (arrString[i].length >limit)
			{
				return true;
				break;
			}
			else
			{
				return false;	
			}
		}
	}
	else
	{
		return false;
	}
}	

// function for encode the URL
function isSpecialChar1(myString){
		var MyStr = '<>;\\*^$#!"~+:;,';
		for (i=0; i<myString.length; i++) {
			var MyChar = myString.substring(i,i+1);
			if (MyStr.indexOf(MyChar) != -1) {
				return true;
			}
		}
		return false;
	} // end fn isSpecialChar

	function urlEncode(inStr) {
outStr=' '; //not '' for a NS bug!
for (i=0; i < inStr.length; i++) {
aChar=inStr.substring (i, i+1);
switch(aChar){
case '%': outStr += "%25"; break; case ',': outStr += "%2C"; break;
case '/': outStr += "%2F"; break; case ':': outStr += "%3A"; break;
case '~': outStr += "%7E"; break; case '!': outStr += "%21"; break;
case '"': outStr += "%22"; break; case '#': outStr += "%23"; break;
case '$': outStr += "%24"; break; case "'": outStr += "%27"; break;
case '`': outStr += "%60"; break; case '^': outStr += "%5E"; break;
case '&': outStr += "%26"; break; case '(': outStr += "%28"; break;
case ')': outStr += "%29"; break; case '+': outStr += "%2B"; break;
case '{': outStr += "%7B"; break; case '|': outStr += "%7C"; break;
case '}': outStr += "%7D"; break; case ';': outStr += "%3B"; break;
case '<': outStr += "%3C"; break; case '=': outStr += "%3D"; break;
case '>': outStr += "%3E"; break; case '?': outStr += "%3F"; break;
case '[': outStr += "%5B"; break; case '\\': outStr += "%5C"; break;
case ']': outStr += "%5D"; break; case ' ': outStr += "+"; break;
default: outStr += aChar;
}
}
return outStr.substring(1, outStr.length);
}


function checkFileType(fileobj){
	theForm = fileobj.form;
	fileValue = fileobj.value;
	fileExtension = fileValue.substr(fileValue.lastIndexOf(".")+1,fileValue.length - fileValue.lastIndexOf(".")+1).toLowerCase();
	if(fileExtension == "bmp" || fileExtension == "gif" || fileExtension == "jpg"){
//		document.adImg.src = theForm.adImage.value;
		return true;
	}
	else{
		alert("Please select a valid [bmp, gif or jpg] image file.");
//		document.adImg.src = "../../images/trans.gif";
		return false;
	}
}


function GoAddressWindow(currentids, fieldname, type){
	var url = siteURL + "addressbook.php?session={sessid1}&fieldname=" + fieldname + "&ugid=" + type + "&to_ids=" + currentids;
	var hWnd = window.open(url,"_addressbook","width=360,height=300,resizable=yes,scrollbars=yes");
	if ((document.window != null) && (!hWnd.opener))
		hWnd.opener = document.window;
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function ImagePopUp(urlen, width, height){
	NewWindow=window.open(urlen, 'popUpWindow', 'width=' + width + ',height=' + height + ',scrollbars=yes,toolbar=no,location=no,menubar=no,status=no, horizontalscroll=no')
}