var langcodes = new Array("en","de","default");
var langredirects = new Array("en/index.htm","de/index.htm","en/index.htm");
//var langredirects = new Array("en/","de/","en/");
var langinfo = Get_Cookie("lang")?Get_Cookie("lang"):navigator.language?navigator.language:navigator.userLanguage;
var gotodefault = 1;
var now = new Date()

function redirect(dest){
	if(window.location.replace)
		window.location.replace(dest);
	else
		window.location = dest;
}

function setLang(lang){
	Set_Cookie("lang",lang,new Date(now.setFullYear(now.getFullYear() +1)),"/");
	//storeIntelligentCookie("lang",lang);
	top.location.href = top.location.href.replace(/\/de\/|\/en\//,"/"+lang+"/")
}

function linkMail(adr){
	location.href="mailto:"+Mail(adr);
}

function Mail(adr){
	tmp = new String();
	for(i=0;i<adr.length;i++)
		tmp+= String.fromCharCode(adr.charCodeAt(i)-3);
	return tmp;
}

function writeMail(adr){
	adr = Mail(adr);
	document.open();
	document.write("<a href=\"mailto:"+adr+"\">"+adr+"</a>");
	document.close();
}


function openWindow(u,t,f,x,y,l,o){if(!isNaN(f)){o=l;l=y;y=x;x=f;f=null;}
	if(!l)l=Math.round((screen.width-x-10)/2);if(!o)o=Math.round((screen.height-y-30)/2);
	if(l<0)l=0;if(o<0)o=0;f=(f)?f+',':'';f+=(x)?'width='+x+',left='+l+',':'';
	f+=(y)?'height='+y+',top='+o:'';t=(t)?t:'_blank';
	return window.open(u,t,f);}




function popupImage(e){
ct = e.currentTarget;
url = ct.getAttribute("href");
width = new Number(getParameter("w",url));
height = new Number(getParameter("h",url));
target = ct.getAttribute('target')||'_blank';
avWidth = (screen.width-100)/width;
avHeight = (screen.height-100)/height;
perc = (avWidth<1||avHeight<1)?Math.min(avWidth,avHeight):1;
width=Math.round(width*perc);
height=Math.round(height*perc);

//		if(imgWindow = openWindow(url,target,width,height)){
			imgWindow = openWindow(url,target,width,height);
			//iWd = imgWindow.document;
			imgWindow.document.open("text/html","replace");
			imgWindow.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\"><html><head><title>greentube.com</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"></head><body onblur=\"top.close();\" style=\"overflow=hidden;margin:0;padding:0\"><img id=\"img\" width=\""+width+"\" height=\""+height+"\" src=\""+url+"\"/></body></html>");
			imgWindow.document.close();
			imgWindow.focus();
		//}
		//else
		//	location.href = url;
		e.preventDefault();
}






/* cookies */
function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}

function Delete_Cookie(name,path,domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
       ( (path) ? ";path=" + path : "") +
       ( (domain) ? ";domain=" + domain : "") +
       ";expires=Thu, 01-Jan-70 00:00:01 GMT";
}

var today = new Date();
var zero_date = new Date(0,0,0);
today.setTime(today.getTime() - zero_date.getTime());

var todays_date = new Date(today.getYear(),today.getMonth(),today.getDate(),0,0,0);
var expires_date = new Date(todays_date.getTime() + (8 * 7 * 86400000));

function storeMasterCookie() {
    if (!Get_Cookie('MasterCookie'))
        Set_Cookie('MasterCookie','MasterCookie');
}

function storeIntelligentCookie(name,value) {
    if (Get_Cookie('MasterCookie')) {
        var IntelligentCookie = Get_Cookie(name);
        if ((!IntelligentCookie) || (IntelligentCookie != value)) {
            Set_Cookie(name,value,expires_date);
            var IntelligentCookie = Get_Cookie(name);
            if ((!IntelligentCookie) || (IntelligentCookie != value))
                Delete_Cookie('MasterCookie');
        }
    }
}
var src_loaded = true;

