
 /**********************************************************************************   
      *   Function Name: pickRandom
      *   Parameters: range
      *   Returns:  image links
      *   Description: To get random images
      *   Revision History:
      *   Initials                 Date              Changes
      * ---------------------------------------------------------- 
      *   Sreekumar               19/10/2005          Created
      *********************************************************************************/



    // JavaScript to interpolate random images into a page.
    var ic = 6;     // Number of alternative images
    var xoxo0 = new Array(ic);  // Array to hold filenames
	var xoxo1 = new Array(ic);
    var xoxo2 = new Array(ic);
	
	   
xoxo0[0] = "images/agriculture_ar_01.jpg";
xoxo1[0] = "images/agriculture_ar_02.jpg";
xoxo2[0] = "images/agriculture_ar_03.jpg";

xoxo0[1] = "images/awarness_ar_01.jpg";
xoxo1[1] = "images/awarness_ar_02.jpg";
xoxo2[1] = "images/awarness_ar_03.jpg";

xoxo0[2] = "images/CivicCenters_ar_01.jpg";
xoxo1[2] = "images/CivicCenters_ar_02.jpg";
xoxo2[2] = "images/CivicCenters_ar_03.jpg";


xoxo0[3] = "images/healthcenters_ar_01.jpg";
xoxo1[3] = "images/healthcenters_ar_02.jpg";
xoxo2[3] = "images/healthcenters_ar_03.jpg";

xoxo0[4] = "images/innovation_ar_01.jpg";
xoxo1[4] = "images/innovation_ar_02.jpg";
xoxo2[4] = "images/innovation_ar_03.jpg";

xoxo0[5] = "images/MicroCredit_ar_01.jpg";
xoxo1[5] = "images/MicroCredit_ar_02.jpg";
xoxo2[5] = "images/MicroCredit_ar_03.jpg";



function pickRandom(range) {
if (Math.random)
return Math.round(Math.random() * (range-1));
else {
var now = new Date();
return (now.getTime() / 1000) % range;
}
}
// Write out an IMG tag, using a randomly-chosen image name.

// -->




function echeck() {
		var str=document.f1.email.value;
		
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(dot)==(str.length-1))
		{
			alert("Invalid E-mail ID");
			f1.email.focus();
		   return false;
		}
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID");
		   f1.email.focus();
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID");
		   f1.email.focus();
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID");
			f1.email.focus();
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID");
			f1.email.focus();
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID");
			f1.email.focus();
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID");
			f1.email.focus();
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID");
			f1.email.focus();
		    return false;
		 }
	
	}

	/////////////////////////////////////////////////////////////////////////////////////

	var agt = navigator.userAgent.toLowerCase();
var ns6 = (!document.all && document.getElementById);
var ie5 = (agt.indexOf('msie') != -1);
var ie4 = document.all;
var ns4 = (document.layers);
var t;
var t1;
var t2;
var submenus = ["Civic","Micro","Awareness","Healthcare","Agriculture","Award","Special"];
var currentStory = -1;
var currentLength = 0;
var objTicker;
var characterTimeout = 50;
var storyTimeout = 5000;
var WidgetOne = "_";
var WidgetTwo = "-";
var NoWidget = "";
var headLines = new Array();
var headLineLinks = new Array();
var objTicker;


function jsfnHighlight(obj)
{
      /**********************************************************************************   
      *   Function Name: jsfnHighlight
      *   Parameters: obj
      *   Returns: N/A
      *   Description: The function Highlights the menu link
      *   Revision History:
      *   Initials                 Date              Changes
      * ---------------------------------------------------------- 
      *   ML                       02/03/05          Created
      *********************************************************************************/
  var classString = obj.className;
  if (classString.match("ft_MtextGray")==null)	
	  obj.className = "ft_MtextH";

}

function jsfnDimMe(obj)
{
      /**********************************************************************************   
      *   Function Name: jsfnDimMe
      *   Parameters: obj
      *   Returns: N/A
      *   Description: The function dims the highlighted link
      *   Revision History:
      *   Initials                 Date              Changes
      * ---------------------------------------------------------- 
      *   ML                       02/03/05          Created
      *********************************************************************************/
  var classString = obj.className;
  if (classString.match("ft_MtextGray")==null)	
	 obj.className = "ft_Mtext";
}
function jsfnHighlightItem(item,item1)
{
      /**********************************************************************************   
      *   Function Name: jsfnHighlight
      *   Parameters: item
      *   Returns: N/A
      *   Description: The function Highlights the menu Cell
      *   Revision History:
      *   Initials                 Date              Changes
      * ---------------------------------------------------------- 
      *   ML                       02/03/05          Created
      *********************************************************************************/
 //alert(item1)
  var obj;
  obj = jsfnfindObj(item);

  if (item1=='micro')
  {
  obj.className = "td_popmenuH2";	
  }
  if (item1=='civic')
  {
  obj.className = "td_popmenuH";
  }
  if (item1=='aware')
  {
  obj.className = "td_popmenuH3";
  }
  if (item1=='health')
  {
  obj.className = "td_popmenuH4";
  }
   if (item1=='award')
  {
  obj.className = "td_popmenuH5";
  }
   if (item1=='agri')
  {
  obj.className = "td_popmenuH6";
  }
  if (item1=='special')
  {
  obj.className = "td_popmenuH";
  }
}


function jsfnHighlightItem1(item)
{
      /**********************************************************************************   
      *   Function Name: jsfnHighlight1
      *   Parameters: item
      *   Returns: N/A
      *   Description: The function Highlights the menu Cell
      *   Revision History:
      *   Initials                 Date              Changes
      * ---------------------------------------------------------- 
      *   Sreekumar                05/06/05          Created
      *********************************************************************************/
  var obj;
  obj = jsfnfindObj(item);
  obj.className = "td_popmenuH1";
}




function jsfnDimItem(item,item1)
{
      /**********************************************************************************   
      *   Function Name: jsfnDimMe
      *   Parameters: obj
      *   Returns: N/A
      *   Description: The function dims the highlighted Cell
      *   Revision History:
      *   Initials                 Date              Changes
      * ---------------------------------------------------------- 
      *   ML                       02/03/05          Created
      *********************************************************************************/
 //alert(item1)
  var obj;
  obj = jsfnfindObj(item);
   if (item1=='micro')
  {
  obj.className = "td_popmenu2";	
  }
   if (item1=='civic')
  {
  obj.className = "td_popmenu";
  }
  if (item1=='aware')
  {
  obj.className = "td_popmenu3";
  }
  if (item1=='health')
  {
  obj.className = "td_popmenu4";
  }
  if (item1=='award')
  {
  obj.className = "td_popmenu5";
  }
  if (item1=='agri')
  {
  obj.className = "td_popmenu6";
  }
   if (item1=='special')
  {
  obj.className = "td_popmenu";
  }
}


function jsfnDimItem1(item)
{
      /**********************************************************************************   
      *   Function Name: jsfnDimItem1
      *   Parameters: obj
      *   Returns: N/A
      *   Description: The function dims the highlighted Cell
      *   Revision History:
      *   Initials                 Date              Changes
      * ---------------------------------------------------------- 
      *   Sreekumar                05/06/05          Created
      *********************************************************************************/
  var obj;
  obj = jsfnfindObj(item);
  obj.className = "td_popmenu1";
}

function jsfnPopUp(menuid,action)
{
      /**********************************************************************************   
      *   Function Name: jsfnPopUp(id,action)
      *   Parameters: menuid = identity of the item , action=show/hide
      *   Returns: N/A
      *   Description: The function displays the popupmenu
      *   Revision History:
      *   Initials                 Date              Changes
      * ---------------------------------------------------------- 
      *   ML                       02/03/05          Created
      *********************************************************************************/
var obj,v;

v = action;
if (t) {
      clearTimeout(t);
      t = null;
}
if ((obj=jsfnfindObj(menuid))!=null)  { 
         if (obj.style) {
            obj=obj.style; 
			
            v=(action=='show')?'block':(action=='hide')?'none':action; 
			//alert(v);
          }
        obj.display=v; 
	}	
}



function jsfnPopUp1(menuid,action)
{
     
var obj,v;

v = action;
if (t1) {
      clearTimeout(t1);
      t1 = null;
}
if ((obj=jsfnfindObj(menuid))!=null)  { 
         if (obj.style) {
            obj=obj.style; 
			
            v=(action=='show')?'block':(action=='hide')?'none':action; 
			//alert(v);
          }
        obj.display=v; 
	}	
}


function jsfnfitmainpane(xwidth)
{
      /**********************************************************************************   
      *   Function Name: jsfnfitmainpane
      *   Parameters: xwidth - horizontal resolution
      *   Returns:  none
      *   Description: The function fits the hidden pane to the screen width
      *   Revision History:
      *   Initials                 Date              Changes
      * ---------------------------------------------------------- 
      *   ML                       02/03/05          Created
      *********************************************************************************/
var obj;

if (ns6) {
            obj = document.getElementById('mainpane');
}

else if (ie4){
            obj = document.all['mainpane'];
}

else if (ns4) {
            obj = document.layers['mainpane'];
}

 obj.style.width=xwidth;

}

function jsfnsetTimer(menuid)
{ 
      /**********************************************************************************   
      *   Function Name: jsfnsetTimer
      *
      *   Parameters: menuid = identity of the item
      *               
      *   Returns: N/A
      *   Description: The function sets a timer to call the function to hide the item 
      *        represened by the id.
      *   Revision History:
      *   Initials                 Date              Changes
      * ---------------------------------------------------------- 
      *   ML                       02/03/05          Created
      *********************************************************************************/

 t = setTimeout("jsfnPopUp('" + menuid + "','hide')",1000);

}

function jsfnsetTimer1(menuid)
{ 
      /**********************************************************************************   
      *   Function Name: jsfnsetTimer
      *
      *   Parameters: menuid = identity of the item
      *               
      *   Returns: N/A
      *   Description: The function sets a timer to call the function to hide the item 
      *        represened by the id.
      *   Revision History:
      *   Initials                 Date              Changes
      * ---------------------------------------------------------- 
      *   ML                       02/03/05          Created
      *********************************************************************************/

 t1 = setTimeout("jsfnPopUp1('" + menuid + "','hide')",1000);

}


function jsfnlayersCloseAll_old(){
      /**********************************************************************************   
      *   Function Name: jsfnlayersCloseAll
      *   Parameters: None
      *   Returns: N/A
      *   Description: The function forcibly hides all the popup submenus 
      *   Revision History:
      *   Initials                 Date              Changes
      * ---------------------------------------------------------- 
      *   ML                       02/05/05          Created
      *********************************************************************************/
for (var i=0;i < submenus.length;i++)
	jsfnPopUp(submenus[i],'hide');
}
function jsfnSubPopUp(menuid,parentid){
      /**********************************************************************************   
      *   Function Name: jsfnSubPopUp
      *   Parameters: menuid,parentid
      *   Returns: N/A
      *   Description: The function displays submenus 
      *   Revision History:
      *   Initials                 Date              Changes
      * ---------------------------------------------------------- 
      *   ML                       02/05/05          Created
      *********************************************************************************/
	if ((obj=jsfnfindObj(menuid))!=null)  { 
         if (obj.style) {
		 obj=obj.style;
		
           (obj.display=='none') ? (obj.display='block'):((obj.display=='block') ? (obj.display='none') : obj.display='block');
	}
	}
}

function jsfnfindObj(n,d) { //v4.01
      /**********************************************************************************   
      *   Function Name: jsfnfindObj
      *   Parameters: n = id, d=document object
      *   Returns:  an object 
      *   Description: The function parses thorugh all the components in the page to locate 
      * 	the object corresponding to the id given and returns it
      *   Revision History:
      *   Initials                 Date              Changes
      * ---------------------------------------------------------- 
      *   ML                       02/03/05          Created
      *********************************************************************************/
  var p,i,x;  
  if(!d) d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; 
    n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) x=d.all[n]; 
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
    x=jsfnfindObj(n,d.layers[i].document);
  if(!x && d.getElementById) 
	x=d.getElementById(n); 
  return x;
}


function jsfnBeginTick() {
      /**********************************************************************************   
      *   Function Name: jsfnBeginTick
      *   Parameters: none
      *   Returns:  none
      *   Description: The function initializes the ticker 
      *   Revision History:
      *   Initials                 Date              Changes
      * ---------------------------------------------------------- 
      *   ML                       02/20/05          Created
      *********************************************************************************/
	
	currentStory = -1;
	currentLength = 0;

	//locate base objects
	if (document.getElementById) {
		objTicker = jsfnfindObj("tickbar");
		jsfnRunTicker();
	}
	else
	{
		document.write("<style>.tickerbar{display:none;}</style>");
            return true;
	}

}

function jsfnRunTicker()
{
      /**********************************************************************************   
      *   Function Name: jsfnRunTicker
      *   Parameters: none
      *   Returns:  none
      *   Description: The function displays the ticker on the ticker bar 
      *   Revision History:
      *   Initials                 Date              Changes
      * ---------------------------------------------------------- 
      *   ML                       02/20/05          Created
      *********************************************************************************/
	
	var myTimeout;

	if (currentLength==0) {
		currentStory++;
		currentStory = currentStory % theItemCount;
		currentHeadline = headLines[currentStory].replace(/&quot;/g,'"');
		targetLink = headLineLinks[currentStory];
		objTicker.href = targetLink;
	}

	objTicker.innerHTML = currentHeadline.substring(0,currentLength) + jsfnWhatWidget();
	// Modify the length for the substring and define the timer

	if(currentLength != currentHeadline.length)
	{
		currentLength++;
		myTimeout = characterTimeout;
	}
	else
	{
		currentLength = 0;
		myTimeout = storyTimeout;
	}
	// Call up the next cycle of the ticker
	setTimeout("jsfnRunTicker()", myTimeout);	
}

function jsfnWhatWidget() {
      /**********************************************************************************   
      *   Function Name: jsfnWhatWidget
      *   Parameters: none
      *   Returns:  widgets
      *   Description: widget generator
      *   Revision History:
      *   Initials                 Date              Changes
      * ---------------------------------------------------------- 
      *   ML                       02/20/05          Created
      *********************************************************************************/

	if (currentLength == currentHeadline.length)
	{
		return NoWidget;
	}
	if ((currentLength % 2) == 1) 
	{
		return WidgetOne;
	}
	else
	{
		return WidgetTwo;
	}
}



function jsfnlayersCloseAll()
	{
   var popup = document.getElementById("civic");
	popup.style.display="none";
	popup = document.getElementById("micro");
	popup.style.display="none";
	popup = document.getElementById("awareness");
	popup.style.display="none";
	popup = document.getElementById("healthcare");
	popup.style.display="none";
	popup = document.getElementById("award");
	popup.style.display="none";
	popup = document.getElementById("agriculture");
	popup.style.display="none";
	popup = document.getElementById("special");
	popup.style.display="none";

}    

function jsfnlayers_CloseAll()
	{
   var popup = document.getElementById("civic");
	popup.style.display="none";
}    





function validate()
{
		var str=document.frmUnsubscribeForm.txtEmailAddress.value;		
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		
		
		if (document.frmUnsubscribeForm.txtEmailAddress.value=="")
		{
		alert("Enter E-mail Address");
		document.frmUnsubscribeForm.txtEmailAddress.focus();
		return false;			
		}	
		
		if (str.indexOf(dot)==(str.length-1))
		{
			alert("Invalid E-mail ID");
			document.frmUnsubscribeForm.txtEmailAddress.focus();
		   return false;
		}
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID");
		   document.frmUnsubscribeForm.txtEmailAddress.focus();
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID");
		   document.frmUnsubscribeForm.txtEmailAddress.focus();
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID");
			document.frmUnsubscribeForm.txtEmailAddress.focus();
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID");
			document.frmUnsubscribeForm.txtEmailAddress.focus();
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID");
			document.frmUnsubscribeForm.txtEmailAddress.focus();
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID");
			document.frmUnsubscribeForm.txtEmailAddress.focus();
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID");
			document.frmUnsubscribeForm.txtEmailAddress.focus();
		    return false;
		 }
	
	}






function validateDetails()
{	
   if (document.frmDetail.txtName.value=="")
	{
		alert("Enter your name");
		document.frmDetail.txtName.focus();
		return false;			
	}	
	
	
	
	if (document.frmDetail.txtAddress.value=="")
	{
		alert("Enter Address");
		document.frmDetail.txtAddress.focus();
		return false;			
	}	
	
	
	if (document.frmDetail.txtCompany.value=="")
	{
		alert("Enter your company name");
		document.frmDetail.txtCompany.focus();
		return false;			
	}
	
	if (document.frmDetail.txtPhone.value=="")
	{
		alert("Enter phone number");
		document.frmDetail.txtPhone.focus();
		return false;			
	}	
	
	
	
	if (document.frmDetail.txtEmailAddress.value=="")
	{
		alert("Enter email address");
		document.frmDetail.txtEmailAddress.focus();
		return false;			
	}
	else
	{
	var str=document.frmDetail.txtEmailAddress.value;
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		
		if (str.indexOf(dot)==(str.length-1))
		{
			alert("Invalid E-mail ID");
			document.frmDetail.txtEmailAddress.focus();
		    return false;
			
		}
		 if (str.indexOf(at)==-1)
		 {
		   alert("Invalid E-mail ID");
		   document.frmDetail.txtEmailAddress.focus();
		   return false;
		}

		 if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		 {
		   alert("Invalid E-mail ID");
		   document.frmDetail.txtEmailAddress.focus();
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		{
		    alert("Invalid E-mail ID");
			document.frmDetail.txtEmailAddress.focus();
		    return false;
		}

		if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID");
			document.frmDetail.txtEmailAddress.focus();
		    return false;
		 }

		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		{
		    alert("Invalid E-mail ID");
			document.frmDetail.txtEmailAddress.focus();
		    return false;
		 }

		if (str.indexOf(dot,(lat+2))==-1)
		{
		    alert("Invalid E-mail ID");
			document.frmDetail.txtEmailAddress.focus();
		    return false;
		 }
		
		if (str.indexOf(" ")!=-1)
		{
		    alert("Invalid E-mail ID");
			document.frmDetail.txtEmailAddress.focus();
		    return false;
		 }

	} //else ends	

}//function end