// JavaScript Document

//SuckerTree Horizontal Menu (Sept 14th, 06)

var menuids=["treemenu1"] //Enter id(s) of SuckerTree UL menus, separated by commas

function buildsubmenus_horizontal(){
for (var i=0; i<menuids.length; i++){
  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
		if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu
			ultags[t].style.top=ultags[t].parentNode.offsetHeight+"px" //dynamically position first level submenus to be height of main menu item
			ultags[t].parentNode.getElementsByTagName("a")[0].className="mainfoldericon"
		}
		else{ //else if this is a sub level menu (ul)
		  ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
    	ultags[t].parentNode.getElementsByTagName("a")[0].className="subfoldericon"
		}
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.visibility="visible"
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.visibility="hidden"
    }
    }
  }
}

if (window.addEventListener)
window.addEventListener("load", buildsubmenus_horizontal, false)
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus_horizontal)

function hideAllNormal() {
	// For web
	$("#dd_web").hide(1000);
	$(".web").slideDown(1000);	
	
	// For application development 
	$("#dd_desk_app").hide(1000);
	$(".desk_app").slideDown(1000);	
	
	// For business solutions
	$("#dd_solutions").hide(1000);
	$(".solutions").slideDown(1000);	
	
	// For consaltancy
	$("#dd_consalt").hide(1000);
	$(".consalt").slideDown(1000);	
	
	// For design
	$("#dd_design").hide(1000);
	$(".design").slideDown(1000);	
	
	return true;
}

function showBySelectorNormal(block) {
	hideAllNormal();
	$("."+block).hide(1000); 
	$("#dd_"+block).slideDown(1000);
	
	return true;
}

function hideAllIE() {
	// For web
	$("#dd_web").hide();
	$(".web").fadeIn(1);	
	
	// For application development 
	$("#dd_desk_app").hide();
	$(".desk_app").fadeIn(1);	
	
	// For business solutions
	$("#dd_solutions").hide();
	$(".solutions").fadeIn(1);	
	
	// For consaltancy
	$("#dd_consalt").hide();
	$(".consalt").fadeIn(1);	
	
	// For design
	$("#dd_design").hide();
	$(".design").fadeIn(1);	
	
	return true;
}

function showBySelectorIE(block) {
	hideAllIE();
	$("."+block).hide(); 
	$("#dd_"+block).fadeIn(1);
	
	return true;
}

function showBySelector(block) {
	if ((navigator.userAgent.indexOf('MSIE') && navigator.userAgent.indexOf('6.0')) > -1) {
		showBySelectorIE(block);
	} else {
		showBySelectorNormal(block);
	}
	
	return true;
}

function hideAll() {
	if ((navigator.userAgent.indexOf('MSIE') && navigator.userAgent.indexOf('6.0')) > -1) {
		hideAllIE();
	} else {
		hideAllNormal();
	}
	
	return true;
}


function toggleList(id) {
    $("#"+id+"_arrow").toggleClass('arrow'); 
    $("#"+id+"_arrow").toggleClass('arrow_down'); 
    if ($("#"+id).css('display') == 'none') {
        $("#"+id).fadeIn(1000); 
    } else {
        $("#"+id).fadeOut(1000);
    }
}


function checkAndSubmit() {
    if ($(".in_search").val().length >= 3) {
	this.form.submit();
    } else {
	alert('Form should contain at least 3 characters to search.');
    }
}
