//<script language="JavaScript">
 var guest=true;
 var info='';

 function show_wait(){
   info='wait';
   var out='<div id="wait"><table width="100%" border="0" cellspacing="0" cellpadding="0" align="center"> <tr><td width="40%"></td><td style="background-color:#ffffff" valign="center" align="center">Загрузка...</td><td width="40%"><img src="/images/1x1.gif" width="1" height="80"></td></tr></table></div>';
   into('info',out);
   show_hide('curtain',1);
   show_hide('info',1);
  }
  
 function into(id,text,show){
   if(!document.getElementById(id)) return false;
   document.getElementById(id).innerHTML=text;
   if (show==1) document.getElementById(id).style.display='';
   if (show==0) document.getElementById(id).style.display='none';
  }

 function into_add(id,text){
   if(!document.getElementById(id)) return false;
   document.getElementById(id).innerHTML+=text;
  }

 function show_hide(id,show){
   if(!document.getElementById(id)) return false;
   document.getElementById(id).style.display=(show!=0)?'':'none';
  }
  
 function str_replace(search, replace, subject) {
    return subject.split(search).join(replace);
  }
 
 
 //~ var timeout = setTimeout('doload();', 3000);
 data_class=function(type){
   this.disabled=false;
   this.perm_data=new Array();
   this.perm_data['type']=type;
   this.data=new Array();
   
   this.timout=null;
   this.auto_load=new Array();
   this.auto_load.time=0;
   
   this.doload=function(){
     for(key in this.perm_data){
       this.data[key]=this.perm_data[key];
      }
     //~ alert(dump(this.data));
     if (this.timeout) clearTimeout(this.timeout);
     // Create new JsHttpRequest object.
     if (!this.disabled){
       this.disabled=true;
       var req = new JsHttpRequest(this);
       // Code automatically called on load finishing.
       req.onreadystatechange = function(p){
         if (req.readyState == 4){
           if(req.responseJS){
             if(req.responseText!=''){
               alert(req.responseText);
              }
             if (req.responseJS.doit!=''){
               eval(req.responseJS.doit);
              }
            }
           p.disabled=false;
           if(p.auto_load.time>0){
             p.timeout = setTimeout(p.auto_load.handler,p.auto_load.time);
            }
          }
        }
       req.open('POST', '/index.php?act=dl_data', true);
       req.send(this.data);
       this.data=new Array();
      }
    }
   
   this.send_action=function(action,id){
     if (id) this.set_data('id',id);
     if (this.timeout) clearTimeout(this.timeout);
     this.set_data('action',action);
     //~ alert(dump(this.data));
     this.doload();
    }
   
   
   this.set_data=function(name,value){
     this.data[name]=value;
    }
    
   this.set_perm_data=function(name,value){
     this.perm_data[name]=value;
    }
    
   this.set_handler=function(handler,time){
     this.auto_load.handler=handler;
     if(time) this.set_time(time);
    }
    
   this.set_time=function(time){
     this.auto_load.time=time;
    }
    
  }
  
 function getMimeType()  {
    var mimeType = "application/x-mplayer2"; //default
    var agt=navigator.userAgent.toLowerCase();
    if (navigator.mimeTypes && agt.indexOf("windows")==-1) {
       //non-IE, no-Windows
       var plugin=navigator.mimeTypes["audio/mpeg"].enabledPlugin;
       if (plugin) mimeType="audio/mpeg" //Mac/Safari & Linux/FFox
    }//end no-Windows
    return mimeType;
  }

 function play_sound(wav_file){
   var player = document.getElementById("player");
   if (player){
     player.parentNode.removeChild(player);
    }
   player = document.body.appendChild(document.createElement("div"));
   player.innerHTML = "<embed src='sounds/"+wav_file+"' autostart='true' loop='false' height='0px' width='0px' type='"+getMimeType()+"'></embed>";
  }
 
 function city(id){
   if(id!=0){
     for(g=1; g<=8; g++){
       show_hide('city_1_img_'+g,(id==g)?1:0);
      }
    }
   show_hide('city_images',id);
  }

 function dump(d,l){
   if (l == null) l = 1;
   var s = '';
   if (typeof(d) == "object") {
     s += typeof(d) + " {\n";
     for (var k in d){
       for (var i=0; i<l; i++) s += "  ";
         s += k+": " + dump(d[k],l+1);
      }
     for (var i=0; i<l-1; i++) s += "  ";
       s += "}\n"
    }
   else{
     s += "" + d + "\n";
    }
   return s;
  }

 var arVersion = navigator.appVersion.split("MSIE")
 var version = parseFloat(arVersion[1])
 function fix_png(image) {
   if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
   var imgID = (image.id) ? "id='" + image.id + "' " : ""
   var imgClass = (image.className) ? "class='" + image.className + "' " : ""
   var imgTitle = (image.title) ? "title='" + image.title + "' " : "title='" + image.alt + "' "
   var imgStyle = "display:inline-block;" + image.style.cssText
   var strNewHTML = "<span " + imgID + imgClass + imgTitle
+ " style=\"" + "width:" + image.width + "px; height:" + image.height + "px;" + imgStyle + ";"
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+ "(src=\'" + image.src + "\', sizingMethod='scale');\"></span>"
image.outerHTML = strNewHTML	
  }
}

/*
$(function () { // make this code initialize when DOM loads
	$('form').submit(function () { // optional: replace "form" with whatever CSS selector you want (ex: ID or class)
		$('input[type="submit"]', this).replaceWith('<strong>Sending...</strong>'); // optional: change "Sending..." to something else
	});
});

*/

//</script>
