
$(function() {
	initTooltip();
});

function initTooltip()
{
	if ($.isFunction($.fn.tooltip))
	{
		$('.tooltip').Tooltip({
			showURL: false,
			id: "tooltip",
			showBody: "; ",
			fade: 250
		});
	}
}

function callOnEnter(e,functionToCall,argArray)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (keycode == 13)
   {
   	if ((argArray == null) || (argArray == "")) 
   	{
   		argArray = new Array();
   	}
   
   	functionToCall.apply(this, argArray);
   	return false;
   }
else
   return true;
}

function submitEnter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   myfield.form.submit();
   return false;
   }
else
   return true;
}

/*
* 
*
*/
function confirmDialog(title, onYesClick, question, height, width, onNoClick)
{
	if (height == null)
	{
		height=150;
	}
		
	if (width == null)
	{
		width=300;
	}

	if (onNoClick == null)
	{
		onNoClick="";
	}

	$("#dialog").html("");

	var dialogContent = unescape("%3Cdiv%20class%3D%22dialog_info%22%3Equestion%3C%2Fdiv%3E%0D%0A%3Ccenter%3E%0D%0A%3Ctable%20cellpadding%3D%2220%22%20width%3D%22270%22%3E%0D%0A%20%20%3Ctr%3E%0D%0A%20%20%20%20%3Ctd%20width%3D%22100%22%3E%3Cdiv%20style%3D%22border%3A1px%20solid%20%23999%3B%20height%3A23px%3B%22%3E%0D%0A%3Ca%20class%3D%22standard_button%22%20%0D%0A%20%0D%0Astyle%3D%22%20height%3A20px%3B%20line-height%3A%2020px%3B%22%0D%0A%20onclick%3D%22onYesClick%3B%24%28%27%23dialog%27%29.dialog%28%27close%27%29%3B%22%3E%0D%0AJA%0D%0A%3C%2Fa%3E%0D%0A%3C%2Fdiv%3E%3C%2Ftd%3E%0D%0A%20%20%20%20%3Ctd%20width%3D%22100%22%3E%3Cdiv%20style%3D%22border%3A1px%20solid%20%23999%3B%20height%3A23px%3B%22%3E%0D%0A%3Ca%20class%3D%22standard_button%22%20%0D%0A%20%0D%0Astyle%3D%22%20height%3A20px%3B%20line-height%3A%2020px%3B%22%0D%0A%20onclick%3D%22onNoClick%3B%24%28%27%23dialog%27%29.dialog%28%27close%27%29%3B%22%3E%0D%0ANEIN%0D%0A%3C%2Fa%3E%0D%0A%3C%2Fdiv%3E%3C%2Ftd%3E%0D%0A%20%20%3C%2Ftr%3E%0D%0A%3C%2Ftable%3E%0D%0A%3C%2Fcenter%3E");
	
	dialogContent = dialogContent.replace(/onYesClick/, onYesClick);
	dialogContent = dialogContent.replace(/onNoClick/, onNoClick);
	dialogContent = dialogContent.replace(/question/, question);
	
	$("#dialog").html(dialogContent);

    $("#dialog").dialog({
    	close: function(event, ui) 
 		{ 
 			$('#dialog').dialog('destroy'); 
 		},
    	resizable: false,
    	draggable: false,
    	height: "auto",
    	width: width,
    	bgiframe: true,
    	modal: true,
    	title: title
	});
}

function infoDialog(title, content, height, width)
{
	if (height == null)
	{
		height=250;
	}
		
	if (width == null)
	{
		width=400;
	}

	$("#dialog").html("");

	content = "<center><br/>"+content+"</center>";

	var dialogContent = unescape("%3Cdiv%20style%3D%22overflow%3A%20auto%3Bheight%20%3A%20150px%22%3Econtent%3C%2Fdiv%3E%0D%0A%3Ccenter%3E%0D%0A%3Ctable%20style%3D%22margin-top%3A%2010px%3B%22%20width%3D%22370%22%3E%0D%0A%20%20%3Ctr%3E%0D%0A%20%20%20%20%3Ctd%20width%3D%22100%25%22%20align%3D%22center%22%3E%3Cdiv%20style%3D%22border%3A1px%20solid%20%23999%3B%20width%3A102px%3B%22%3E%0D%0A%3Ca%20class%3D%22standard_button%22%20%0D%0A%20%0D%0Astyle%3D%22%20width%3A100px%3B%22%0D%0A%20onclick%3D%22%24%28%27%23dialog%27%29.dialog%28%27close%27%29%22%3E%0D%0AOK%0D%0A%3C%2Fa%3E%0D%0A%3C%2Fdiv%3E%3C%2Ftd%3E%0D%0A%20%20%3C%2Ftr%3E%0D%0A%3C%2Ftable%3E%0D%0A%3C%2Fcenter%3E");
	
	dialogContent = dialogContent.replace(/150/, height-100);
	dialogContent = dialogContent.replace(/370/, width-30);
	dialogContent = dialogContent.replace(/content/, content);
	
	$("#dialog").html(dialogContent);

    $("#dialog").dialog({
    	close: function(event, ui) 
 		{ 
 			$('#dialog').dialog('destroy'); 
 		},
    	resizable: false,
    	draggable: false,
    	height: "auto",
    	width: width,
    	bgiframe: true,
    	modal: true,
    	title: title
	});
}

/**********************************************************************************************/

function checkCookiesActive()
{
	$.post( "http://www.surfbali.ch/core/ajax/ajax.php",	
	{
		type: "CHECK_COOKIES"
	},
	function(html)
	{
		if (html != 1)
		{
			$(".cookies_error").html(html);
		}
	});
}
