
function setSearchBox(searchType) {
	// clear both 'selected' states
	$('people').className = "";
	$('organizations').className = "";
	
	// set the new searchType as the current selected tab
	var theTab = $(searchType);
	theTab.className = "selected";
	theTab.blur(); // removes that tacky outline on focused links...
	
	// set the hidden input field to hold the new searchType value
	document.search.type.value = searchType;
}

function changeBackgroundImage(index){
document.getElementById(_listItemArray[index][0]).style.background =  _listItemArray[index][2];
document.getElementById("_searchInputTypeHidden").value = _listItemArray[index][3];
for(ii=0; ii <_listItemArray.length;ii++){
if(ii!=index){
document.getElementById(_listItemArray[ii][0]).style.background =  _listItemArray[ii][1];
document.getElementById(_listItemArray[ii][0]).style.backgroundPosition = "bottom right"
}
}

}

function openPopup(pageloc) {


   w = screen.availWidth;
   h = screen.availHeight;


var popW = 430, popH = 250;

var leftPos = (w-popW)/2, topPos = (h-popH)/2;

	PopWin=window.open(pageloc,'PopWin','height='+popH+',width='+popW+',top='+topPos+',left='+leftPos+',scrollbars=no,resizable=no');
	PopWin.focus();
	}
	
function openBugReportPopup(){
		document.getElementById('sideNavigation_inc:SendToFrndDiv').style.visibility="hidden";		
		document.getElementById('sideNavigation_inc:BugReprtDiv').style.visibility="visible";
		document.getElementById('sideNavigation_inc:formBug:TfBugText').value="";
		return false;
	}	
	
	var isMozilla;
	var objDiv = null;
	var originalDivHTML = "";
	var DivID = "";
	var over = false;

//
// dinamically add a div to 
// dim all the page
//
function buildDimmerDiv()
{
	 if (isMozilla) {
		width=92;	
		height=100;				
		document.write('<div id="dimmer" class="dimmer" style="background-image:url(gray.png);width:'+width + '%; height:' + height +'%;z-index:100;_background-image:none;_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale src=gray.png);"></div>');
	}
	else{	
		width=100;
		height=100;
		document.write('<div id="dimmer" class="dimmer" style="background-image:url(gray.png);width:'+width + '%; height:' + height +'%;z-index:100;_background-image:none;_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale src=gray.png);"></div>');		
	}
	
	
    
  	
}

	
 function displayWindow()
    {
        var w, h, l, t;
        w = 500;
        h = 250;
        l = screen.width/4;
        t = screen.height/4;
              
              // no title		        
        // displayFloatingDiv('windowcontent', '', w, h, l, t);

              // with title		        
        displayFloatingDiv('sideNavigation_inc:BugReprtDiv', 'Comments and suggestion', w, h, l, t);
        return false;
}	

function displayFloatingDiv(divId, title, width, height, left, top) 
{
	DivID = divId;

	document.getElementById('dimmer').style.visibility = "visible";		
    document.getElementById(divId).style.width = width + 'px';
    document.getElementById(divId).style.height = height + 'px';
    document.getElementById(divId).style.left = left + 'px';
    document.getElementById(divId).style.top = top + 'px';
	
	var addHeader;
	
	if (originalDivHTML == "")
	    originalDivHTML = document.getElementById(divId).innerHTML;
	
	addHeader = '<table style="width:' + width + 'px" class="floatingHeader">' +
	            '<tr><td ondblclick="void(0);" onmouseover="over=true;" onmouseout="over=false;" style="cursor:move;height:18px;" class="infoMessage">' + title + '</td>' + 
	            '<td style="width:18px" align="right"><a href="javascript:hiddenFloatingDiv(\'' + divId + '\');void(0);">' + 
	            '<img alt="Close..." title="Close..." src="images/close.jpg" border="0"></a></td></tr></table>';
	

    // add to your div an header	
	document.getElementById(divId).innerHTML = addHeader + originalDivHTML;
	
	
	document.getElementById(divId).className = 'dimming';
	document.getElementById(divId).style.visibility = "visible";


}
function hiddenFloatingDiv(divId) 
{
	document.getElementById(divId).innerHTML = originalDivHTML;
	document.getElementById(divId).style.visibility='hidden';
	document.getElementById('dimmer').style.visibility = 'hidden';
	
	DivID = "";
}
function MouseDown(e) 
{
    if (over)
    {
        if (isMozilla) {
            objDiv = document.getElementById(DivID);
            X = e.layerX;
            Y = e.layerY;
            return false;
        }
        else {
            objDiv = document.getElementById(DivID);
            objDiv = objDiv.style;
            X = event.offsetX;
            Y = event.offsetY;
        }
    }
}


//
//
//
function MouseMove(e) 
{
    if (objDiv) {
        if (isMozilla) {
            objDiv.style.top = (e.pageY-Y) + 'px';
            objDiv.style.left = (e.pageX-X) + 'px';
            return false;
        }
        else 
        {
            objDiv.pixelLeft = event.clientX-X + document.body.scrollLeft;
            objDiv.pixelTop = event.clientY-Y + document.body.scrollTop;
            return false;
        }
    }
}

//
//
//
function MouseUp() 
{
    objDiv = null;
}


//
//
//
function init()
{
    // check browser
    isMozilla = (document.all) ? 0 : 1;


    if (isMozilla) 
    {
        document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
    }

    document.onmousedown = MouseDown;
    document.onmousemove = MouseMove;
    document.onmouseup = MouseUp;

    // add the div
    // used to dim the page
	buildDimmerDiv();

}

// call init
 
function openSendToFriendPopup(){
		document.getElementById('SendToFrndDiv').style.visibility="visible";
		document.getElementById('OtMailFrom').value="";
		document.getElementById('inputMailTo').value="";
		document.getElementById('TfMailText').value="";		
		var confirmTrue=document.getElementById("mailConfirmNot");
		if(confirmTrue!=null){		
			confirmTrue.style.display="none";
		} 
		var confirmFalse=document.getElementById("mailConfirm");
		if(confirmFalse!=null){
			confirmFalse.style.display="none"
		}				
		return false;
	}
function populateSchools(country,state,SchoolDropDown){
    var common = new Common();
  	var url = "getSchools?country="+country+"&state="+state;
   try
	 {
       var objXml = common.CreateXmlHttpRequest();
        objXml.open("get", url, true);
        objXml.onreadystatechange = function(){
            if(objXml.readyState == 4)
            {
                if(objXml.status == 200)
                {
                    var schools = objXml.responseXML.getElementsByTagName("school");
         			SchoolDropDown.length = 0
         			SchoolDropDown.options.add(new Option("select a school...",""))
         			for(var ii=0; ii<schools.length; ii++){
         			var schoolName = schools[ii].firstChild.data
         				SchoolDropDown.options.add(new Option(schoolName,schoolName))
         			}
         			SchoolDropDown.options.add(new Option("Other...","Other"))
                }
            }
        };
        
        objXml.send(null);

    }   
    catch(Error)
   {
        alert(Error);
    }
 }	
