
var d=document, site="public";
var UA = navigator.userAgent, w = window;

var is_gecko = /gecko/i.test(UA);
var is_opera = /opera/i.test(UA);
var is_ie = /msie/i.test(UA)&&!is_opera&&!(/mac_powerpc/i.test(UA));
var is_ie5 = is_ie&&/msie 5\.[^5]/i.test(UA);
var is_mac_ie = /msie.*mac/i.test(UA);
var is_khtml = /Konqueror|Safari|KHTML/i.test(navigator.userAgent);

var reNull = /^(\s*)(\b.+\b)(\s*)$/g;

/** Init */
function Init() {
    //initStricker();
}

/** Enlarge image */
function enlarge(url, width, height) {
	Left = (screen.width-width)/2;
    Top = (screen.height-height)/2;
    Attr = 'left='+Left+',top='+Top+',width='+width+',height='+height+',location=no,menubar=no,resizable=no,titlebar=no,toolbar=no,dependent=yes,fullscreen=no,scrollbars=yes';
    window.open("/enlarge.php?"+url, '_blank', Attr);
	return false;
}

function showUserInfo(id) 
{
    var width = 500;
    var height = 400;
	Left = (screen.width-width)/2;
    Top = (screen.height-height)/2;
    Attr = 'left='+Left+',top='+Top+',width='+width+',height='+height+',location=no,menubar=no,resizable=no,titlebar=no,toolbar=no,dependent=no,fullscreen=no,scrollbars=yes';
    window.open("/user.php?id="+id, '_blank', Attr);
	return false;
}


/** Request window */
function request(ActionId) 
{
    width = 700;
    height = 600;
	Left = (screen.width-width)/2;
    Top = (screen.height-height)/2;
    Attr = 'left='+Left+',top='+Top+',width='+width+',height='+height+',location=no,menubar=no,resizable=no,titlebar=no,toolbar=no,dependent=yes,fullscreen=no,scrollbars=yes';
    window.open("/tours/request.php?aId="+ActionId, '_blank', Attr);
	return false;
}

/** Return object left position */
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

/** Return object top position */
function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

/** Hide all select objects */
function hideSelects(obj) {
    
  if (is_ie && obj!=undefined) 
  {  
    var aSelect = d.getElementsByTagName("SELECT");
	if (aSelect.length>0) {
	    //-- Search submenu top, left, width, height  ----
		var formTop = findPosY(obj);
		var formLeft = findPosX(obj);
		var formRight = formLeft+obj.offsetWidth;
		var formBottom = formTop+obj.offsetHeight;

		for (ii=0; ii<aSelect.length; ii++) 
		{
		    //-- Search select top, left, width ----
			var objTop = findPosY(aSelect[ii]);
			var objLeft = findPosX(aSelect[ii]);
			var objRight = objLeft+aSelect[ii].offsetWidth;
			var objBottom = objTop+aSelect[ii].offsetHeight;
			
			var hide = 0;
			if ( (formLeft<=objLeft && formRight>=objRight && formTop<=objTop && formBottom>=objBottom) ||
    			 (formLeft<=objLeft && formRight>=objRight && formTop>=objTop && formTop<=objBottom) ||
    			 (formLeft>=objLeft && formLeft<=objRight && formTop>=objTop && formTop<=objBottom) ||
    			 (formRight>=objLeft && formRight<=objRight && formTop>=objTop && formTop<=objBottom) ||
    			 (formLeft<=objLeft && formRight>=objRight && formBottom>=objTop && formBottom<=objBottom) ||
    			 (formRight>=objLeft && formRight<=objRight && formBottom>=objTop && formBottom<=objBottom) ||
    			 (formLeft>=objLeft && formLeft<=objRight && formBottom>=objTop && formBottom<=objBottom) ||
    			 (formLeft>=objLeft && formLeft<=objRight && formTop<=objTop && formBottom>=objBottom) ||
    			 (formRight>=objLeft && formRight<=objRight && formTop<=objTop && formBottom>=objBottom) 
    		   ) hide=1;

			if (hide==1) aSelect[ii].style.visibility="hidden";
		}
	}
  }
}

/** Show all select objectd */
function showSelects() {
  if (is_ie) {
	var aSelect = d.getElementsByTagName("SELECT");
	for (var ii=0; ii<aSelect.length; ii++) aSelect[ii].style.visibility="visible";
  }
}

var imgLogo = new Image();
imgLogo.src = "/images/logo.gif";

var imgLogoR = new Image();
imgLogoR.src = "/images/logor.gif";

function logoChange(mode)
{
    if (mode==0) d.getElementById("imgLogo").src = imgLogo.src; else d.getElementById("imgLogo").src = imgLogoR.src;
}
