//JavaScript - Copyright by mediaLINK - v5.3/03.12.2004
//-----browserAndSystem-setting in gendefs.js


//-----default-settings
//following if-query to prevent ev. location-attaches on netscape (to adjust, if location-attaches can contain slashes)
var filename = "";
if (self.location.href.indexOf("?") > -1){
        filename=self.location.href.substring(self.location.href.lastIndexOf("/")+1,self.location.href.lastIndexOf("?"));
}else{
        filename=self.location.href.substring(self.location.href.lastIndexOf("/")+1,self.location.href.length);
}

var rubric = filename.substring(0,2);
var sls = self.location.search.substring(1,self.location.search.length);
var filenameRef = "";
var rubricRef = "";
var frameLoad = false;

if (document.referrer){
        filenameRef = document.referrer.substring(document.referrer.lastIndexOf("/")+1,document.referrer.length);
        rubricRef = filenameRef.substring(0,2);
        //auto-crosslink-evaluation
        if ((self.name == "dsp") && (top.name == "main") && (rubric != rubricRef) && (filenameRef.indexOf('_') > -1)){
                frameLoad = true;
        }
}



//-----root-setting
framesetroot = "../pagesnav/frames.htm";



//-----frame-functions
if (self == top){
        if ((ns4) && (self.outerHeight==0) && (self.outerWidth==0)){
                //NS4 is printing and loads the document in an unvisible space as a single frame
        }else{
                wait=setTimeout("JavaScript:top.location.href=framesetroot",100);  //delay for Netscape
        }
}




//-----form functions-------------------------------------------------------------------
function search(){
        if (document.searchform.searchzip.value == "" && document.searchform.searchsupply.value == ""){
                alert(msgFormNoSearchEntry);
        }else{
                document.searchform.submit();
        }
}


function login(){
        if ((document.loginform.loginuser.value == "") || (document.loginform.loginpassword.value == "")){
                alert(msgFormInvalidLogin);
        }else{

                document.loginform.submitLogin.value='submitLogin';
                document.loginform.submit();
        }
}

function SendPassword(){
        if ((document.loginform.loginuser.value == "")){
                alert(msgFormInvalidSendPassword);
        }else{
                document.loginform.submitLogin.value='submitSendPassword';
                document.loginform.submit();
        }
}


function submitAdminSearch(){
                document.searchadmin.submit();
}


function register(){
        if ((document.loginform.registername.value == "") || (document.loginform.registersupply.value == "") || (document.loginform.registermail.value == "") || (document.loginform.registerphone.value == "")){
                alert(msgFormRequired);
        }else{
                document.loginform.submitRegister.value='submitRegister';
                document.loginform.submit();
        }
}


function save(){
        if ((document.inputsupply.wvgnameversorgung.value == "") || (document.inputsupply.wvgstrasse.value == "") || (document.inputsupply.wvgplz.value == "") || (document.inputsupply.wvgort.value == "") || (document.inputsupply.aspnachname.value == "") || (document.inputsupply.aspvorname.value == "") || (document.inputsupply.asptelefon.value == "") || (document.inputsupply.aspemail.value == "")){
                alert(msgFormRequired);
        }
        else{
                document.inputsupply.inputsupply_save.value = 'inputsupply_save';
                document.inputsupply.submit();
        }
}


function new_region(){
        if (document.inputsupply.wvgnameversorgung.value == ""){
                alert(msgFormRequired);
        }
        else{
                document.inputsupply.inputsupply_new_region.value = 'inputsupply_new_region';
                document.inputsupply.submit();
        }
}


function promotion(){
        if (document.inputsupply.wvgnameversorgung.value == ""){
                alert(msgFormRequired);
        }
        else{
                document.inputsupply.inputsupply_promotion.value = 'inputsupply_promotion';
                document.inputsupply.submit();
        }
}


function sendinput(){
        if ((document.inputdata.wrtkurzbezeichnung_gebiet.value == "") || ((document.getElementById("plz1").value == "") && (document.getElementById("plz2").value == ""))){
                alert(msgFormRequired);
        }else{
                document.inputdata.submit_inputdata.value = 'submit_inputdata';
                document.inputdata.submit();
        }
}


function sendpromotion(){
        if (document.uploadform.checkdisclaimer.checked == true){
                document.uploadform.submit_inputpromotion.value='submit_inputpromotion';
                document.uploadform.submit();
        }else{
                alert(msgFormCheckDisclaimer);
        }
}


function admin(){
                 document.adminresults.submit();

}


function close_session(){
                         document.inputsupply.inputsupply_close.value = 'inputsupply_close';
                         document.inputsupply.submit();
}




//----- edit functions ------------------------------------------------------------

function regionDelete(){
        alert(msgEditRegionDelete);
}



//----- various functions ---------------------------------------------------------

//print functions
function printdsp(){
        if ((self.print) || (ieX && WIN)){
                if (self.print){                        //NS4W/NS4.5M/NS6W/IE5W/Mozilla 1.21
                        if (self.focus){
                                top.dsp.focus();        //for E5W
                        }
                        top.dsp.print();
                }else{
                        printo();                                //IEXWin
                }
        }else{
                if ((ieX) && (MAC)){                //IE4/5Mac
                        alert(msgPrintingFailedE5M);
                }else{
                        alert(msgPrintingFailed);
                }
        }
}

function printo() {
        var OLECMDID_PRINT = 6;
        var OLECMDEXECOPT_DONTPROMPTUSER = 2;
        var OLECMDEXECOPT_PROMPTUSER = 1;
        var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
        document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
        oldHandler = window.onerror;
        window.onerror = deal;
        WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER);
        WebBrowser1.outerHTML = "";
        window.onerror = oldHandler;
}

function deal(){
        WebBrowser1.outerHTML = "";
        window.onerror = oldHandler;
        return true;
}


//bookmark-functions
function setBookmark(){
        var bookmarkurl = self.location.href;
        var bookmarktitle = document.title;
        if (window.external && noMAC){
        //if(document.all){
                window.external.AddFavorite(bookmarkurl,bookmarktitle);
        }else{
                alert(msgBookmarkingFailed);
        }
}


//others

function defocus(t){
        if (t.blur){t.blur()}
}