
window.onload = function(){
	FixBackground();
	NavShadows();
}

function FixBackground(){
	var bg = document.getElementsByTagName("form")[0];
	var container = document.getElementById("container");
	var arrayPageSize = getPageSize();
	
	var height = Max(bg.clientHeight, container.clientHeight, arrayPageSize[1]);
	
	bg.style.height = height + "px";
	container.style.height = height + "px";
	
}

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function Max(a,b,c){
	if(a > b){
		if(a > c) return a;
		else return c;
	}else{
		if(b > c) return b;
		else return c;
	}
}


function NavShadows(){
	
	var shadow = 0;
	var navigation = document.getElementById("navigation");
	
	var list = navigation.getElementsByTagName("li");

	for(j = 0; j < list.length; j++)
	{
		var element = list[j];
		for(i = 0; i < element.className.split(' ').length; i++){
			if(element.className.split(' ')[i] == "current" && !shadow) {
			
				//create shadows in nav
				var topShadow = document.createElement("div");
				var bottomShadow = document.createElement("div");
						
				topShadow.className = "shadow-top";
				bottomShadow.className = "shadow-bottom";
			
				//define positions of shadows			
				topShadow.style.top = (element.offsetTop - 38) + "px";
				bottomShadow.style.top = (element.offsetTop + element.clientHeight) + "px";
						
				navigation.appendChild(topShadow);
				navigation.appendChild(bottomShadow);
			
				//make shadows visible
				topShadow.style.display = "block";
				bottomShadow.style.display = "block";
				
				shadow = 1;
							
			}
		}
	}
}

//UL2Select script
function ul2select(hid, sel, foo){
  var select=document.createElement('select');
  var holder = document.getElementById(hid);
  var ul = holder.getElementsByTagName('ul')[0];
  var az = ul.getElementsByTagName('A');
  if ( az.length > 0 )
  {
	  var createOption = function (a) {
	    	var opt = document.createElement('option');
		opt.innerHTML = a.innerHTML;
		opt.value = a.href;
		opt.selected = a.id == sel ? "selected" : "";
		return opt;
	  }

	  select.onchange = function(){
	    if(this.options[this.selectedIndex].value != false) 
	      location.href = this.options[this.selectedIndex].value
	  };

	  var deft = {innerHTML:foo, href:0, id:"x0"};
	  select.appendChild(createOption(deft));

	  for (var i = 0;it = az[i];i++){
		select.appendChild(createOption(it));
	  }
	  holder.removeChild(ul);
	  holder.appendChild(select);
 }
}
//end Ul2Select

function ShowServices(element){
	var services = document.getElementById("services");
	
	if(element.className == "up"){
		element.className = "down";
		services.style.display = "none";
	}else{
		element.className = "up";
		services.style.display = "block";
	}
	
}

function ul_select(hid){
  var list = document.getElementById(hid).getElementsByTagName('ul')[0];
  var link =  document.getElementById(hid).getElementsByTagName('a')[0];
  
  	link.onclick = function(){ 
		list.style.display = 'block';
	}
  
  	list.onmouseover = function(){
		list.style.display = 'block';
	}
  
	list.onmouseout = function(){
		this.style.display = 'none';
	}
  
}









