function blocking(nr,show,kind){
         if(document.layers){
                 current=(show==1) ? 'block':'none';
                 current=(show==1&&kind!=undefined) ? kind:current;document.layers[nr].display=current;
         }
         else if(document.all){
                 current=(show==1) ? 'block':'none';
                 current=(show==1&&kind!=undefined)?kind:current;document.all[nr].style.display=current;
         }
         else if(document.getElementById){
                 vista=(show==1)?'block':'none';
                 vista=(show==1&&kind!=undefined)?kind:vista;document.getElementById(nr).style.display=vista;
         }
}
function visi(nr,show){
         if(document.layers){
                 vista=(show==1)?'show':'hide';
                 document.layers[nr].visibility=vista;
         }
         else if(document.all){
                 vista=(show==1)?'visible':'hidden';
                 document.all[nr].style.visibility=vista;
         }
         else if(document.getElementById){
                 vista=(show==1)?'visible':'hidden';
                 document.getElementById(nr).style.visibility=vista
         }
}
function str_replace(search,replace,subject,count){
         var i=0,j=0,temp='',repl='',sl=0,fl=0,f=[].concat(search),r=[].concat(replace),s=subject,ra=r instanceof Array,sa=s instanceof Array;s=[].concat(s);
         if(count){
                 this.window[count]=0;
         }
         for(i=0,sl=s.length;i<sl;i++){
                 if(s[i]===''){
                         continue;
                 }
                 for(j=0,fl=f.length;j<fl;j++){
                         temp=s[i]+'';
                         repl=ra?(r[j]!==undefined?r[j]:''):r[0];s[i]=(temp).split(f[j]).join(repl);
                         if(count&&s[i]!==temp){
                                 this.window[count]+=(temp.length-s[i].length)/f[j].length;
                         }
                 }
         }
         return sa?s:s[0];
}
function makeattribut(name,wert,element){
         var att='';
         var ele='';
         att=document.createAttribute(name);
         att.nodeValue=wert;
         ele=document.getElementById(element);
         ele.setAttributeNode(att);
}
function changeposition_x(nr,left){
         var x=left;
         document.getElementById(nr).style.left=x;
}
function changeposition_y(nr,top){
         var y=top;document.getElementById(nr).style.top=y;
}
var box='box';
function createbox(titel,inhalt){
         document.getElementById('box').innerHTML='<table cellspacing="0" cellpadding="0" border="0"><tr><td width="350" height="36" valign="bottom" background="/images/box_oben.gif"><center><table width="330" cellspacing="0" cellpadding="0" border="0"><tr><td><h4 style="border-bottom:0px;">'+titel+'</h4></td></tr></table></center></td></tr><tr><td background="/images/box_mitte.gif"><center><table width="350" cellspacing="0" cellpadding="0" border="0"><tr><td><ul>'+inhalt+'</ul></td></tr></table></center></td></tr><tr><td><img src="/images/box_unten.gif" width="350" height="34"></td></tr></table>';
}
function urlencode (str) {
    str = (str+'').toString();
    return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
}
//Ajax
var req = null;
function ajaxstart() {
         try{
                 req = new XMLHttpRequest();
         }
         catch(ms){
                 try{
                         req = new ActiveXObject("Msxml2.XMLHTTP");
                 }
                 catch(nonms){
                         try{
                                 req = new ActiveXObject("Microsoft.XMLHTTP");
                         }
                         catch(failed){
                                 req = null;
                         }
                 }
         }
         if(req == null)
                 alert("Ajax-Fehler");
}
function ajaxhandler(method, get, send){
         ajaxstart();
        if(method == "get")
                 req.open("GET", "/ajax.php?" + get, true);
         else
                 req.open("POST", "/ajax.php?"+ get, true)
         req.onreadystatechange = function(){
                 if(req.readyState == 4){
                         if(req.status == 200){
                                 eval(req.responseText);
                         }
                         /*else{
                                 alert('Ajax-Status-Fehler: ' + req.status);
                         }*/
                }
                 /*else{
                         alert('Ajax-Open-Fehler');
                 }*/
         }
         req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
         req.send(send);
}
function setcookie(name, value, expires, path, domain, secure ){
         var today = new Date();
         today.setTime( today.getTime() );

         if ( expires ){
                 expires = expires * 1000;
         }
         var expires_date = new Date( today.getTime() + (expires) );

         document.cookie = name + "=" +escape( value ) + ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + ( ( path ) ? ";path=" + path : "" ) + ( ( domain ) ? ";domain=" + domain : "" ) + ( ( secure ) ? ";secure" : "" );
}

function add_ean(pid,shopid,table,modul,id){
         document.getElementById('savebutton'+id).innerHTML='<img src="/images/loading3.gif" />';
         ajaxhandler('post','action=add_ean','id='+id+'&pid='+pid+'&shopid='+shopid+'&table='+table+'&modul='+modul+'&cache='+modul+'_'+pid+'.txt&ean='+document.getElementById('ean'+id).value);
         document.getElementById('ean'+id).disabled=true;
}
var tabs_active = false; // Vorsichtsmaßnahme für verschwindende Tabs...
function edit_search_words(pid){
         if(confirm('Sollen die Search-Words wirklich so gespeichert werden?')){
                 document.getElementById('savebutton').innerHTML='<img src="/images/loading3.gif" />';
                 ajaxhandler('post','action=edit_search_words','pid=' + pid + '&search_words=' + urlencode(document.getElementById('search_words').value));
                 document.getElementById('search_words').disabled=true;
         }
}
