var sw=screen.width;
var aw=screen.availWidth;
var ah=screen.availHeight;

if(/MSIE/.test(navigator.userAgent) || /Firefox/.test(navigator.userAgent)){
        var xH=document.documentElement.clientHeight;
        var xW=document.documentElement.clientWidth;
}else{
        var xH=document.body.clientHeight;
        var xW=document.body.clientWidth;
}

var jsHost=self.location.hostname;

//-------        HOME
function home(){self.location.href=jsHost}

if(document.getElementById('hd')){
        var d=document.getElementById('hd');
        d.style.cursor='pointer';
        d.onclick=home;
}

//-------        PopUp Fenster Url,Width,Height,Parameters        ------------------------

function popUp(){
        var adr=(popUp.arguments[0])? popUp.arguments[0] : false;
        var w=(popUp.arguments[1])? popUp.arguments[1] : false;
        var h=(popUp.arguments[2])? popUp.arguments[2] : false;
        var p=(popUp.arguments[3])? popUp.arguments[3] : false;
        arg  = (w != false) ? "width="+ w +"," : "";
        arg += (h != false) ? "height="+ h +"," : "";
        arg += (w != false) ? "left="+ (screen.width-w)/2 +"," : "";
        arg += (h != false) ? "top="+ (screen.height-h)/2 +"," : "";
        arg += (p != false) ? ","+ p +"" : "";
        if(adr){
                win=window.open(adr,'_blank',arg);
        }else{
                return false;
        }
}

//-------        Events return Xpos and Ypos        ----------------------------------------

if(document.getElementById){
        function mH(e){
                 Xpos = (e) ? e.pageX : document.body.scrollLeft+event.x;
                 Ypos = (e) ? e.pageY : document.body.scrollTop+event.y;
        }
        window.document.onload=mH;
        document.onmousemove = mH;
}

//-------        CATALOG BRANDS        --------------------------------------------------------

function showCatalogMenu(){//        Google friendly

        if(document.getElementById('catalogMenu')){
        var td= document.getElementById('catalogMenu');

                td.style.visibility='visible';
                td.onmouseover=clearCatalogMenuTimer;
                td.onmouseout=setCatalogMenuTimer;
                clearCatalogMenuTimer();
        }
}

function hideCatalogMenu(){
        document.getElementById('catalogMenu').style.visibility='hidden';
}

function setCatalogMenuTimer(){
        ert=setTimeout("hideCatalogMenu()",2000)
}

function clearCatalogMenuTimer(){
        if(window.ert){
                clearTimeout(ert)
        }
}






//--------        SWAP IMAGE        -----------------------------------------------------------



function swapImage(src,id){
         if(document.getElementById(id)){
                 var d=document.getElementById(id);
                 d.src=src;
        }
}



//-------        Checking AGB´s          IF SHOP only --------------------------------------------------------

function sendOrder(){
        if(!document.form.agb.checked){
                document.form.agb.focus();
                alert("Sie müssen noch unseren AGBs zustimmen");
                return false;
        }else{
                document.form.submit()
        }
}




//----------------        TICKER                IF TICKER only        ---------------------------------






        function getCookie(name){
           var i=0
           var suche = name+"="
           while (i<document.cookie.length){
              if (document.cookie.substring(i, i+suche.length)==suche){
                 var ende = document.cookie.indexOf(";", i+suche.length)
                 ende = (ende>-1) ? ende : document.cookie.length
                 var cook = document.cookie.substring(i+suche.length, ende)
                 return unescape(cook)
              }
              i++
           }
           return null
        }
        function setCookie(name, wert){
           var cook = name+"=" + unescape(wert)
           document.cookie = cook
        }

        function playTicker(){

                 if(stat==0){
                         speed=0;
                         stat=1;
                         setCookie("speed","0");
                         setCookie("stat","1");
                         setCookie("pos",pos);
                 }else{
                         speed=1.8;
                         stat=0;
                         setCookie("speed","1.8");
                         setCookie("stat","0");
                         setCookie("pos",pos);
                 }
        }


if(document.getElementById('ticker')){

        var expTime,speed,stat,pos,ablauf = new Date();
        var inTwoH = ablauf.getTime() + (3000);
        ablauf.setTime(inTwoH);
        expTime=ablauf.toGMTString();
        stat=0;
        speed=1.8;
        pos=textWidth=document.getElementById('ticker').offsetWidth

        if(document.cookie){
                 if(getCookie("stat") !== null){
                         stat=getCookie("stat")
                         speed=parseFloat(getCookie("speed"))
                         pos=parseInt(getCookie("pos"))

                 }else{

                         setCookie("stat","0");
                         setCookie("speed","1.8");
                         setCookie("pos",pos)

                 }
        }
        pos=parseInt(pos);

        function moveTicker(){
                 if(document.getElementById){
                         document.getElementById("ticker").style.left = pos + 'px';
                 }
                 pos-=speed;
                 if(pos < -textWidth){
                         pos=textWidth;
                 }
                 var tmr=setTimeout("moveTicker()", 20);
        }
}













//--------------------------------------------------------------------------------------------


function go_to(url){self.location.href=url;}
function home(){self.location.href='http://'+ jsHost;}
function abmelden(z){
        if(confirm('Abmelden?')){
        if(z==0){
                self.location.href='http://'+jsHost+'/plugins/forms/kunden/overview.php?abmelden';
        }else if(confirm('Vorsicht, beim abmelden wird ihr Warenkorb geleert.')){
                self.location.href='http://'+jsHost+'/plugins/forms/kunden/overview.php?abmelden';
        }
        }
}
function agbs(){
        popUp("http://"+jsHost+"/?AGB",800,600,'scrollbars,toolbar,resizable');
}
//-------        Disable Right click

if(jsHost !=="127.0.0.1"){
        function clickIE4(){
                if (event.button==2){return false;}
        }
        function clickNS4(e){
                if (document.layers||document.getElementById&&!document.all){
                        if (e.which==2||e.which==3){return false;}
                }
        }
        if (document.layers){
                document.captureEvents(Event.MOUSEDOWN);
                document.onmousedown=clickNS4;
         }else if (document.all&&!document.getElementById){
                document.onmousedown=clickIE4;
        }
        //document.oncontextmenu=new Function("return false");
}


//-------------------        SHOP ARTIKEL IMAGES


function openImageGallery(arg1,arg2){

        if(document.getElementById('artikelImage')){
                var d=document.getElementById('artikelImage');
                w=window.open('http://'+jsHost+'/shop/artikel_images.php?imgCR='+d.src+'&imgDIR='+arg1+'&imgNAME='+arg2+'','_blank','width=100,height=100,resizable');
        }

}

function mTim(){
        if(document.getElementById('logout')){
                 var logout=document.getElementById('logout');
                 logout.style.visibility='visible';
                 logout.innerHTML='Login gültig noch: ';
                 if(tm>0){tm--}else{
                         self.location.reload();
                 }
                 var sec = tm;
                 var ho = Math.floor(sec/3600);
                 var min = Math.floor((sec - (ho * 3600))/60);
                 sec = (sec-(ho*3600))%60;
                 ho=ho.toString()
                 min=min.toString()
                 sec=sec.toString()

                 ho=ho.length==1?"0"+ho:ho;
                 min=min.length==1?"0"+min:min;
                 sec=sec.length==1?"0"+sec:sec;
                 logout.innerHTML +=ho+":"+min+":"+sec;
                 window.setTimeout('mTim()',1000)
        }
}