function toggleLayer( whichLayer ) {
	var elem, vis;
	elem = document.getElementById( whichLayer );
	vis = elem.style;

	if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
	
	vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
	vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function relatedsiterollover(name, filename) {
  var fullpath = 'http://www.layeredtech.com/_img/graphics/footer/' + filename;
  document.images[name].src = fullpath;
}

function graphicsrollover(name, filename) {
  var fullpath = 'http://www.layeredtech.com/_img/graphics/' + filename;
  document.images[name].src = fullpath;
}

/* SEARCH BAR */
function searchGoogle() {
	var searchquery = document.searchbar.userq.value;
	window.location = "http://www.google.com/search?hl=en&q=" + searchquery + "&as_epq=&as_oq=&as_eq=&num=10&lr=&as_filetype=&ft=i&as_sitesearch=layeredtech.com&as_qdr=all&as_rights=&as_occt=any&cr=&as_nlo=&as_nhi=&safe=off";
}


////Jquery Modal Window
// production: $(document).ready(function() {
jQuery(function ($) {	

	//select all the a tag with name equal to modal
	$('a[name=modal]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		
		//Get the A tag
		var id = $(this).attr('href');
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(2000); 
	
	});
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});			
	
});
var timer1 = 500;
var closeMenu = 0;
var ddmenuitem = 0;
function showMenu(id) {	
	stoptimer();
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';
}

function hideMenu() {
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

function closetimer() {
	closeMenu = window.setTimeout(hideMenu, timer1);
}

function stoptimer() {
	if(closeMenu)
	{
		window.clearTimeout(closeMenu);
		closeMenu = null;
	}
}
function rollover(name, filename) {
  var fullpath = 'http://www.layeredtech.com/_img/graphics/navBar/' + filename;
  document.images[name].src = fullpath;
}

document.onclick = hideMenu;

function NewWin(page,name,width,height,sb){
        var scrollbars = 'yes';
        if(sb == false) {
            scrollbars = 'no';
        }
        var OpenWin = window.open(page,name,'toolbar=no,menubar=no,location=no,scrollbars'+scrollbars+',width='+width+',height='+height+',resizable=yes,status=no');
        OpenWin.focus();
}
function sharelink(p,t) {
    NewWin('/lp/share.php?p=' + p + '&t=' + t, 'sharewindow', 330, 420, false);
}
