var NS4 = (document.layers) ? 1 : 0;
var IE4 = (document.all) ? 1 : 0;
var DOM = (document.getElementById) ? 1 : 0;



function hideLoadMsg(){
	if(IE4){eval('document.all["divLoadMsg"].style.visibility="hidden"');}
		else if(NS4){eval('document.layers["divLoadMsg"].visibility="hide"');}
		else {eval('document.getElementById("divLoadMsg").style.visibility="hidden"');}

	/*if(IE4 || NS4){
		if(NS4) document.divLoadMsg.visibility="hidden"
		else divLoadMsg.style.visibility="hidden"
	}*/
}

function aoprAktion()
{
	if(document.prop.aktion.options[document.prop.aktion.options.selectedIndex].value == "none")
	{
		alert("Bitte wählen Sie eine Aktion.");
		return;
	}else if(document.prop.aktion.options[document.prop.aktion.options.selectedIndex].value == "pdp")
	{
		sure = confirm("Wollen Sie das gewählte Produkt wirklich löschen?");
    	if(sure == false)return;
	}

	document.prop.ta.value='aoprakt';
	document.prop.submit();
}


function newMaWindow(url){
    //url = (NS4)?("rech/"+url):url;
	mawin = open(url,"MaFe","left=30,top=30,width=650,height=600,scrollbars");
    mawin.focus();}

function newHelpWindow(url){
    //url = (NS4)?("rech/"+url):url;
	helpwin = open(url,"HelpFe","left=30,top=30,width=400,height=500");
    helpwin.focus();}

function newHelpWindowDev(url){
    //url = (NS4)?("rech/"+url):url;
	helpwin = open(url,"HelpFe","left=30,top=30,width=400,height=500,scrollbars");
    helpwin.focus();}

function newHelpCfgWindow(url){
    //url = (NS4)?("rech/"+url):url;
	helpwin = open(url,"HelpFe","left=30,top=30,width=400,height=500,scrollbars");
    helpwin.focus();}

function newHeWindow(url){
    //url = (NS4)?("rech/"+url):url;
	he = open(url,"HeFe","width=600,height=450,scrollbars");
    he.focus();}

function runResetSubmit(){
    document.mainc.reset.value=1;
    document.mainc.submit();
    return;}

function changeTableBG(id,bgclass){
 	eval("document.all.bg"+id).className = bgclass;
}

function newVPropWindow(url){
	 //url = (NS4)?("rech/"+url):url;
 	 vpropw = open(url,"vpropw","width=300,height=600,scrollbars");
 	 vpropw.focus();}

function updateVPropWindow(url){
    //url = (NS4)?("rech/"+url):url;
    vpropw = open(url,"vpropw","width=300,height=650,scrollbars");}

function runSubmit(wert){
	 document.prop.subtree.value = wert;
	 document.prop.submit();
	 return;}

function printit(){
    var NS = (navigator.appName == "Netscape");
    var VERSION = parseInt(navigator.appVersion);
    if (NS && VERSION>3)
	{
        window.print() ;
	}
	else
	{
        var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
        document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
        WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";
	}}

function sort(sortorder){
 	document.prop.sort.value=sortorder;
	document.prop.submit();}


function updateParentWindow(url){
	opener.location.href=url;}


function setYPos(){
    if (window.pageYOffset)document.prop.ypos.value = window.pageYOffset;
   	else if (document.body && document.body.scrollTop) document.prop.ypos.value=document.body.scrollTop;
	if(document.prop.ypos.value < 100)document.prop.ypos.value=0;}

//Herstelleranfrage

function docSubmit(){
    setYPos();
    document.prop.submit();
    return;}

function docNLSubmit(loc){
    setYPos();
    document.prop.action = loc;
    document.prop.submit();
    return;}

function docScSubmit(sc){
    setYPos();
    document.prop.sc.value=sc;
    document.prop.submit();
    return;}

function docRedSubmit(sc, propid){
    setYPos()
    document.prop.redsc.value=sc;
	document.prop.redid.value=propid;
    document.prop.submit();
    return;}

//Akqui

function checkFlag(pkma){
    document.prop.stat.value = "enable";
    document.prop.pdid.value=pkma;
    document.prop.submit();
    return;}


function safetyCheck(mess,pkma,sid,pdtype){
    sure = confirm(mess);
    if(sure == true) window.location.href = "arc.php?SID="+sid+"&from=aopr&stat=del&pdid=" +pkma+"&pdtype="+pdtype;
    else window.location.href = "#";}

function validat(tb,curLang)
{
    if(tb.value != null && tb.value != "")
	{
        test_value=tb.value;
        test_value=test_value.replace(/[ ]+/,"");
        test_value=test_value.replace(/[a-zA-Z]+/,"");
        test_value=test_value.replace(/[,]+/,".");
        test_value=test_value.replace(/[.]+/,".");
        test_value=test_value.match(/[\d]*\.*[\d+]+/);

        if(test_value != null) tb.value=test_value;
        else
		{
			if(curLang=='d') alert("Syntaxfehler !\nGeben Sie bitte einen Zahlenwert ein !");
			else alert("Syntax error !\nPlease enter a numerical value !");
            tb.value="";
            tb.focus();
		}
	}
}

function check(form){
    if(!(form.ma_name.value.length > 0)){
        alert("Missing machine name !");

        form.ma_name.focus();
        return (false);}
    return(true);}

function changeLang(t,l){
    document.prop.ta.value = t;
    document.prop.lang.value = l;
    document.prop.submit();
    return;}


function cancelAkqui(t,p){
    document.prop.ta.value = t;
	document.prop.bpage.value = p;
    document.prop.submit();
    return;}

function changeLocation(ta){
	 document.prop.ta.value = ta;
	 document.prop.submit();
	 return;}

function changeAkquiView(ta,cu){
	 document.prop.ta.value = ta;
	 document.prop.curr_prop.value = cu;
	 document.prop.submit();
	 return;}

// ProFi: Akquise ... Verbundaufbau
function LayerWindow(url)
{
	layerwin = open(url,"Schichten","left="+(screen.width-430)+",top=30,width=400,height=480,scrollbars,status=yes");
	layerwin.focus();
}

// ProFi: Akquise ... Submit-Funktionen

function runPMDataSubmit(act,mess)
{
	var errcode = 0;
	if(document.prop.grpname.value.length < 1) errcode += 1;
	if(document.prop.grpname_e.value.length < 1) errcode += 2;
	if((typeof document.prop.zka_id.value) == "undefined") errcode += 4;
	if((typeof document.prop.ps_id.value) == "undefined") errcode += 8;

	if(errcode > 0)
	{
		document.prop.ta.value = 'aapm';
		document.prop.errcode.value = errcode;
	}
	else document.prop.ta.value = 'aahf';
	document.prop.action = act;
	document.prop.submit();
}

function runPMSubmit(act)
{
	document.prop.action = act;
	document.prop.submit();
}

/* sj: alte (einsprachige) Version *
// ProFi: Akquise ... Submit-Funktion
function transferData(idLayer,strLayer)
{
//  opener.document.modprodgrppage1.currLayerID.value = idLayer;
  opener.document.prop.layerNameD.value = strLayer;
  self.close();
  opener.document.prop.submit();
}
**/

/* sj: neue (mehrsprachige) Version */
// ProFi: Akquise ... Submit-Funktion
function transferData(idLayer,strLayer_d,strLayer_e)
{
  opener.document.prop.layerNameD.value = strLayer_d;
  opener.document.prop.layerNameE.value = strLayer_e;
  self.close();
  opener.document.prop.submit();
}
/**/

// ProFi/PaFi: Akquise ... Ansprechpartner hinzufuegen/aendern
function checkAP(mess)
{
	if(document.aukp.apname.value.length < 1 ||
	   document.aukp.apbereich.value.length < 1 ||
	   document.aukp.apemail.value.length < 1)
	{
		alert(mess);
		document.aukp.apname.focus();
		document.aukp.changeit.value=0;
		return false;
	}
	return true;
}

function runKpSubmit(what,mess)
{
	switch(what)
	{
		case 'n':	if(checkAP(mess))
					{ // neuer Ansprechpartner
						document.aukp.new_contact.value = 1;
						document.aukp.submit();
					}
					break;
		case 'c':	if(checkAP(mess))
					{ // Ansprechpartner aendern
						document.aukp.chg_contact.value = 1;
						document.aukp.submit();
					}
					break;
		case 'd':	sure = confirm(mess); // Sicherheitsabfrage vor dem Loeschen eines Ansprechpartners
					if(sure == true) document.aukp.del.value=1;
					else document.aukp.del.value=0;
					document.aukp.submit();
					break;
	}
}

// ProFi/PaFi: Akquise ... Sicherheitsabfrage vor dem Loeschen eines Ansprechpartners
function getSureDelAP(mess)
{
	sure = confirm(mess);
    if(sure == true) document.aukp.del.value=1;
	else document.aukp.del.value=0;
}


//test

function inLayerList()
{
	//alert(document.prop.compositeLayers.options[document.prop.compositeLayers.length]);
	NeuerEintrag = new Option(document.prop.layerName.value,document.prop.layerName.value,false,true);
	document.prop.compositeLayers.options[document.prop.compositeLayers.length]=NeuerEintrag;

}

function APWindow(url)
{
	apwin = open(url,"APDaten","width=450,height=180,scrollbars");
	apwin.focus();
}

function noteWindow(url)
{
	nbwin = open(url,"notebook","width=700,height=450,status=yes,scrollbars");
    nbwin.focus();
}

function updateWin()
{
	opener.location.reload();
}

function nextPdClass(jskeys)
{
	document.nextPdClass.keys.value=jskeys;
	document.nextPdClass.submit();
	return;
}