<!--

// ------------------------------------------------------------
// Allgemeiner Image-Changer
// ------------------------------------------------------------
function chg(ImageName, FileName) {
	if (document[ImageName]) {
		document[ImageName].src = FileName;
	} else if (typeof(document.getElementById)=="function" && document.getElementById(ImageName)) {
		document.getElementById(ImageName).src = FileName;
	}
}


function open_window_tipafriend(ref_url) {	// Wrapper-Routine für das Tip-A-Friend-Window
	if( ref_url && ref_url != "" ) {
		window.open("/fileadmin/extensions/tipafriend/tipafriend.php?url="+ref_url, "tell", "width=530,height=610,scrollbars=no,menubar=no,toolbar=no,location=no,status=no,resizable=no");
	}
}


function open_window_tipafriend2(ref_url) {	// Wrapper-Routine für das neue Tip-A-Friend-Window (eigene Community-Routine)
	if( ref_url && ref_url != "" ) {
		window.open("/community/Users/tellafriend/?refurl="+URLEncode( ref_url ), "tell", "width=530,height=610,scrollbars=no,menubar=no,toolbar=no,location=no,status=no,resizable=no");
	}
}

function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}


// ------------------------------------------------------------
// Open_Window: Neues Fenster öffnen
// ------------------------------------------------------------
function open_window(url, x, y, center, name) {
	if (x && x != "") { width = x; } else { width = 600; }
	if (y && y != "") { height = y + 17; } else { height = 507; }
	if (center && center == 1) {
/*		if (navigator.appName=="Netscape") {
		    var widthall = top.window.innerWidth;
		    var heightall = top.window.innerHeight;
		} else if (navigator.appName.indexOf("Microsoft") != -1) {
		    var widthall = top.document.body.offsetWidth;
		    var heightall = top.document.body.offsetHeight;
		}*/
		var widthall = screen.Width;
		var heightall = screen.Height;
		var top = Math.round( ( heightall - height ) / 2 );
		if( widthall >= width ) {
			var left = Math.round( ( widthall - width ) / 2 );
		} else {
			var left = Math.round( ( width - widthall ) / 2 );
		}
		// alert( "Old Browser => width: " + widthall + " height: " + heightall + " \nCenter-Window => top: " + top + " left: " + left + " \nNew Window => width: " + width + " height: " + height );
	} else {
		var top = 10;
		var left = 10;
	}
	if( name && name == 1 ) {
		var myname = Math.round( 1000 * Math.random() );
	} else {
		var myname = "1";
	}
	var zoom_win = window.open(url, "openwindow"+myname, "left="+left+",top="+top+",width="+width+",height="+height+",scrollbars=yes,menubar=yes,toolbar=no,location=no,status=no,resizable=no");
}
function open_window_full(url) {
	var widthall = screen.Width;
	var heightall = screen.Height;
	var zoom_win = window.open(url, "openwindowfull", 'width=' + widthall + ',height=' + heightall + ',top=0,left=0,scrollbars=auto,menubar=yes');
}
// ------------------------------------------------------------



// ------------------------------------------------------------
// Thickbox per Javascript starten/triggern
// Param linkid: HTML-Element-ID des Links
// Param divid: HTML-Element-ID des Divs, das geöffnet werden soll
// ------------------------------------------------------------
function start_thickbox(linkid,divid) {
	var myname = linkid; // "cakemessagelink";
	var mydiv = divid; 	// "cakemessage";
	window.location.href="#TB_inline?height=155&width=300&inlineId="+mydiv+"&modal=true";
	var obj = document.getElementById( myname );
	// alert( obj );
	var t = obj.title || obj.name || null;
	var a = obj.href || obj.alt;
	var g = obj.rel || false;
	// alert(a);
	tb_show(t,a,g);
}
// ------------------------------------------------------------

	
	
// ------------------------------------------------------------
// JS-Email Validation
// ------------------------------------------------------------
function check_email (emailStr) {
	var checkTLD=0; var knownDomsPat=/^(de|com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/; var emailPat=/^(.+)@(.+)$/; var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]"; var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")"; var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/; var atom=validChars + '+'; var word="(" + atom + "|" + quotedUser + ")"; var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$"); var matchArray=emailStr.match(emailPat);
	if (matchArray==null) {
		// alert("Email address seems incorrect (check @ and .'s)");
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	// Start by checking that only basic ASCII characters are in the strings (0-127).
	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
			// alert("Ths username contains invalid characters.");
			return false;
		}
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			// alert("Ths domain name contains invalid characters.");
			return false;
		}
	}
	// See if "user" is valid 
	if (user.match(userPat)==null) {
		// user is not valid
		// alert("The username doesn't seem to be valid.");
		return false;
	}
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				// alert("Destination IP address is invalid!");
				return false;
			}
		}
		return true;
	}
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
			// alert("The domain name does not seem to be valid.");
			return false;
		}
	}
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {
		// alert("The address must end in a well-known domain or two letter " + "country.");
		return false;
	}
	if (len<2) {
		// alert("This address is missing a hostname!");
		return false;
	}
	// If we've gotten this far, everything's valid!
	return true;
}

// Check, ob ein String eine Nummer ist
function IsNumeric(sText) {
	var ValidChars = "0123456789";	// ggf. noch "." oder "-" erlauben
	var IsNumber=true;
	var Char;
	for (i = 0; i < sText.length && IsNumber == true; i++)  { 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) {
			IsNumber = false;
		}
	}
	return IsNumber;
}

function show(object) {
	getNode(object).style.display = 'block';
	setCookie('the_news', 'show');
}

function hide(object) {
	getNode(object).style.display = 'none';
	setCookie('the_news', 'hide');
}

function div_show(object) {
	getNode(object).style.visibility = 'visible';
}

function div_hide(object) {
	getNode(object).style.visibility = 'hidden';
}

function setCookie( key, value ) {
	document.cookie = key + '=' + value + '; expires=' +
		new Date( 2010, 0, 1 ).toGMTString();
		
}

// Submit-Button enablen/disablen
function enable_submit_button( enable ) {
	if( enable && document.getElementById ) {
		document.getElementById('weiter').disabled = false;
	} else if( document.getElementById ) {
		document.getElementById('weiter').disabled = true;
	}
	return true;
}

// -->
