var remote = null;

/*

	Show a new window

	n: window name

	u: url

	w: width

	h: height

*/
function ShowWindow(n,u,w,h)
{
	args="width="+w+",height="+h+",titlebar=no,menubar=no,toolbar=no,directories=no,resizable=yes,scrollbars=yes,status=0";
	remote=window.open(u,n,args);
	if (remote != null)
	{
	    if (remote.opener == null)
	    		remote.opener =self;
		window.name='MyWindow';
		remote.location.href=u;
	}
	remote.focus();
}
/*
	open url
*/
function open_url(aurl,m,w,h)
{
	var currTime= new Date();
	var newurl=aurl;
	/* Open in the same window */

	if (m==0)
	{
		// window.open(newurl,"_self");
		self.location.href = newurl;
	}

	else
	{
		/* Open in the a new window */

		ShowWindow('windowname1',newurl,w,h);	
	}

}
function change_language(aurl,m)
{

    var obj = document.getElementById("id_lang");  
		var selIndex = obj.selectedIndex;
    var newurl = aurl + '&language=' + obj.options[selIndex].value;
  
    self.location.href = newurl;
}

function show_map(s_name,s_address,phone,fax,email)
{
 // alert(s_address + " - " + phone+ " - " +fax+ " - " +email);
  var newurl="/show_map.php?s_name=" + s_name + "&s_address=" + s_address + "&s_phone=" + phone + "&s_fax=" + fax+ "&s_email=" + email;
 //alert(newurl);
 	ShowWindow('windowname1',newurl,"1000","1000");   
}

function toggleLayer( whichLayer )
{ 
 var elem, vis; 
 if( document.getElementById )  // this is the way the standards work 
    elem = document.getElementById( whichLayer ); 
 else if( document.all ) // this is the way old msie versions work
     elem = document.all[whichLayer]; 
  else if( document.layers ) // this is the way nn4 works    
    elem = document.layers[whichLayer];  
    vis = elem.style;  // if the style.display value is blank we try to figure it out here  

    if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
          vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none'; 
      
    vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
function showhide(whichLayer,action)
{ 
 var elem, vis; 
 if( document.getElementById )  // this is the way the standards work 
    elem = document.getElementById( whichLayer ); 
 else if( document.all ) // this is the way old msie versions work
     elem = document.all[whichLayer]; 
  else if( document.layers ) // this is the way nn4 works    
    elem = document.layers[whichLayer];  
    vis = elem.style;  // if the style.display value is blank we try to figure it out here  

    if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
          vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none'; 
    //Show
    if (action == 1)
    {
      if ((vis.display==''||vis.display=='none'))
      vis.display = "block";
    }  
    else
    {
      if ((vis.display==''||vis.display=='block'))
        vis.display = "none";    
    }
    //vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}
function removespaces(string) {
 return string.split(' ').join('');
}

// copyright 1999 Idocs, Inc. http://www.idocs.com
// Distribute this script freely but keep this notice in place
function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;

// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}

