// JavaScript Document
//
// Switch Menu script
//Author Binu jose 

var persistmenu="no" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only
//get and set the originating url
var strPreUrl = document.URL; 
strPreUrl=strPreUrl.substr(0,strPreUrl.indexOf('//')+2)+document.domain;

if (document.getElementById){ 
document.write('<style type="text/css">\n')
//document.write('.submenu{display: none;}\n')
document.write('</style>\n')

}

function SwitchMenu(obj){
	if(document.getElementById){
	var divNum= obj.substring(obj.length,obj.length-1);
	
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv").getElementsByTagName("span"); 
	
		if(el.style.display != "block"){ 
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") {
				ar[i].style.display = "none";
				}
				if (document.getElementById("spn"+i)){
				//document.getElementById("spn"+i).style.backgroundImage="url(/images/up_arrow.gif)";http://www.ccatenn.org/newWeb/images/down_arrow.gif
				document.getElementById("spn"+i).innerHTML="<img src='" + strPreUrl + "/images/common/down_arrow.gif' border='0'>";
				}
			}
			el.style.display = "block";
			//document.getElementById("spn"+divNum).style.backgroundImage="url(/images/down_arrow.gif)";
			document.getElementById("spn"+divNum).innerHTML="<img src='" + strPreUrl + "/images/common/up_arrow.gif' border='0'>";
		}else{
			el.style.display = "none";
			//if (obj){
			//document.getElementById("spn"+divNum).style.backgroundImage="url(/images/up_arrow.gif)";
			document.getElementById("spn"+divNum).innerHTML="<img src='" + strPreUrl + "/images/common/down_arrow.gif' border='0'>";
			//}
		}
	}
}

function SwitchMenuTop(){
	if(document.getElementById){
	//var divNum= obj.substring(obj.length,obj.length-1);
	
	//var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv").getElementsByTagName("span"); 
	
		//if(el.style.display != "block"){ 
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu"){
				ar[i].style.display = "none";
				}
				if (document.getElementById("spn"+i)){
				//document.getElementById("spn"+i).style.backgroundImage="url(/images/up_arrow.gif)";
				document.getElementById("spn"+i).innerHTML="<img src='" + strPreUrl + "/images/common/down_arrow.gif' border='0'>";
				}
			}
			//el.style.display = "block";
			//document.getElementById("div"+divNum).style.backgroundImage="url(/images/down_arrow.gif)";
		//}else{
			//el.style.display = "none";
			//if (obj){
			//document.getElementById("div"+divNum).style.backgroundImage="url(/images/up_arrow.gif)";
			//}
		//}
	}
}


function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
	var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname;
	var cookievalue=get_cookie(cookiename);
	if (cookievalue!=""){
		document.getElementById(cookievalue).style.display="block";
		var divNum= cookievalue.substring(cookievalue.length,cookievalue.length-1);
		if (document.getElementById("spn"+divNum)) {
			//document.getElementById("spn"+divNum).style.backgroundImage="url(/images/down_arrow.gif)";
			document.getElementById("spn"+divNum).innerHTML="<img src='" + strPreUrl + "/images/common/up_arrow.gif' border='0'>";
		}
	}
 }
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate

//---------------------------------------------------
function openwindow(url1)
		{
		alert ("inside");
		var newwindow=open("ShowEvents.asp?GetMyDate=2003-06-25","ContactUs","height=450,width=540,scrollbars")
		}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  NewWindow=window.open(theURL,winName,features);
NewWindow.focus()
//NewWindow.location.reload()
}


//--------------------------------------------------------------------------------
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function empty()
{
  // alert("inside the emptyfunc");
   //document.write (document.form1.length);
   for(var i=0;i<document.Events.length;i++)  // To check all the fields
	{
      if  (document.Events[i].value == "") // checking for field is empty
          	{
          	 
          	 if (document.Events[i].name=="txtShortDesc")
          	 {
          	      alert("Please Enter a Short Description");
          		  document.Events.txtShortDesc.focus();	      
          	      return false;
           	 }
          	 
          	 if (document.Events[i].name=="txtDescription")
          	 {
          		
				//alert("Please Enter Details");
          		document.Events.txtDescription.value = document.Events.txtShortDesc.value;		
				//document.Events.txtDescription.focus();
          		//return false;
          	 }
          	 
         	 
         } 
	
    }
					
    return true;
     
 }


function empty1()
{
var j = 0;
//   alert("inside the emptyfunc");
   //document.write (document.form1.length);
   
   for(var i=0;i<document.Remove.length;i++)  // To check all the fields
	{
	
	
      if  (document.Remove[i].type == "checkbox")
			
		{
			if (document.Remove[i].checked==true)
			{
						  j = 1;
			}
	    }	 
	 
	}	
	//alert ("j=" +  j )	 ;
	if ( j == 1)
	{
	 //alert("inside true");
	 var agree = confirm(" Are you sure you want to delete the selected programme(s)");
	if (agree)
	 {
	 return true;
	 }
	 else
	 {
	 return false;
	 }
	 return true;
	 }
	 
	if (j==0)
	 {
	 alert ("Please check the checkbox(es) before Deleting");
	 return false;
	 }
	
 }

 
function CheckAll(chk)
{
for (var i=0;i < document.Remove.elements.length;i++)
	{
		var e = document.Remove.elements[i];
		if (e.type == "checkbox")
		{
			e.checked = chk.checked;
			
		}
	}
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document;
  
   if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    
}

function MM_findObj(n, d) { //v4.01
  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&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
