ip$.handlers = [
 function(){
  ip$.assignFirstChild("UL","LI");
  ip$.assignLastChild("UL","LI");
  ip$.externalLinks();
  autoClear();
  tabHandler("BriefGBS");
  tabHandler("BriefGComm");
  tabHandler("BriefCE");
  tabHandler("News");
  tabHandler("Gallery");
  tabHandler("InnerNews");
  galleryScroll("Thumbs");
  showHide();
  EventsShowHide();
  mediaGallery();
  dropDown();
  mediaTabHandler();
  imageRollOver(ip$.getID("Navigation1"),"LI");
  if(ip$.browser.msie && ip$.browser.version == "6.0") document.execCommand("BackgroundImageCache",false,true);
  goBack();
  pageTop();
  quickLinks();
  //function()
  //{ 
  // try {document.execCommand("BackgroundImageCache", false, true);} catch(e){};
  //};
 }
];

//----------------------------------------------------------------
// Function to auto clear the text fields
//----------------------------------------------------------------

function autoClear(){
	var clears = ip$.getClass(document,"AutoClear");
	ip$.temp = [];
	ip$.each(clears,function(i,el){
		ip$.temp.push(el.value);
		el.onclick = function(){
		 if(this.value == ip$.temp[i]){
			 this.value = "";
			 this.style.background = "#ffffff";
			 this.style.color = "#666666";
		 };
		}
		el.onblur = function(){
			if(this.value == "") this.value = ip$.temp[i];
		}
	});
}

//----------------------------------------------------------------
// Function to change Tabs
//----------------------------------------------------------------

function tabHandler(block){
	var tab = ip$.getClass(document,block)[0];
	if(!tab) return;
	var tabs = ip$.getTags(tab,"A");
	
	var checkNewsEvent = ip$.getClass(tab,"NewsEvents")[0];
	var parentLIs = ip$.getTags(checkNewsEvent,"LI",true);
	if(!parentLIs) return;

	if(ip$.getTags(parentLIs[0],"LI").length < 1){
	 parentLIs[0].style.display = "none"; 
	 ip$.addClass(parentLIs[1],"Active");
	 //parentLIs[1].onclick = function(){return false};
	 return;
	}
	if(ip$.getTags(parentLIs[1],"LI").length < 1){
	 parentLIs[1].style.display = "none"; 
	 //parentLIs[0].onclick = function(){return false};
	 return;
	}	 
	
	ip$.each(tabs,function(i,el){
		el.onclick = function(){
			if(this.parentNode.parentNode.className!="NewsEvents")
			return true;
			resetActiveClass();
			ip$.addClass(this.parentNode,"Active");
			if(this.innerHTML == "UPCOMING EVENTS" && ip$.getClass(tab,"ViewAll")[0]){
			 var viewAll = ip$.getClass(tab,"ViewAll")[0];
			 viewAll.style.display = "none";
			 checkNewsEvent.style.paddingBottom = "24px";
			}
			if(this.innerHTML == "LATEST NEWS" && ip$.getClass(tab,"ViewAll")[0]){
			 ip$.getClass(tab,"ViewAll")[0].style.display = "block";
			 checkNewsEvent.style.paddingBottom = "10px";
			}
   if(this.getAttribute("rel")=="Photos")
   {
			 galleryScroll("Thumbs");
			 ip$.getClass(tab,"MoreVideos")[0].style.display = "none";
			 ip$.getClass(tab,"MorePhotos")[0].style.display = "block";
			}
			if(this.getAttribute("rel")=="Videos")
			{
			 galleryScroll("Thumbs1");
			 ip$.getClass(tab,"MorePhotos")[0].style.display = "none";
			 ip$.getClass(tab,"MoreVideos")[0].style.display = "block";
			}
			return false;
		}
	});
	
	function resetActiveClass(){
		ip$.each(ip$.getClass(tab,"Active"),function(i,el){
		 ip$.removeClass(el,"Active");
		});
	}
}

//----------------------------------------------------------------
// Functions to call scroller functions
//----------------------------------------------------------------

function galleryScroll(ScrollObject)
{
  var thumbs = ip$.getClass(document,ScrollObject)[0];
  var thumbsLength = ip$.getTags(thumbs,"LI");
  if(!thumbsLength) return;
  var thumbHolder = ip$.getTags(thumbs,"UL")[0];
  if(!thumbHolder) return;
  thumbHolder.style.width = (thumbsLength.length * 79)+"px";
  
  var _next = ip$.getClass(document,"Next")[0];
  if(!_next)return;
  
  _next.onclick = function()
  {
   return false;
  }
  _next.onmouseover = function()
  {
   ScrollToRight(ScrollObject);
  }
  _next.onmouseout = function()
  {
   clearInterval(Timer);
  }
  
  var _prev = ip$.getClass(document,"Prev")[0];
  if(!_prev)return;
  _prev.onclick = function()
  {
   return false;
  }
  _prev.onmouseover = function()
  {
   ScrollToLeft(ScrollObject);
  }
  _prev.onmouseout = function()
  {
   clearInterval(Timer);
  }
}

//----------------------------------------------------------------
// Functions to Scroll photos and Videos
//----------------------------------------------------------------

function ScrollToLeft(ScrollObject)
{
	try
	{  
  	Timer = setInterval("ip$.getClass(document,'"+ ScrollObject +"')[0].scrollLeft -= 2", 15);
 }
	catch (ExceptionObject)
	{
	}
}

function ScrollToRight(ScrollObject)
{
	try
	{ 
		Timer = setInterval("ip$.getClass(document,'"+ ScrollObject +"')[0].scrollLeft += 2", 15);
 }
	catch (ExceptionObject)
	{
	}
}

//----------------------------------------------------------------
// Functions for Collapse and Expand
//----------------------------------------------------------------

function showHide()
{
 var mainBlock = ip$.getClass(document,"Collapse")[0]; 
 if(!mainBlock) return;
 var headings = ip$.getTags(mainBlock,"H3",true);
 
 ip$.each(headings,function(i,el){
		 el.onclick = function(){
		  ip$.each(ip$.getTags(mainBlock,"DIV",true),function(i,el){
		   el.style.display = "none";
		   ip$.removeClass(headings[i],"Active");
		  });
		  if(this.getAttribute("ID")=="Search")
		  {
		   ip$.getClass(document,"Search")[0].style.display = "block";
		   this.className = "Active";
		  }
		  if(this.getAttribute("ID")=="ILike")
		  {
		   ip$.getClass(document,"ILike")[0].style.display = "block";
		   this.className = "Active";
		  }
		  if(this.getAttribute("ID")=="Register")
		  {
		   ip$.getClass(document,"Register")[0].style.display = "block";
		   this.className = "Active";
		  }
		  return false;
		 }
		});
}

//----------------------------------------------------------------
// Functions for Events show hide
//----------------------------------------------------------------

function EventsShowHide(){
 var _Events = ip$.getClass(document,"NewsEventList")[0];
 if(!_Events) return;
 
 var As = ip$.getTags(_Events,"A");
 
 for(var i = 0;i<As.length;i++){
   As[i].onclick = function(){
    if(ip$.getTags(_Events,"DIV").length != 0){
     for(var ii = 0;ii<As.length;ii++){
      var activeLIs = ip$.getClass(_Events,"Active")[0];
      if(activeLIs){
        ip$.removeClass(activeLIs,"Active");
       }
      }
      ip$.addClass(this.parentNode.parentNode,"Active");
      //alert(this.parentNode.parentNode.tagName);
      return false;
     };
    }
  }
}

//----------------------------------------------------------------
// Functions for Events show hide
//----------------------------------------------------------------

function mediaGallery(){
 
 var preview = ip$.getClass(document,"Preview")[0];
 var thumbs = ip$.getClass(document,"MediaThumbs")[0];
 
 if(!preview || !thumbs) return;
 
 //thumbs.style.display = "block";
 //preview.style.display = "none";
 
 var anchors = ip$.getTags(thumbs,"A");
 //var img = ip$.getTags(thumbs,"IMG");
 
 ip$.each(anchors,function(i,el){
  el.onclick = function(){
   thumbs.style.display = "none";
   ip$.getTags(preview,"IMG",true)[0].src = el.href;
   preview.style.display = "block";
   return false;
  }
 });
 
 ip$.getClass(preview,"Close")[0].onclick = function(){
  thumbs.style.display = "block";
  preview.style.display = "none";
  ip$.getTags(preview,"IMG",true)[0].src = "";
  return false;
 };
}

//----------------------------------------------------------------
// Functions for Navigation Drop down
//----------------------------------------------------------------

function dropDown(){
	var down = ip$.getClass(document,"Navigation1")[0];
 if(!down) return;
	var LIs = ip$.getTags(down,"LI",true);
	for(var i=0,k=LIs.length;i<k;i++){
	 if(ip$.getTags(LIs[i],"DIV")[0]){
	  LIs[i].onmouseover = function(){
	    //ip$.addClass(this,"Active");
	    ip$.getTags(this,"DIV")[0].style.display = 'block';
	   }
	  LIs[i].onmouseout = function(){
	    //ip$.removeClass(this,"Active");
	    ip$.getTags(this,"DIV")[0].style.display = 'none';
	  }
	 }
	}
}  

//----------------------------------------------------------------
// Functions for Gallery handler
//----------------------------------------------------------------

function mediaTabHandler(){
	var _photos = ip$.getClass(document,"Thumbs")[0];
 if(!_photos) return;
	var _videos = ip$.getClass(document,"Thumbs1")[0];
 if(!_videos) return;
 
 var photoThumbs = ip$.getTags(_photos,"UL");
 var videoThumbs = ip$.getTags(_videos,"UL");
 
 if(photoThumbs.length < 1)
 {
  _photos.parentNode.style.display = "none";
  ip$.addClass(_videos.parentNode,"Active");
  _videos.parentNode.style.marginLeft = "0";
  galleryScroll("Thumbs1"); 
 }
 if(videoThumbs.length < 1)
 {
  _videos.parentNode.style.display = "none";
  ip$.addClass(_photos.parentNode,"Active"); 
  galleryScroll("Thumbs");
 }
 if(photoThumbs.length < 1 && videoThumbs.length < 1)
 {
  ip$.getClass(document,"Gallery")[0].style.display = "none";
 }
}  

//function for Navigation rollover
function imageRollOver(oNode,sTag){
 if(!oNode) return; 
 var tags = ip$.getTags(oNode,sTag);
 ip$.each(tags,function(i,el){
  if(el.className.indexOf("Active") > -1){
   var img = ip$.getTags(el,"IMG")[0];
   img.src = img.src.replace(".gif","Active.gif");
   return;
  }
  ip$.addEvent(el,"mouseover",function(){
   var img = ip$.getTags(el,"IMG")[0];
   if(!img) return;
   if(img.src.indexOf("Active.gif") < 0) 
   img.src = img.src.replace(".gif","Active.gif");
   ip$.addClass(el,"Active");
  });
  ip$.addEvent(el,"mouseout",function(){
   var img = ip$.getTags(el,"IMG")[0];
   if(!img) return;
   if(img.src.indexOf("Active.gif") > -1) 
   img.src = img.src.replace("Active.gif",".gif");
   ip$.removeClass(el,"Active");
  });
 });
}

function goBack()
{
 var _back = ip$.getClass(document,"Back")[0];
 if(!_back) return;
 
 _back.onclick = function()
 {
  history.go(-1);
  return false;
 }
 
}

/// <summary>
/// This function Scrolls the page up.
/// </summary>
function pageTop()
{
 var Top = ip$.getClass(document,"Top");
 for(var i=0;i<Top.length;i++)
 {
 Top[i].onclick = function(){
 window.scrollTo(0,0)
 return false;
 }
 }
}


/// <summary>
/// This function opens a new window for quick links.
/// </summary>
function quickLinks()
{
 var quickLinks = ip$.getClass(document,'QuickLinks')[0];
 if(!quickLinks) return;
  
 quickLinks.onchange = function(){
  if(this.value == '0')
  return; 
  window.open(this.value);
 }
}

/// <summary>
///  This function opens a Maximized popup
/// </summary>
function PopupMax(URL, Width, Height, Scrollable, Resizable)
{
	try
	{
		var PopupMax;
		if ((typeof(Width) == "number") && (typeof(Height) == "number"))
			PopupMax = window.open(URL, "PopupMax", "width = " + Width + ", height = " + Height + ", top = " + ((screen.height - Height) / 2) + ", left = " + ((screen.width - Width) / 2) + ", resizable = " + (Resizable ? "yes" : "no") + ", scrollbars = " + (Scrollable ? "yes" : "no") + ", status = no, menubar = yes");
		else
			PopupMax = window.open(URL, "PopupMax");		
	}
	catch (ExceptionObject)
	{
		alert("Your browser or a piece of software installed on your\ncomputer appears to be blocking popups on this page.\n\nPlease enable popups and refresh this page to continue.");
	}
}
