
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 tmt_findObj(n){
        var x,t; if((n.indexOf("?"))>0&&parent.frames.length){t=n.split("?");
        x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
        }else{x=document.getElementById(n)}return x;
}

function validemail(email){
    var teststr = email;
	if(email){
		if (!email.match(/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$/i)){
		   return false;
		} else {
		   return true;
		}
	}
}
// PulldownMenü
function MM_showHideLayers() { //v3.0A Modified by Al Sparber and Massimo Foti for NN6 Compatibility
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  if(document.getElementById){
   	for (i=0; i<(args.length-2); i+=3){ 
    	obj=tmt_findObj(args[i]);
        v=args[i+2];
   		v=(v=='show')?'visible':(v='hide')?'hidden':v;
   		if(obj)
        	obj.style.visibility=v;
    }
  } else{
  	for (i=0; i<(args.length-2); i+=3) 
    	if ((obj=MM_findObj(args[i]))!=null) { 
        	v=args[i+2];
    		if (obj.style) { 
            	obj=obj.style; 
                v=(v=='show')?'visible':(v='hide')?'hidden':v; 
            }
    		obj.visibility=v; 
        }
  }
}

function adjustPulldownPos(name){
	if(document.getElementById){
    	obj=tmt_findObj(name);
        objSrcPos = tmt_findObj('navX');
    	if(document.all){
    		offsetX = document.all.navX.offsetLeft;
    		offsetY = document.all.navX.offsetTop;
     		//alert("adjust " + name + " -> left += " + offsetX + " top += " + offsetY);  
        	obj.style.pixelLeft += offsetX; 
        	obj.style.pixelTop += offsetY; 
        } else {
    		X = obj.offsetLeft;
    		Y = obj.offsetTop; 
    		offsetX = objSrcPos.offsetLeft;
    		offsetY = objSrcPos.offsetTop; 
     		//alert("adjust " + name + " -> left += " + offsetX + " top += " + offsetY);  
        	obj.style.left = X + offsetX; 
        	obj.style.top = Y + offsetY; 
            //alert("adjust " + name + " -> left += " + obj.style.left + " top += " + obj.style.top); 
        } 
    } else {
    	obj=MM_findObj(name);
        objSrcPos = MM_findObj('navX');
        if(document.layers){
        	offsetX = document.navX.pageX;
        	offsetY = document.navX.pageY;
        	//alert("adjust " + name + " " + document.navX.name + " -> left += " + offsetX + " top += " + offsetY);  
        	obj.left += offsetX; 
        	obj.top += offsetY; 
        } else {
        	if(document.all){
        		offsetX = document.all.navX.offsetLeft;
        		offsetY = document.all.navX.offsetTop;
	        	//alert("adjust " + name + " -> left += " + offsetX + " top += " + offsetY);  
            	obj.style.pixelLeft += offsetX; 
            	obj.style.pixelTop += offsetY; 
            }
        }
    }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

var anzahlObj = 0;
function laden(name, erstes, zweites) {  
  if (browserOK) {     
    Bilder[anzahlObj] = new Array(3);
    Bilder[anzahlObj][0] = new Image();
    Bilder[anzahlObj][0].src = erstes;
    Bilder[anzahlObj][1] = new Image();
    Bilder[anzahlObj][1].src = zweites;
    Bilder[anzahlObj][2] = name;
    anzahlObj++;
  }
}

function an(name){
  if (browserOK) {
     for (i = 0; i < anzahlObj; i++) {
      if (document.images[Bilder[i][2]] != null)
        if (name != Bilder[i][2]) { 
          document.images[Bilder[i][2]].src = Bilder[i][0].src;
        } else {
          document.images[Bilder[i][2]].src = Bilder[i][1].src;
        }
    }
  }
}

function aus(){
  if (browserOK) {
     for (i = 0; i < anzahlObj; i++) {
      if (document.images[Bilder[i][2]] != null) 
        document.images[Bilder[i][2]].src = Bilder[i][0].src;
    }
  }
}
/*
function submitForm(cmdField, cmdValue)
{
    if (cmdField) {
        if (cmdValue) {
            document.forms['frmMain'].elements[cmdField].value=cmdValue;
        } else {
            document.forms['frmMain'].elements[cmdField].value=cmdValue;
        }
    }
    document.forms['frmMain'].submit();
}
*/
function submitForm(cmdField, cmdValue)
{
    if (cmdField) {
        if (cmdValue) {
            document.forms[0].elements[cmdField].value=cmdValue;
        } else {
            document.forms[0].elements[cmdField].value=cmdValue;
        }
    }
    document.forms[0].submit();
}


function selectEntry(lngID) {
    document.forms['frmSearch'].elements['strEntryID'].value=lngID;
}

function setSelection(lngID) {
    document.forms['frmSearch'].elements['strSelect'].value=lngID;
}

function selection(strURL, strName, strAnker){
	if(strName){
		var sIndex = document.forms[0].elements[strName].selectedIndex;
        if(sIndex >= 0){
  	var value = document.forms[0].elements[strName].options[sIndex].value;
            if(value != -1){
                if (strAnker) {
                	location.href = strURL + "&selected=" + value + "#" + strAnker;
                } else {            
                	location.href = strURL + "&selected=" + value;
                }
            }
        } else {
        	alert("Bitte wählen Sie erst ein Element aus");
        }
    }
}

function selectListeLand(){
	if(document.forms[0].chksort[1].checked){
    	document.forms[0].submit(); /*cmdSearch.click();*/
    } else {
    	if(document.forms[0].strLand.selectedIndex != 0){
        	document.forms[0].strLand.selectedIndex = 0;
        }
    }
}

function sendForm(strName,strSearchStr,strPostfix){
	var postFix = "";
    if(strPostfix){
    	postFix = strPostfix;
    }
    if (strSearchStr) { 
	    document.forms['frmSearch'].elements[strName+postFix].value=strSearchStr+'*';
    	var i = 0;
        var n = 0;
        var old = -1;
	    var strVars = "";
    	for(i = 0; i < document.forms['frmSearch'].elements.length; i++){
        	if(document.forms['frmSearch'].elements[i].type != "submit"){
            	if(n != old){
                	if(n == 0){
                    	strVars += "?";
                    } else {
                    	strVars += "&";
                    }
                    old = n;
                }
                if(document.forms['frmSearch'].elements[i].type == "checkbox" || document.forms['frmSearch'].elements[i].type == "radio"){
                	if(document.forms['frmSearch'].elements[i].checked){
    					strVars += document.forms['frmSearch'].elements[i].name + "=" + escape(document.forms['frmSearch'].elements[i].value);
                        n++;
                    }
                //alert(n + " Type: " + document.forms['frmSearch'].elements[i].type + "\nName: " + document.forms['frmSearch'].elements[i].name + "\nValue: " + document.forms['frmSearch'].elements[i].value + "\nChecked: " + document.forms['frmSearch'].elements[i].checked); 
                } else {
	    			strVars += document.forms['frmSearch'].elements[i].name + "=" + escape(document.forms['frmSearch'].elements[i].value);
                    n++;
                }
            }
    	}
        self.location.href="index.php" + strVars + "&cmdSearch" + postFix + "=Suchen";
        //document.forms['frmSearch'].elements['cmdSearch'+postFix].click();
    } else {
        document.frmSearch.submit();
    }
}

function checkAllBoxes(strName){
	var alle = 0;
    var boxCount = 0;
   	for(i = 0; i < document.forms[0].elements.length; i++){
       	if(document.forms[0].elements[i].type == "checkbox" && document.forms[0].elements[i].name.indexOf(strName) >= 0){
	    	if(document.forms[0].elements[i].value < 0){
            	return;
            }
        }
	}
   	for(i = 0; i < document.forms[0].elements.length; i++){
    	if(document.forms[0].elements[i].type == "checkbox" && document.forms[0].elements[i].name.indexOf(strName) >= 0){
        	if(document.forms[0].elements[i].checked){
            	alle++;
            }
        	document.forms[0].elements[i].checked = true;
            boxCount++;
        }
	}
    if(boxCount == alle){
	   	for(i = 0; i < document.forms[0].elements.length; i++){
    		if(document.forms[0].elements[i].type == "checkbox" && document.forms[0].elements[i].name.indexOf(strName) >= 0){
	        	document.forms[0].elements[i].checked = false;
    	    }
		}
    }
}

function confirmDelete(strText) {
    return confirm(strText);
}

function openPopup(theURL) {
	if(navigator.userAgent.indexOf("MSIE") < 0){ 
		wndPopup = window.open(theURL,'popup1','width=620,height520,locationbar=no,menubar=no,resizable=no,status=yes,scrollbars=yes');
    } else {
    	wndPopup = window.open(theURL,'popup1','width=640,height=540,locationbar=no,menubar=no,resizable=no,status=yes,scrollbars=yes');
    }
    if(wndPopup){
    	wndPopup.focus();
    }
}

function openInfoPopup(theURL) {
	if(navigator.userAgent.indexOf("MSIE") < 0){ 
		wndPopup = window.open(theURL,'popup1','width=480,height=580,locationbar=no,menubar=no,resizable=no,status=yes,scrollbars=yes');
    } else {
    	wndPopup = window.open(theURL,'popup1','width=500,height=600,locationbar=no,menubar=no,resizable=no,status=yes,scrollbars=yes');
    }
    if(wndPopup){
    	wndPopup.focus();
    }
}

function openFaxPopup(theURL) {
	if(navigator.userAgent.indexOf("MSIE") < 0){ 
		wndFaxPopup = window.open(theURL,'popup2','width=820,height=640,locationbar=no,menubar=no,resizable=no,status=yes,scrollbars=yes');
    } else {
    	wndFaxPopup = window.open(theURL,'popup2','width=840,height=640,locationbar=no,menubar=no,resizable=no,status=yes,scrollbars=yes');
    }
    if(wndFaxPopup){
    	wndFaxPopup.focus();
    }
}



function dosubmit(op, conf, param) {

	var submitit = true;
	if(conf) {
		submitit = window.confirm(conf);
	}
	if(param) {
		document.forms[0].param.value = param;
	}
	
	if(submitit) {
    	document.forms[0].operate.value = op;
		document.forms[0].submit();
	}
}

function showsubmenu(i) {
	if(i) {
		var submenu = document.getElementById("tnav2_"+i);
		submenu.style.visibility = 'visible';
		if(window.innerWidth) {
			scr = window.innerWidth;
		} else {
			scr = document.body.offsetWidth;
		}
		var pos = menpos[i]+(scr-996)/2;
		if(document.all) {
			pos-=10;
		}
		submenu.style.left = pos;
		oldi = i;
		ms = new Date().getTime();
	}
}

function switchsubmenu(i) {
	if(oldi) {
		var submenu_old = document.getElementById("tnav2_"+oldi);
		submenu_old.style.visibility = 'hidden';
	}
	showsubmenu(i);
}

function stayalive() {
	ms = new Date().getTime();
}

function restoresubmenu() {
	setTimeout("checkclose()",300);
}

function checkclose() {
	if(ms) {
		ms2 = new Date().getTime();
		if( (ms2-ms) >=1000) {
			switchsubmenu(seli);
		} else {
			restoresubmenu();
		}
	}
}

function open_publ_list() {
	var plist = document.getElementById("publ_list");
	if(plist) {
		plist.style.display = "block";
	}
}


function makepdf(filename) {
	seite = 'http://www.gtue-oldtimerservice.de/' + filename;
	window.open(seite,'popup1','width=640,height=480,locationbar=no,menubar=no,resizable=no,status=yes');
}

