// Bus Timetable Ajax Code

var http = false;
if(navigator.appName == "Microsoft Internet Explorer") {
	http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
  	http = new XMLHttpRequest();
}
var http2 = false;
if(navigator.appName == "Microsoft Internet Explorer") {
	http2 = new ActiveXObject("Microsoft.XMLHTTP");
} else {
  	http2 = new XMLHttpRequest();
}

function bhsinfo(bhsid) {
 	 http.abort();
 	 http.open("GET", "../resources/PHP/ajax.php?bhsid=" + bhsid, true);
  	 http.onreadystatechange=function() {
  	  if(http.readyState == 4 && http.responseText != '') {
			document.getElementById('output').innerHTML  = http.responseText;
  	  }
 	 }
  	http.send(null);
  setTimeout(function(){bhsinfo(bhsid)} , 30*1000 );
}

function bhsinfo2(bhsid) {
 	 http2.abort();
 	 http2.open("GET", "../resources/PHP/ajax.php?bhsid=" + bhsid, true);
  	 http2.onreadystatechange=function() {
  	  if(http2.readyState == 4 && http2.responseText != '') {
			document.getElementById('output_B').innerHTML  = http2.responseText;
  	  }
 	 }
  	http2.send(null);
  setTimeout(function(){bhsinfo2(bhsid)} , 30*1000 );
}

// SBB INPUT datum & Zeit

function SBBdate(ID)  {
	today = new Date()
	CurrentYear = today.getYear();
	if(CurrentYear < 2000) { CurrentYear = CurrentYear + 1900; }
	var input = document.getElementById(ID);
	input.value = PadDigits(today.getDate(), 2) + "." + PadDigits((today.getMonth()+1), 2) + "." + CurrentYear;
}
function SBBtime(ID)  {
	today = new Date()
	var input = document.getElementById(ID);
	input.value = PadDigits(today.getHours(), 2) + ":" + PadDigits(today.getMinutes(), 2);
}

// Standard site code


function onLoad(subject) {
	versenden(subject);
}
function pad_left() {
	var Lwidth = ((document.body.clientWidth - 900) / 2) + "px";
	document.getElementById('pano').style.paddingLeft = Lwidth;
	document.getElementById('Hauptnavigation').style.paddingLeft = Lwidth;
	document.getElementById('ZweiteNavigation').style.paddingLeft = Lwidth;
	document.getElementById('content').style.marginLeft = Lwidth;
	document.getElementById('footer').style.paddingLeft = Lwidth;

}

function PadDigits(n, totalDigits) { 
        n = n.toString(); 
        var pd = ''; 
        if (totalDigits > n.length) 
        { 
            for (i=0; i < (totalDigits-n.length); i++) 
            { 
                pd += '0'; 
            } 
        } 
        return pd + n.toString(); 
} 

function mailto(Name,E1,Domain)  {
Email=(E1 + '@' + Domain)	;
document.write('<A href="mailto:' + Email + '" title="Mailto: ' + Name + '">' + Email + '</a>' );
}
function versenden(subject) {
	/*
var url=new String(window.location);
subject = escape(subject);
var vershref="mailto:?subject="+subject+"&body="+url;
document.getElementById('versenden').href = vershref;*/
}

function Copy(text)  {
text = typeof(text) != 'undefined' ? text : '';
today = new Date()
CurrentYear = today.getYear();
if(CurrentYear < 2000) { CurrentYear = CurrentYear + 1900; }
document.write("&copy " + CurrentYear + " " + text);
}

function prt_Date(Beschreibung)  {
today = new Date()
CurrentYear = today.getYear();
if(CurrentYear < 2000) { CurrentYear = CurrentYear + 1900; }
document.write(Beschreibung + " " + PadDigits(today.getDate(), 2) + "." + PadDigits((today.getMonth()+1), 2) + "." + CurrentYear + " " + PadDigits(today.getHours(), 2) + ":" + PadDigits(today.getMinutes(), 2));
}
function menu_goto( menuform )
{
    //var baseurl = "http://www.put-your-domain-name-here.com" ;
    selecteditem = menuform.newurl.selectedIndex ;
    newurl = menuform.newurl.options[ selecteditem ].value ;
    if (newurl.length != 0) {
      //location.href = baseurl + newurl ;
    }
}
function checkFormular(form) // Funktioniert nicht!!
{
valid = true;

var required= form.required.value ;
required = required.replace(" ","");
Arequired = required.split(",");

var compare= form.compare.value ;
compare = compare.replace(" ","");
compare = compare.split(",");

var warning_on_ID= form.warning_on_ID.value ;
warning_on_ID = warning_on_ID.replace(" ","");
warning_on_ID = warning_on_ID.split(",");

var warning_off_ID= form.warning_off_ID.value ;
warning_off_ID = warning_off_ID.replace(" ","");
warning_off_ID = warning_off_ID.split(",");

for(var i=0; i < required.length; i++)
	{
		
	var x = getElementsByTagName(required[i]);
	alert(x.value);
	if ( x.value == "" ) //&& document.getElementById(required[i])
    	{
			
		document.getElementById(required[i]).style.color = 'red';
		valid = false;
    	}
	else document.getElementById(required[i]).style.color = '';
	}

/*for(var i=0; i < form.compare.length; i++)
	{
	if ( form.compare[i].value != form.compare[i+1].value && document.getElementById(compare[i+1]))
    	{
		document.getElementById(compare[i+1]).style.color = 'red';
		valid = false;
    	}
	else document.getElementById(compare[i+1]).style.color = '';
	}
 */
 
 // also add thing to check that has email 'at'
 
 
 if ( valid == false )
	{
	 	document.getElementById('pflicht_1').style.display = 'none';
		document.getElementById('pflicht_2').style.color = 'red';
		document.getElementById('pflicht_2').style.display = 'block';
		document.getElementById('ueberprufen').style.color = 'red';
		document.getElementById('ueberprufen').style.display = 'block';
	}
 if (valid == true) {
	 	//form.submit();
    }
}

/*  FROM ORIGINAL CL SITE  */

function send_article(){
	link	= window.location.href;
	window.location.href = "mailto:?subject=Biografiearbeit - Linktipp&body= "+link;
}
function print_view(page){
	popup=window.open(page,"print","width=700,height=600,scrollbars=yes,resizable=no,menubar=yes,locationbar=no,toolbar=no,left=0,top=0");
	popup.focus();
}
function print_viewpup(page){
	popup=window.open(page,"print","width=900,height=600,scrollbars=yes,resizable=yes,menubar=yes,locationbar=no,toolbar=no,left=90,top=0");
	popup.focus();
}
function HelpWindow(file,window) {
	msgWindow=open(file,window,"toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=yes,scrollbars=yes,width=750,height=600");
	if (msgWindow.opener == null) msgWindow.opener = self;
}
function popup(url){
  window.open(url,'popup','status=no,toolbar=no,scrollbars=yes,width=500,height=520,left=90,top=27')
}
function popupex(theURL,winName,features) {
  window.open(theURL,winName,features);
}
function open_window(page,wd,hg,name){
	popup=window.open(page,name,"width=" + wd + ",height=" + hg + ",scrollbars=no,resizable=yes,menubar=no,locationbar=no,left=270,top=180");
}
function open_windowx(page,wd,hg,name){
	popup=window.open(page,name,"width=" + wd + ",height=" + hg + ",status=no,toolbar=no,scrollbars=yes,resizable=no,menubar=no,locationbar=no,left=180,top=9");
	popup.focus();
}
function open_windowvr(page,wd,hg,lx,ty,name){
	popup=window.open(page,name,"width=" + wd + ",height=" + hg + ",left=" + lx + ",top=" + ty +",status=no,toolbar=no,scrollbars=no,resizable=no,menubar=no,locationbar=no");
	popup.focus();
}
function open_windowvrex(page,wd,hg,lx,ty,name){
	popup=window.open(page,name,"width=" + wd + ",height=" + hg + ",left=" + lx + ",top=" + ty +",status=no,toolbar=no,scrollbars=yes,resizable=yes,menubar=no,locationbar=yes");
	popup.focus();
}
function open_windowjq(page,wd,hg,name){
	popup=window.open(page,name,"width=" + wd + ",height=" + hg + ",scrollbars=no,resizable=yes,menubar=no,locationbar=no,left=270,top=180");
}
function lin(pass) {
	var html_ext=".html";
	var path_to_page="http://www.fuss-schule.info/";
	var location=path_to_page+pass+html_ext;
	this.location.href=location
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function right(e) {
if (navigator.appName == 'Netscape' &&
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' &&
(event.button == 2 || event.button == 3))
{
alert ("© Claudia Larsen");
return false;
}
return true;
}
document.onmousedown=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=right;
