$(document).ready(function(){
	
	$(".tab_content").hide();
	$(".tabs li").show();
	$("ul.tabs li:first").addClass("active").show();
	$(".tab_content:first").show();
	
	$("ul.tabs li").mouseover(function() {
		$("ul.tabs li").removeClass("active"); 
		$(this).addClass("active");
		$(".tab_content").hide();
		var activeTab = $(this).find("a").attr("rel");
		var classNameA = $(this).find("a").attr("class");
		$(activeTab).show();
		
		return false;
	});
	if($('#src_txt').val() == "" ) $('#src_txt').val(rm_search);
	$('#src_txt').click(function(event) {
	  if($('#src_txt').val() == rm_search ) $('#src_txt').val("");
	});
	
	$("#src_txt").autocomplete("index.php?com=search&res=true", {
		width: 260,
		matchContains: true,
		selectFirst: false
	});
	$("#src_txt").result(function(event, data, formatted) {
		$('#src_txt').val(rm_search);
		var as = data.toString().split(',');
		var tg = as[as.length-1].split('-');
		if(tg.length > 1)
		{
			if(tg[0] == "g") window.location.href = "index.php?com=geo&id=" + tg[1];
			else if(tg[0] == "h") window.location.href = "index.php?com=hotels&id=" + tg[1];
			else if(tg[0] == "n") window.location.href = "index.php?com=content&id=" + tg[1];
		}		
	});
	$('#src_txt').keypress(function(event) {
	  if (event.keyCode == '13') { event.preventDefault();  }	  
	});

});

function CloseComboPopup()
{
	if(window.generalPopup)
	{
		$(window.generalPopup).hide('slow');
		window.generalPopup = null;
	}
}

window.generalPopup = null;
function ShowPopupEffect(obj)
{
	window.generalPopup = obj;
	$(obj).show('slow');
}

CheckgeneralPopup = function(ev) {
	
	if (window.generalPopup) {
		
		var el = Browser.isIE ? window.event.srcElement : ev.target;
		for (; el != null && el.id != (window.generalPopup.id); el = el.parentNode);
		if (el == null) {
			CloseComboPopup();
		}
	}
};
addEvent(document, "mousedown", CheckgeneralPopup);

this.imagePreview = function(){	
	/* CONFIG */
	xOffset = 10;
	yOffset = 30;
	/* END CONFIG */
	$("div.preview, span.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ this.id +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset - 100) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("div.preview, span.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset - 100) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});

function cNv(nav, gid, km, prl, opt)
{
	var _push = {};
	var _com = getParameter("com");
	if(_com && _com != "geo")
	{
		_push["com"] = getParameter("com");
		_push["geo"] = gid;
		_push["id"] = "";
	}
	else 
	{
		_push["com"] = "geo";
		_push["id"] = gid;
	}
	
	if(km) _push["km"] = km; else _push["km"] = '';
	if(prl) _push["prl"] = prl; else _push["prl"] = '';
	if(opt) _push["opt"] = opt; else _push["opt"] = '';
	
	var _uri = PrepareUrl(_push);
	if(nav) window.location.href = _uri;
	else return _uri;
}

function getParameter(paramName) {
  var searchString = window.location.search.substring(1), i, val, params = searchString.split("&");

  for (i=0;i<params.length;i++) {
    val = params[i].split("=");
    if (val[0] == paramName) {
      return unescape(val[1]);
    }
  }
  return null;
}

function getIcon(path)
{
	var bIcon = new GIcon(G_DEFAULT_ICON);
	bIcon.image = path;
	//bIcon.iconsize = new GSize(38,38);
	bIcon.iconSize = new GSize(26,30);
	bIcon.shadowSize = new GSize(1,1);
	bIcon.iconAnchor = new GPoint(12,12);
	bIcon.infoWindowAnchor = new GPoint(0,0);
	return bIcon;
}
