function trim(userInput)
{
	var iEnd, iStart, bLoop, cChar, sTrimmed;

	iEnd = userInput.length - 1;
	iStart = 0;
	bLoop = true;

	cChar = userInput.charAt(iStart);
	while ((iStart < iEnd) && ((cChar == "\n") || (cChar == "\r") || (cChar == "\t") || (cChar == " ")))
	{
		iStart ++;
		cChar = userInput.charAt(iStart);
	}

	cChar = userInput.charAt(iEnd);
	while ((iEnd >= 0) && ((cChar == "\n") || (cChar == "\r") ||
                        (cChar == "\t") || (cChar == " ")))
	{
		iEnd --;
		cChar = userInput.charAt(iEnd);
	}

	if (iStart < iEnd)
	{
		sTrimmed = userInput.substring(iStart, iEnd + 1);
	} 
	else if(iStart == iEnd) 
	{
		sTrimmed = userInput;
	}
	else
	{
		sTrimmed = "";
	}

	return sTrimmed;	
}

function SetValue(name){						
	var arg= name + "=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while(i<clen){
		var j=i+alen;
		if (document.cookie.substring(i,j)==arg){
			var endstr=document.cookie.indexOf(";",j);
			if (endstr==-1)
				endstr=document.cookie.length;
			return unescape(document.cookie.substring(j, endstr));
		}
		i= document.cookie.indexOf(" ", i) +1;
		if (i==0) break;
	}
	return null;
}

function SetCookie(name, value, expiresOld){
	var now= new Date();
	var expires = new Date(now.getTime() + 1000 * 60 * 60 * 24 * 30);
	document.cookie= name+ "=" + escape (value) + "; expires=" +expires.toGMTString();
}

function CheckString(sCheckString){
	strCheck	= new String(sCheckString);
	bCheck="True";
	for (i=0; i < strCheck.length; i++){
		CheckChar=strCheck.charCodeAt(i);
		if ((CheckChar >= 33 && CheckChar <= 38) || (CheckChar >= 42 && CheckChar <= 43) || (CheckChar >= 58 && CheckChar <= 62) || (CheckChar >= 91 && CheckChar < 95) || (CheckChar >= 123 && CheckChar <= 126))
		{
			bCheck="False";
		}
	}
	if (bCheck=="False"){
		return false;
	}
	else{
		return true;
	}
}

function SmallWindowOpen(strFileName)
{
	if (top.ICU && !top.ICU.closed )
		top.ICU.close();

 	var WindowWidth	= 200;
 	var WindowHeight= 200;
 	var WindowTop	= parseInt((screen.height-WindowHeight)/2);
 	var WindowLeft= parseInt((screen.width-WindowWidth)/2);
	top.ICU = window.open("","ICU","Height="+WindowHeight+",Width="+WindowWidth+",top="+WindowTop+",left="+WindowLeft+",titlebar=no");
	top.ICU.document.write("<html><body><center><IMG SRC=" + strFileName + "></center></body></html>");
}
function WindowOpen(strFileName)
{
	if (top.ICU && !top.ICU.closed )
		top.ICU.close();
 	var WindowWidth	= 750;
 	var WindowHeight= 550;
 	var WindowTop	= parseInt((screen.height-WindowHeight)/2);
 	var WindowLeft= parseInt((screen.width-WindowWidth)/2);
	top.ICU = window.open("","ICU","Height="+WindowHeight+",Width="+WindowWidth+",top="+WindowTop+",left="+WindowLeft+",titlebar=no");
	top.ICU.document.write("<html><body><center><IMG SRC='" + strFileName + "'><br><INPUT type='button' value='Close' onclick='window.close();' id=button1 name=button1></center></body></html>");
}

function FullWindowOpen(strFileName){
	if (top.ICU && !top.ICU.closed)
		top.ICU.close();

 	var WindowWidth	= screen.width * 0.8;
 	var WindowHeight= screen.height * 0.7;
 	var WindowTop	= parseInt((screen.height-WindowHeight)/2);
 	var WindowLeft= parseInt((screen.width-WindowWidth)/2);
	top.ICU = window.open("","ICU","Height="+WindowHeight+",Width="+WindowWidth+",top="+WindowTop+",left="+WindowLeft+",titlebar=no,scrollbars=yes,resizable=yes");
	top.ICU.document.write("<html><HEAD><TITLE>" + strFileName + "</TITLE></HEAD><body><center><IMG SRC=" + strFileName + "><br><INPUT type=button value=Close onclick=window.close() id=button1 name=button1></center></body></html>");
}

function OpenWindowCustom(strFileName,iWidth,iHeight){
	if (top.ICU && !top.ICU.closed)
		top.ICU.close();

 	var WindowWidth	= screen.width * iWidth;
 	var WindowHeight= screen.height * iHeight;
 	var WindowTop	= parseInt((screen.height-WindowHeight)/2);
 	var WindowLeft= parseInt((screen.width-WindowWidth)/2);
	top.ICU = window.open(strFileName,"ICU","Height="+WindowHeight+",Width="+WindowWidth+",top="+WindowTop+",left="+WindowLeft+",titlebar=no,scrollbars=yes,resizable=yes");
}

function FullWindow(strFileName,StrDesc,StrFullDesc)
{
	if (top.ICU && !top.ICU.closed)
		top.ICU.close();

 	var WindowWidth	= screen.width * 0.8;
 	var WindowHeight= screen.height * 0.7;
 	var WindowTop	= parseInt((screen.height-WindowHeight)/2);
 	var WindowLeft= parseInt((screen.width-WindowWidth)/2);
	//top.ICU = window.open("","ICU","Height="+WindowHeight+",Width="+WindowWidth+",top="+WindowTop+",left="+WindowLeft+",titlebar=no,scrollbars=yes,resizable=yes");
	//top.ICU.document.write("<html><HEAD><TITLE>"+StrDesc+"</TITLE></HEAD><body><center><IMG SRC=" + strFileName + "><br><INPUT type=button value=Close onclick=window.close() id=button1 name=button1></center></body></html>");
	Karunya93 = top.window.open("","Karunya93","Height="+WindowHeight+",Width="+WindowWidth+",top="+WindowTop+",left="+WindowLeft+",titlebar=no,scrollbars=yes,resizable=yes");
	Karunya93.document.write("<html><HEAD><TITLE>" +StrDesc + "</TITLE></HEAD><body><center><p style='FONT-FAMILY: Arial,Helvetica; FONT-SIZE: 9pt' >" + StrFullDesc + "<br><IMG SRC=" + strFileName+"><br><INPUT type=button value=Close onclick='window.close();' id=button1 name=button1></center></body></html>");
}

// This function Open the file in anew window with the description on the top
function WindowOpenWithDesc(strFileName,strDesc)
{
	if (top.ICU && !top.ICU.closed)
		top.ICU.close();

 	var WindowWidth	= screen.width * 0.8;
 	var WindowHeight= screen.height * 0.7;
 	var WindowTop	= parseInt((screen.height-WindowHeight)/2);
 	var WindowLeft	= parseInt((screen.width-WindowWidth)/2);

	Karunya93 = top.window.open("","Karunya93","Height="+WindowHeight+",Width="+WindowWidth+",top="+WindowTop+",left="+WindowLeft+",titlebar=no,scrollbars=yes,resizable=yes");
	Karunya93.document.write("<html><HEAD><TITLE>" + strFileName + "</TITLE></HEAD><body><center><p style='FONT-FAMILY: Arial,Helvetica; FONT-SIZE: 9pt' >" + strDesc + "<br><IMG SRC=" + strFileName+"><br><INPUT type=button value=Close onclick='window.close();' id=button1 name=button1></center></body></html>");
}

function OpenURL(strLoc,iWidth,iHeight,sToolbar,sMenubar,sTitlebar,sScrollbar,sresizable)
{
	if (top.SoffrontKb && !top.SoffrontKb.closed )
		{top.SoffrontKb.close()}

 	var WindowWidth	= screen.width * parseFloat(iWidth);
 	var WindowHeight= screen.height * parseFloat(iHeight);
 	var WindowTop	= parseInt((screen.height-WindowHeight)/2);
 	var WindowLeft	= parseInt((screen.width-WindowWidth)/2);
	top.SoffrontKb = window.open(strLoc,"SoffrontKb","Height="+WindowHeight+",Width="+WindowWidth+",top="+WindowTop+",left="+WindowLeft+",titlebar=" + sTitlebar + ",scrollbars=" + sScrollbar + ",resizable=" + sresizable + ",toolbar=" + sToolbar + ",menubar=" + sMenubar);
	top.SoffrontKb.focus();
}

function EmailValidate(strEMail)
{
	var StrInvalidEmailMsg	= "Invalid Email ID\rEmail ID should be like name@company.com.";
	strFind	= new String(strEMail);
	if ( ((strFind.indexOf("@") == -1) ||(strFind.indexOf(".") == -1)) && (strFind != ""))
	{
		alert(StrInvalidEmailMsg);
		return false;
	}
	if (strFind.indexOf("@") != strFind.lastIndexOf("@")){
		alert(StrInvalidEmailMsg);
		return false;
	}
	if (strFind.indexOf("@") > strFind.lastIndexOf(".")-2){
		alert(StrInvalidEmailMsg);
		return false;
	}
	if (strFind.search('@') < 0){
		alert(StrInvalidEmailMsg);
		return false;
	}
	if (strFind.search(' ') > 0){
		alert("Invalid Email ID\rEmail ID cannot have spaces\rEmail ID should be like name@company.com.");
		return false;
	}
	if (strFind.charAt(strFind.length-1) == '.'){
		alert(StrInvalidEmailMsg);
		return false;
	}

	var strCheck	= new String(strEMail);
	for (i=0; i < strCheck.length; i++){
		CheckChar = strCheck.charCodeAt(i);
		if ((CheckChar >= 32 && CheckChar <= 44) || (CheckChar >= 58 && CheckChar <= 63) || (CheckChar >= 91 && CheckChar < 95) || (CheckChar >= 123 && CheckChar <= 126) || (CheckChar == 47) || (CheckChar == 96))
		{
			alert("Invalid Email ID\rEmail ID cannot have special characters\rEmail ID should be like name@company.com.");
			return false;
		}
	}
	return true;
}


function OnOpenSendMail()
{
	if (top.ICU1 && !top.ICU1.closed)
		top.ICU1.close();

	var WindowWidth	= screen.width * 0.5;
	var WindowHeight= screen.height * 0.55;
	var WindowTop	= parseInt((screen.height-WindowHeight)/2);
	var WindowLeft= parseInt((screen.width-WindowWidth)/2);
	ICU1 = top.window.open("SendMail.aspx","ICU1","Height="+WindowHeight+",Width="+WindowWidth+",top="+WindowTop+",left="+WindowLeft+",titlebar=no,scrollbars=yes,resizable=yes");
}

function popUp(url)
{
	if (top.ICU && !top.ICU.closed)
		top.ICU.close();

	var WindowWidth	= screen.width * 0.8;
	var WindowHeight= screen.height * 0.6;
	var WindowTop	= parseInt((screen.height-WindowHeight)/2);
	var WindowLeft= parseInt((screen.width-WindowWidth)/2);
	ICU = top.window.open(url,"ICU","Height="+WindowHeight+",Width="+WindowWidth+",top="+WindowTop+",left="+WindowLeft+",titlebar=no,scrollbars=yes,resizable=yes");
	//sealWin1=window.open(url,"win1",'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=0,width=750,height=480');   
}
//popUp("FastingPrayer/2005/FastingPrayerFlyer2005.jpg");

function OnOpenWindow()
{
	if (top.ICU1 && !top.ICU1.closed)
		top.ICU1.close();

	var WindowWidth	= screen.width * 0.5;
	var WindowHeight= screen.height * 0.65;
	var WindowTop	= parseInt((screen.height-WindowHeight)/2);
	var WindowLeft= parseInt((screen.width-WindowWidth)/2);
	ICU1 = top.window.open("http://www.indianchristiansunited.org/Register.php","ICU1","Height="+WindowHeight+",Width="+WindowWidth+",top="+WindowTop+",left="+WindowLeft+",titlebar=no,scrollbars=yes,resizable=yes");
}

function GetDirections(intType)
{
	var strLoc = "";
	if (top.ICU1 && !top.ICU1.closed)
		top.ICU1.close();
		
	if (intType == 2)
		strLoc = "http://www.mapquest.com/maps/map.adp?address=47%20Winthrop%20St&city=Williston%20Park&state=NY&zipcode=11596%2d1850&country=US&title=47%20Winthrop%20St%20Williston%20Park%2c%20NY%2011596%2d1850%2c%20US&cid=lfmaplink2";
	else
		strLoc = "http://www.mapquest.com/maps/map.adp?address=560%20N%20Britton%20Ave&city=Sunnyvale&state=CA&zipcode=94085%2d3841&country=US&title=560%20N%20Britton%20Ave%20Sunnyvale%2c%20CA%2094085%2d3841%2c%20US&cid=lfmaplink2";

	var WindowWidth	= screen.width * 0.8;
	var WindowHeight= screen.height * 0.7;
	var WindowTop	= parseInt((screen.height-WindowHeight)/2);
	var WindowLeft= parseInt((screen.width-WindowWidth)/2);
	ICU = top.window.open(strLoc,"ICU","Height="+WindowHeight+",Width="+WindowWidth+",top="+WindowTop+",left="+WindowLeft+",toolbar=yes,scrollbars=yes,resizable=yes");
}

function OnDivClick(divName)
{
	if (document.getElementById(divName).style.display == "")
	{
		document.getElementById(divName).style.display = "none";
		document.getElementById("img" + divName).src = "images/Plus.jpg";
		
	}
	else
	{
		document.getElementById(divName).style.display = "";
		document.getElementById("img" + divName).src = "images/Minus.jpg";
	}
}