

function popup (url, name, width, height, scrollbars)
{
	left_pos = (screen.width / 2) - (width / 2);
	top_pos = (screen.height / 2) - (height / 2);

	window.open(url, name, 'resizable=1,scrollbars='+scrollbars+',status=no,toolbar=no,menubar=no,width=' + width + ',height=' + height + ',left=' + left_pos + ',top=' + top_pos);	
	return false;
}


function externalLinks()
{
	$$('a').each(
		function (anchor) {
			if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
				anchor.target = "_blank";
		}
	);
}
Event.onDOMReady(externalLinks);


function emptyfield (field, defaultval, blur)
{
	if ( blur == true ) {
		if (field.value == '') {
			field.value = defaultval;
		}
	} else {
		if (field.value == defaultval) {
			field.value = '';
		}
	}
}

function checkFieldValue (id_name, dictionary_value)
{
	if (dictionary_value == document.getElementById(id_name).value)
		document.getElementById(id_name).value = '';
}

function ajaxCall(url, params)
{
	xmlobj = null;	
	try
	{
		xmlobj=new XMLHttpRequest();
	}
	catch(e) {
		try
		{
			xmlobj=new ActiveXObject('Microsoft.XMLHTTP');
		}
		catch(e)
		{
			xmlobj=null;
			return false;
		}
	}
	xmlobj.open('POST', url, true);
	xmlobj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');	
	xmlobj.onreadystatechange = function() {
		if (xmlobj.readyState == 4) {
			xmlobj.status == 200;
			if (xmlobj.responseText) {
				document.getElementById('single-item').innerHTML = xmlobj.responseText;
				document.getElementById('multi-item').style.width = '48%';
				document.getElementById('single-item').style.visibility = 'visible';
			}
		}
	}
	xmlobj.send(params);
}



/**
 * Outsmarting the Google Toolbar
 * 
 * http://code.jenseng.com/google/
 */

  if(window.attachEvent)
    window.attachEvent("onload",setListeners);

  function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++){
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++){
      selectList[i].attachEvent("onpropertychange",restoreStyles);
      selectList[i].style.backgroundColor = "";
    }
  }

  function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "")
      event.srcElement.style.backgroundColor = "";
  }


function getScrollHeight()
{
   var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;
           
   return h ? h : 0;
}