/*
Copyright (c) 2008, Blue Ocean Labs. All rights reserved.
*/

if (typeof console == 'undefined') {
	console = function() {};
	console.log = function() {};
}


function setCursor(element, start, end) {
	if(element.setSelectionRange) {
		element.focus();
		element.setSelectionRange(start, end);
	}
	else if(element.createTextRange) {
		range=element.createTextRange();
		range.collapse(true);
		range.moveEnd('character',end);
		range.movestart('character',start);
		range.select();
	}
} 

function popwin(theURL,winName,features) {
	popup = window.open(theURL,winName,features);
	// seite, "popup", "width=420,height=380,top=10,left=30,resizable=yes,scrollbars=no,status=no,menubar=no,location=no");
	popup.focus();
}

function switchLanguage(lang) {
	Cookie.set('fyesta_lang', lang);
	window.location.reload(true);
}

var Cookie = {
	get: function(name) {
		var val = String(document.cookie).replace(new RegExp("^(.*; )?"+name+"\=([^;]*)(;)?.*$"), "$2");
		return (val == document.cookie)? null : unescape(val);
	},
	set: function(name, value, cookieExpireSeconds) {
		var expDate = new Date();
		if (!cookieExpireSeconds) {
			cookieExpireSeconds = 1000 * 60 * 60 * 24 * 365;
		}
		expDate.setTime(expDate.getTime() + cookieExpireSeconds);
		var cookieValue = name+"="+escape(value) + "; path=/;expires="+expDate.toGMTString()+";";
		if (window.location.hostname != 'localhost') {
			cookieValue += "domain=."+window.location.hostname+";";
		}
		document.cookie = cookieValue; 
	},
	remove: function(name) {
		Cookie.set(name, '', new Date(Date.parse('Thu, 01-Jan-1970 00:00:01 GMT')));
	}
};
