/*
	------------------------------------
	© bluemedia, http://www.bluemedia.at
	Script by Edermayr Ronald
	Script can be used for free but this
	notice must not be removed.
	------------------------------------
*/
function textCounter(field, maxlimit){
	var matched_char = 0;
	var last_pos = -1;
	while (last_pos != field.value.lastIndexOf("\n")) {
		last_pos = field.value.indexOf("\n", last_pos+1);
		if ( last_pos != -1 ){
			if ( field.value.lastIndexOf("\r") == -1 ){
				matched_char++;
			}
		}
	}
	if ((field.value.length + matched_char) > maxlimit ){
		field.value = field.value.substring(0, (maxlimit - matched_char));
		window.alert("Maximale Zeichenanzahl von " + maxlimit + " Zeichen erreicht");
	}
}

// --- mouseover-functions for browsers with dom-support ---
function bg(obj, color) {
	obj.style.backgroundColor = color;
}

function mOver(obj, over){
	bg(obj, over);
	obj.style.cursor = "pointer";
}

function mOut(obj, out){
	bg(obj, out);
}
// --- end mouseover-functions ---


// --- function geturl ---
function getURL(){
	var args = getURL.arguments;
	if (args.length == 1){
		this.location = args[0];
	}else if (args.length > 1){
		for (i=0; i<(args.length-1); i+=2){
			if (args[i+1] == "_blank")
				window.open(args[i]);
	  		else if (typeof(eval(args[i+1])) == "object")
				eval(args[i+1]+".location='"+args[i]+"'");
			else
				alert("Frame ist ungültig oder existiert nicht.");
		}
	}else{
		alert("ungültige Anzahl an Argumenten beim Aufruf der Funktion \"getURL\"");
		return false;
	}
}

function openwin_printable(imagename,img_width,img_height) {

	var leftpos = (screen.height - img_height)/2;
	var toppos  = (screen.width - img_width)/2;
		
	newWindow = window.open("","newWindow","width="+(img_width+50)+",height="+(img_height+40)+",left="+leftpos+",top="+toppos);
	newWindow.document.open();
	newWindow.document.write('<html><title>Detailansicht</title><head><link rel="stylesheet" type="text/css" href="styles_content.css"></head><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">'); 
	newWindow.document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%"><tr><td><table width="1%" border="0" cellspacing="0" cellpadding="1" align="center" valign="top"><tr><td  colspan="2"><img src="../Rieder%20-%20Bauelemente%20f%FCrs%20Leben-Dateien/%27%2B%20imagename%20%2B%20%27"></td></tr><tr><td><a href="javascript:self.close();"><b>Fenster schliessen</b></a></td><td><div align="right"><a href="#" onclick="window.print();return false"><b>Anfahrtsplan drucken</b></a></div></td></tr></table></td></tr></table>'); 
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}


// --- js popup function ---
function openwin(img_name,img_width,img_height) {

	if (img_width < 30) img_width = 200;
	if (img_height < 30) img_height = 200;

	var leftpos = (screen.height - img_height)/2;
	var toppos  = (screen.width - img_width)/2;
	
	win = window.open("","win","width="+img_width+",height="+img_height+",left="+toppos+",top="+leftpos);
	win.document.open();
	win.document.writeln('<html><title>Detailansicht</title>');
	win.document.writeln('<head>');
	win.document.writeln('<script language="javascript">');
	win.document.writeln('var speed = 10;');
	win.document.writeln('var start_w = 50;');
	win.document.writeln('var start_h = 50;');
	win.document.writeln('window.resizeTo(start_w, start_h);');
	win.document.writeln('var end_w = ' + img_width + ' + 10;');
	win.document.writeln('var end_h = ' + img_height + ' + 29;');
	win.document.writeln('function resize(){');
	win.document.writeln('if(start_w < end_w || start_h < end_h){');
	win.document.writeln('start_w += 10;');
	win.document.writeln('start_h += 10;');
	win.document.writeln('if (start_w > end_w) start_w = end_w;');
	win.document.writeln('if (start_h > end_h) start_h = end_h;')
	win.document.writeln('window.resizeTo(start_w, start_h);');
	win.document.writeln('setTimeout("resize();", 10);');
	//win.document.writeln('alert("w=" + this.start_w + ", " + this.end_w + ", h=" + this.start_h + ", " + this.end_h);');
	win.document.writeln('}');
	win.document.writeln('}');
	win.document.writeln('</script>');
	win.document.writeln('</head>');
	win.document.writeln('<body background="images/popup_loading.gif" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onLoad="resize();">');// onBlur="self.close();">');
	win.document.writeln('<img name="TheImg" src="../Rieder%20-%20Bauelemente%20f%FCrs%20Leben-Dateien/%27%2Bimg_name%2B%27" width="'+img_width+'" height="'+img_height+'">'); 
	win.document.writeln('</body></html>');
	win.document.close();
	
	if (!document.layers) { // for IE
		img_width = parseInt(img_width);
		img_height = parseInt(img_height);
		img_width += 10;
		img_height += 29;
	}
	//win.resizeTo(img_width,img_height);
	win.resizeTo(50,50);
	win.focus();
}

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function showpopup() {
	var showpopup = getCookie("popup");
	if (showpopup != "true") {
		setCookie("popup", "true");
		var url;
		url = "popup_04_04.asp";
		window.open('popups/' + url + '','rieder','scrollbars=no,resizable=yes,width=400,height=380');
	}

}


