function init ()
{
	externalLinks();	
	if ($('Lightbox'))
		initLightbox();
}
window.onload = init;


function changeClass(obj, new_class)
{
    obj.className = new_class;
}

function changeBgColor(obj, new_color)
{
	obj.style.backgroundColor=new_color;
}

function changePic(name, pic)
{
	name.src = pic;
}

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()
{
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++)
	{
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
	}
}

function emptyfield (field, defaultval, blur)
{
	if ( blur == true ) {
		if (field.value == '') {
			field.value = defaultval;
		}
	} else {
		if (field.value == defaultval) {
			field.value = '';
		}
	}

	return true;
}

function checkFieldValue (id_name, dictionary_value)
{
	//alert(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 = "";
  }
  

  
/**
  * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
  */
function echeck (str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)

	if (str.indexOf(at)==-1){
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		return false
	 }

	 return true					
}