/*

Author: REDTRAY
Version 1.0 Created: 20.11.2006]
File Discription: This is general/common javascript code used by all or many web pages

Modification History:
1) 05.05.2007 @ 10:00 am - by Jitendra Madhav (added search functionality)
2) 07.05.2007 @ 11:25 am - by Jitendra Madhav (added comment for loadHomePage function)


*/

function remove_focus(obj){
	eval(obj).blur();
}

function do_search(){
	var url="http://www.google.co.uk/search?q="+document.forms[0].search_string.value+" site%3Awww.redtray.co.uk&submit=Google+Search";
	//window.open(url,"","");
	window.location.href=url;
}

// Function to control the expansion and collapse of the text 
function expand(lyr){
	var obj_style=document.getElementById(lyr).style;
	if ((obj_style.display=="block") || (obj_style.display=="")){
		obj_style.display="none";
		//if(navigator.appName=="Netscape"){
			document.getElementById(lyr).style.visibility="hidden";
			document.getElementById(lyr).style.height="0px";
		//}
	}else{
		obj_style.display="block";
		if(navigator.appName=="Netscape"){
			document.getElementById(lyr).style.visibility="visible";
			document.getElementById(lyr).style.height="710px";
		}else{
			document.getElementById(lyr).style.visibility="visible";
			document.getElementById(lyr).style.height="100%";
		}
	}
}

// Function to control the left menu open/close settings page-wise
function loadHomePage(getMenuNo){
//	alert(getMenuNo);
	/*if(getMenuNo==4){
		getMenuNo=1;
	}*/
	url_id="default.htm";
	window.location=url_id+"?id="+getMenuNo;
}
	if(location.search.length>0) 
	{
			leftmenu_expend_index = location.search.substring(location.search.indexOf('=')+1);	
			if(leftmenu_expend_index>=1 && leftmenu_expend_index<=4)
			{
			}
			else
			{
				leftmenu_expend_index=1;
				expend_no=leftmenu_expend_index;
			}
	}
	else
	{
			leftmenu_expend_index=1;
			expend_no=leftmenu_expend_index;
	}

function loadPage(url, interest){
	url_id=url;
	window.location=url_id+"?id="+expend_no;
}

/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.redtray.com)
***********************************************/

//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="clients.htm">Client List</a><br/>'
menu1[1]='<a href="case_studies.htm">Case Studies</a><br /><img src="images/menu_last_op_bg.gif" align="bottom">'


//Contents for menu 2, and so on
var menu2=new Array()
menu2[0]='<a href="clients_benifit.htm">CLIENT BENEFITS</a><br/>'
menu2[1]='<a href="clientAreaLogin.htm">LOGIN</a><br /><img src="images/menu_last_op_bg.gif" align="bottom">'

var menu3=new Array()
menu3[0]='<a href="quickreference_quide.htm">Quick Reference Guides</a><br />'
menu3[1]='<a href="insight.htm">Insight</a><br />'
menu3[2]='<a href="resources.htm">Links</a><br /><img src="images/menu_last_op_bg.gif" align="bottom">'
		
var menuwidth='165px' //default menu width
var menubgcolor='images/bgcolorred.gif'  //menu bgcolor
var disappeardelay=300  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="menu_bg" style="visibility:hidden; z-index:20;" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"><div id="dropmenudiv"></div></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}
function showhide(obj, e, visible, hidden, menuwidth, menuheight){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
dropmenuobj.widthobj.height=menuheight
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth, menuheight){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("menu_bg") : menu_bg
populatemenu(menucontents)
if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth, menuheight)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="no")
document.onclick=hidemenu






var isCSS, isW3C, isIE4, isNN4;
// initialize upon load to let all browsers establish content objects
function initDHTMLAPI() {
    if (document.images) {
        isCSS = (document.body && document.body.style) ? true : false;
        isW3C = (isCSS && document.getElementById) ? true : false;
        isIE4 = (isCSS && document.all) ? true : false;
        isNN4 = (document.layers) ? true : false;
        isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
		//alert(" isCSS "+isCSS+"\r isW3C "+isW3C+"\r isIE4 "+isIE4+"\r isNN4 "+isNN4+"\r isIE6CSS "+isIE6CSS);
    }
}


/***********************************************
* (www.redtray.com)
***********************************************/