// Browsererkennung
if(window.opera) { // Opera
	var opera = true;
}
else if(document.all){ // Internet Explorer
	var msie = true;
}
else if(document.getElementById && document.compatMode) { // Firefox
	var ff = true;
}
else if(document.getElementById){ // Netscape 6+
	var ns6 = true;
}

//DHTML Window script- Copyright Dynamic Drive (http://www.dynamicdrive.com)
//For full source code, documentation, and terms of usage,
//Visit http://www.dynamicdrive.com/dynamicindex9/dhtmlwindow.htm

var dragapproved = false;
var minrestore = 0;
var initialwidth, initialheight;

function iecompattest() {
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function drag_drop(e) {
	if (msie&&dragapproved&&event.button==1) {
		document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px";
		document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px";
	} else if ((ns6||ff||opera)&&dragapproved) {
		document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px";
		document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px";
	}
}

function initializedrag(e) {
	offsetx=msie? event.clientX : e.clientX;
	offsety=msie? event.clientY : e.clientY;
	document.getElementById("dwindowcontent").style.display="none"; //extra
	tempx=parseInt(document.getElementById("dwindow").style.left);
	tempy=parseInt(document.getElementById("dwindow").style.top);

	dragapproved=true;
	document.getElementById("dwindow").onmousemove=drag_drop;
}

function loadwindow(url,width,height) {
	if (ns6)
		window.open(url,"","width=width,height=height,scrollbars=1");
	else {
		if (ff) {
			document.getElementById("dwindowcontent").style.width=width-4+"px";
		}
		
		document.getElementById("dwindow").style.width=initialwidth=width+"px";
		document.getElementById("dwindow").style.height=initialheight=height+"px";

		document.getElementById("dwindow").style.left="50px";
		document.getElementById("dwindow").style.top=msie ? iecompattest().scrollTop*1+65+"px" : window.pageYOffset*1+65+"px";
		document.getElementById("cframe").src=url;
		document.getElementById("dwindow").style.display='';
	}
}

function closeit() {
	document.getElementById("dwindow").style.display="none";
	document.getElementById("cframe").src='';
}

function stopdrag() {
	dragapproved=false;
	document.getElementById("dwindow").onmousemove=null;
	document.getElementById("dwindowcontent").style.display=""; //extra
}

// DHTML Start
function startuploadwin(url, width, height) {
	if (ns6)
		window.onload = new Function('loadwindow(url, width, height)');
  else
    loadwindow(url, width, height);
}


//Popup Cookie sperre
//===================

var expDays = 1; // number of hours the cookie should last

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
    return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

function SetCookie (name, value) {
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {
  var exp = new Date();
  exp.setTime (exp.getTime() - 1);
  var cval = GetCookie (name);
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

var exp = new Date();
exp.setTime(exp.getTime() + (expDays*60*60*1000));

function amt(){
  var count = GetCookie('count')
  if(count == null) {
    SetCookie('count','1')
    return 1
  } else {
    var newcount = parseInt(count) + 1;
    DeleteCookie('count')
    SetCookie('count',newcount,exp)
    return count
  }
}

function getCookieVal(offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function checkCount() {
  var count = GetCookie('count');
  if (count == null) {
    count=1;
    SetCookie('count', count, exp);
    return true;
  } else {
    count++;
    SetCookie('count', count, exp);
    return false;
  }
}