
/* Start of drop down functions */
/*------------------------------*/
var IE = document.all?true:false

// Temporary variables to hold mouse x-y pos.s
var mouseX = 0
var mouseY = 0
var e = new Object();

function dropdown_show(buttonid) {
	document.getElementById(buttonid + '_dropdown').style.visibility='visible';
	bringToFront(buttonid + '_dropdown');
	document.getElementById(buttonid + '_dropdown').style.left=(document.getElementById(buttonid).offsetLeft-1)+'px';
	document.getElementById(buttonid + '_dropdown').style.top=document.getElementById(buttonid).offsetTop+'px';
}
function dropdown_hide(divid,button,e) {
	if (IE) { // grab the x-y pos.s if browser is IE
		mouseX = event.clientX + document.documentElement.scrollLeft;
		mouseY = event.clientY + document.documentElement.scrollTop;
	} else { // grab the x-y pos.s if browser is NS
		mouseX = e.pageX;
		mouseY = e.pageY;
	}
	var error = 4;
	var divHeight = parseFloat(document.getElementById(divid).clientHeight);
	var divTop = parseFloat(document.getElementById(divid).style.top);
	var divWidth = parseFloat(document.getElementById(divid).clientWidth);
	var divLeft = parseFloat(document.getElementById(divid).style.left);
	if ((divTop + error >= mouseY) || (divTop + divHeight - error <= mouseY) || (divLeft + error >= mouseX) || (divLeft + divWidth - error <= mouseX)) {
			document.getElementById(divid).style.visibility='hidden';
	}
}

function getAbsoluteDivs()   
{   
    var arr = new Array();   
    var all_divs = document.body.getElementsByTagName("DIV");   
    var j = 0;   
  
    for (i = 0; i < all_divs.length; i++)   
        if (all_divs.item(i).style.position=='absolute')   
        {   
            arr[j] = all_divs.item(i);   
            j++;   
        }   
  
    return arr;   
}   
  
function bringToFront(id)   
{   
    if (!document.getElementById ||   
        !document.getElementsByTagName)   
        return;   
  
    var obj = document.getElementById(id);   
    var divs = getAbsoluteDivs();   
    var max_index = 0;   
    var cur_index;   
  
    // Compute the maximal z-index of   
    // other absolute-positioned divs   
    for (i = 0; i < divs.length; i++)   
    {   
        var item = divs[i];   
        if (item == obj ||   
            item.style.zIndex == '')   
            continue;   
  
        cur_index = parseInt(item.style.zIndex);   
        if (max_index < cur_index)   
        {   
            max_index = cur_index;   
        }   
    }   
  
    obj.style.zIndex = max_index + 1;   
}   

/*------------------------------*/
/* End of Drop Down Functions */


//ajax functions
// Get the HTTP Object
function getHTTPObject(){
	if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest) return new XMLHttpRequest();
	else {
		alert("Your browser does not support AJAX, please update your browser.");
		return null;
	}
}   
					   
// Change the value of the outputText field
function setOutput(){
	if(httpObject.readyState == 4){
		document.getElementById('ratesupdate').innerHTML = httpObject.responseText;
	}
}

// Implement business logic
function ajax_function(params){
	httpObject = getHTTPObject();
	if (httpObject != null) {
		httpObject.open("POST", "inc/ajax.php", true);
		httpObject.onreadystatechange = setOutput;
		
		// Set our POST header correctly…
		httpObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		httpObject.setRequestHeader("Content-length", params.length);
		httpObject.setRequestHeader("Connection", "close");
		
		// Send the parms data…
		httpObject.send(params);

		}
	}
//end of ajax functions
var menu = "";
var amount = "";
function move_menu(direction,menu){
	if (direction=='left'){
		amount=-3;
	} else {
		amount=3;
	}
	menuname=menu;
	myInterval = window.setInterval('tick_move()',1);
}
function tick_move(){
	menuleft = amount;
	menu=menuname;
	document.getElementById(menu).scrollLeft += menuleft;
}

