// JavaScript Document



function add_load_event(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

	
function share(){
	if (!document.getElementById("bookmark_link")) return false;
	var bookmark = document.getElementById("bookmark_link");
		bookmark.onclick=function(){
			var ul = document.getElementById("bookmark").getElementsByTagName("ul")[0];
			ul.style.display = "block";
			/*this.getElementsByTagName('a')[0].style.backgroundColor="#FFAA13";
			var linktous = document.getElementById("link");
			var email = document.getElementById("email");
			linktous.getElementsByTagName('a')[0].style.backgroundColor="#e6e6e6";
			email.getElementsByTagName('a')[0].style.backgroundColor="#e6e6e6";*/
			var linktous = document.getElementById("link");
			var dl = linktous.getElementsByTagName("dl")[0];
			dl.style.display = "none";
			var email = document.getElementById("email_to_friend");
			//var email_dl = email.getElementsByTagName("dl")[0];
			email.style.display = "none";
			return false;
		}
		
		var linktous = document.getElementById("link_to_us_link");
		
		linktous.onclick = function(){
			var linktous = document.getElementById("link");
			var dl = linktous.getElementsByTagName("dl")[0];
			
			dl.style.display = "block";
			
			var bookmark = document.getElementById("bookmark");
			
			var ul = bookmark.getElementsByTagName("ul")[0];
			ul.style.display = "none";
			var email = document.getElementById("email_to_friend");
			//var email_dl = email.getElementsByTagName("dl")[0];
			email.style.display = "none";
			
			return false;
			
		}
		
		var email = document.getElementById("email_link");
		email.onclick=function(){
			var email = document.getElementById("email_to_friend");
			//var email_dl = email.getElementsByTagName("dl")[0];
			email.style.display = "block";
			var linktous = document.getElementById("link");
			var dl = linktous.getElementsByTagName("dl")[0];
			dl.style.display = "none";
			var bookmark = document.getElementById("bookmark");
			var ul = bookmark.getElementsByTagName("ul")[0];
			ul.style.display = "none";
			return false;
			
		}
		
		var printpage = document.getElementById("print_link");
		printpage.onclick=function(){
			window.print();
			return false;
		}
		
		var myform= document.getElementById("email_to_friend");
		var button = myform.getElementsByTagName("button")[0];
		button.onclick = function(){
			var myform= document.getElementById("email_to_friend");
			 myform.submit();
		}
		
	
}
add_load_event(share);


/****************************** Secondary Drop Down Menu ********************/
function showDropDown(){
	$(this).find('ul').show();
}

function hideDropDown(){
	//alert("hello");
	$(this).find('ul').hide();
}

function initDropDown(){
	$('ul#primary_navigation li ul').hide();
	
	$('ul#primary_navigation > li').mouseover(showDropDown);
	$('ul#primary_navigation > li').mouseout(hideDropDown);
}

add_load_event(initDropDown);

/****************************** weblaunch.co.uk ********************/
$(function() {

	$(".WLpopUp").click(function() {
		loadPopUp($(this).attr('href'));
		return false;
	});
	
	$("#WLbackgroundPopUp").click(function() {
		unloadPopUp();
	});
	
	$("#WLpopUp").click(function() {
		unloadPopUp();
	});
}
);

// Testimonials

function loadPopUp(src) {
	//alert(src);
	$("#WLpopUp").attr('src',src);
	$("#WLbackgroundPopUp").css({  "opacity": "0.7"  });
	$("#WLbackgroundPopUp").fadeIn("fast");
	$("#WLpopUp").fadeIn("slow");
	centrePopUp();
}

function centrePopUp() {
	//request data for centering  
	var windowWidth = document.documentElement.clientWidth;  
	var windowHeight = document.documentElement.clientHeight;  
	var popupHeight = $("#WLpopUp").height();  
	var popupWidth = $("#WLpopUp").width();  
	//centering  
	$("#WLpopUp").css({ 
		"top": windowHeight/2-popupHeight/2,  
		"left": windowWidth/2-popupWidth/2  
	});  
	//only need force for IE6  
	  
	$("#WLbackgroundPopUp").css({  
	"height": windowHeight  
});  
}

function unloadPopUp() {

	$("#WLbackgroundPopUp").fadeOut("fast");
	$("#WLpopUp").fadeOut("fast");

}