function setupRollovers() {
  if (!document.getElementsByTagName)
    return;
  var all_links = document.getElementsByTagName('a');
  for (var i = 0; i < all_links.length; i++) {
    var link = all_links[i]; 
    if (link.className &&
        (' ' + link.className + ' ').indexOf(' rollover ') != -1) {
      if (link.childNodes &&
          link.childNodes.length == 1 &&
          link.childNodes[0].nodeName.toLowerCase() == 'img') {
        link.onmouseover = mouseover;
        link.onmouseout = mouseout;
      }
    }
  }
}

function find_target(e)
{
  /* Begin the DOM events part, which you */
  /* can ignore for now if it's confusing */
  var target; 

  if (window.event && window.event.srcElement) 
    target = window.event.srcElement;
  else if (e && e.target)
    target = e.target;
  if (!target)
    return null;

  while (target != document.body &&
      target.nodeName.toLowerCase() != 'a')
    target = target.parentNode;

  if (target.nodeName.toLowerCase() != 'a')
    return null;

  return target;
}

function mouseover(e) {
	
  var target = find_target(e);
  
  if (!target) return;

  // the only child node of the a tag in target will be an img tag
  var img_tag = target.childNodes[0];

  // Take the "src", which names an image called "something.ext",
  // Make it point to "something_over.ext"
  // This is done with a regular expression
  //reset the OVER img if its there 
  img_tag.src = img_tag.src.replace(/-OVER(\.[^.]+)$/, '$1');
  
  // reaply the img
  img_tag.src = img_tag.src.replace(/(\.[^.]+)$/, '-OVER$1');
}

function mouseout(e) {
  var target = find_target(e);
  if (!target) return;

  // the only child node of the A-tag in |target| will be an IMG-tag
  var img_tag = target.childNodes[0];

  // Take the "src", which names an image as "something_over.ext",
  // Make it point to "something.ext"
  // This is done with a regular expression
  img_tag.src = img_tag.src.replace(/-OVER(\.[^.]+)$/, '$1');
}

/*Realod the Project screen after 5 seconds */




function ReloadProjectAjax(divId,url,showpaging,TypeProject,pid){
	//clearTimeout(Projtimer);
	if (!document.getElementById) return false;
	if (!document.getElementById("ProjectPortfolioAJX")) return false;
	

	var dNow = new Date();
	var tNow = dNow.getTime();

	if(divId == null && url == null){
		
		divId = 'ProjectPortfolioAJX';
		
	};
	
	
	switch(TypeProject) {
		case 1:
			url = "include/display-projects.asp"
			break;
		case 2:
			url = "include/project-portfolio.asp"
			break;
		};
		/*if(pid == null){
			pid = '0'};*/
			
		if(showpaging){
			url = url + '?t=' + tNow + '&pid=' + pid;
		}else{
			url =  url + '?p=0&t=' + tNow + '&pid=' + pid;
		};
		
		//alert(url)
		
		
	ajax_loadContent(divId,url);
	
	//Projtimer = setTimeout('ReloadProjectAjax("' + divId + '","' + url + '",' + showpaging + ',' + TypeProject + ',"' + pid + '")',1000);
};

function RolloverSubmit(){
	if (!document.getElementById) return false;
	if (!document.getElementById("FrmSubmit")) return false;
	var Button = document.getElementById("FrmSubmit");
	
		Button.onmouseover = ButtonRollover;
        Button.onmouseout = ButtonRollout;
	
	
	};
	
function ButtonRollover(){
	
	 this.src = this.src.replace(/-OVER(\.[^.]+)$/, '$1');
  
	  // reaply the img
	  this.src = this.src.replace(/(\.[^.]+)$/, '-OVER$1');
	}


	function ButtonRollout(){
	
	 this.src = this.src.replace(/-OVER(\.[^.]+)$/, '$1');
	}
addLoadEvent(function() {
	//PrepareMenu();
	loadGallery();
	
});	

addLoadEvent(function() {
	//PrepareMenu();
	
	setupRollovers();
	
	
});

addLoadEvent(function() {
	//PrepareMenu();
	RolloverSubmit()
	
});

addLoadEvent(function() {
	TB_init()
	
});