function search(url){
var txtBox = document.getElementById("Search");
location.href= url + "?q=" + txtBox.value;
}

function searchPerson(url){
var txt = url + "?searchText=" + document.getElementById("Find").value;
window.open(txt,"edir");
}
function cswmButtonSunken(id){
return false;
}

NS4 = (document.layers) ? true : false;

function checkEnter(event,type,url)
{ 	
	var code = 0;
	
	if (NS4)
		code = event.which;
	else
		code = event.keyCode;
	if (code==13)
		{
		
		if(type == "searchPerson")searchPerson(url);
		if(type == "search")search(url);
		
		}
		
}

function clickHandler(url) {
	link = eval(url).href;
	// check the current sitename
	DocURL = document.URL;
	protocolIndex=DocURL.indexOf("://",4);
	serverIndex=DocURL.indexOf("/",protocolIndex + 3);
	BeginURL=DocURL.indexOf("#",1) + 1;
	urlresult=DocURL.substring(BeginURL,serverIndex);
	displayresult=DocURL.substring(protocolIndex + 3 ,serverIndex);
	//alert(displayresult);
	
	// check the passed in url
	protocolIndex1=link.indexOf("://",4);
	serverIndex1=link.indexOf("/",protocolIndex1 + 3);
	BeginURL1=link.indexOf("#",1) + 1;
	urlresult1=link.substring(BeginURL1,serverIndex1);
	displayresult1=link.substring(protocolIndex1 + 3 ,serverIndex1);
	
	
	// compare both the servernames, if they are equal then it is internal link else outside link
	if (displayresult == displayresult1){
		var containspdf = link.indexOf(".pdf");
		var containsword = link.indexOf(".doc");
		
		if(containspdf != -1){
			newwin = window.open(link,"","width=500,height=400,resizable=yes");
			return false;
		}else if(containsword != -1){
			newwin = window.open(link,"","width=500,height=400,resizable=yes");
			return false;
		}else{
		
			return true;
		}
	}else {
		if((link.indexOf("mailto:") == -1) && (link.indexOf("novelis.com") == -1) && (link.indexOf("insidenovelis.com") == -1)) {
				//var redirecturl = outsidelinksurl + "?" + link ;
				var redirecturl =  link ;
				
				newwin = window.open(redirecturl,"","width=750,height=400,Toolbar=yes,scrollbars=yes,location=yes,resizable=yes");
				return false;
		}else{
				return true;
		}
	}
}
function swap(imageobj, imgurl, state){
	
	if(state == 0){
		document.images[imageobj].src =  imgurl + "_over.gif"
	}
	else if(state == 1){
		document.images[imageobj].src =  imgurl + ".gif"
	}
	else if(state == 2){
		document.images[imageobj].src =  imgurl + "_selected.gif"
	}
	else{
		document.images[imageobj].src =  imgurl + ".gif"
		
	}
}

function ToggleDisplay(id)
  {
    var elem = document.getElementById('d' + id);
    if (elem) 
    {
      if (elem.style.display != 'block') 
      {
        elem.style.display = 'block';
        elem.style.visibility = 'visible';
      } 
      else
      {
        elem.style.display = 'none';
        elem.style.visibility = 'hidden';
      }
    }
  }

