var countMails = 0;
var lng;

var forb = new Array("barcamp","info");

function getWholeMail(id,msg){
	 document.getElementById(id).style.display='block';
         document.getElementById('mailInhalt2').innerHTML = '<img src="images/19-0.gif" width="100" height="100">';
         $("#"+id).fadeTo("fast",0.4,function(){$("#mailInhalt").fadeIn("fast",function(){
           $("#mailInhalt2").load("read_"+lng+".php", {no: msg});
         ;});});
         }
         
function closeMail(id){
	 $("#mailInhalt").fadeOut("fast");
	 $("#"+id).fadeOut("fast");
         }

function killMail(s,u){
         yn = false;
         if(lng=="de"){
            yn = window.confirm("Mail ("+s+") wirklich "+unescape("l%F6schen")+" ?");
         }else{         
            yn = window.confirm("Really delete Mail ("+s+") ?");
            }

         addr = document.getElementById("mailAdr").value;
         if (yn) {
             $.ajax({
             type: "POST",
             url: "read_"+lng+".php",
             data: "kill="+u,
             success: function(msg){
                   $("#mailContent").load("test_"+lng+".php", {mail: addr,notify: 0},function(){;closeMail(document.getElementById('fader').value);});
                   }
               });

            }
         }
	 

function getMail(miniSymbol){
	
	addr = document.getElementById("mailAdr").value;
	myMsg = new Array();
	if(miniSymbol){
	   $("#p_check2").fadeIn("fast");
	   }
	
	$.ajax({
        type: "POST",
        url: "test_"+lng+".php",
        data: "mail="+addr+"&check=1",
        success: function(msg){
        myMsg = msg.split("|");
        if(miniSymbol){
           $("#p_check2").fadeOut("fast");
	   }
           if(Number(myMsg[0])>Number(countMails)){
              loadMailFenster(addr,(countMails>0)?myMsg[1]:"no");
              }
           else{
              window.setTimeout("getMail(true)",5000);
              }
           countMails = Number(myMsg[0]);
           }
         });
        }


function checkMail(l){
	 countMails = 0;
         lng = l;
         if(lng=="de"){
            window.prompt("Deine E-Mail zum kopieren in die Zwischenablage",document.getElementById("mailAdr").value+"@sapya.com");
         }else{         
            window.prompt("Your E-Mail to copy into the clipboard",document.getElementById("mailAdr").value+"@sapya.com");
            }
         //window.open("werbung_"+l+".html","Ads","width=468,height=90,left=100,top=200");
         checkMailGo();
         }

function checkMailOk(){
         window.setTimeout('checkMailGo()',1000);
         window.setTimeout('self.focus();',2000);
         }

function checkMailGo(){

         for(i=0;i<forb.length;i++){
	     if(forb[i] == document.getElementById("mailAdr").value){
	        $("#p_leer").fadeOut("fast",function(){$("#p_denied").fadeIn("fast");});
		return;
	        }
	     }


         $.ajax({
             type: "POST",
             url: "write.php",
             data: "m="+document.getElementById("mailAdr").value,
             success: function(msg){
                   $("#p_leer").fadeOut("fast",function(){$("#p_load").fadeIn("fast",function(){getMail(false);});});
                   }
               });
         }
         
function loadMailFenster(mailAdr,mehrAlsNull){
	 $("#mailContent").load("test_"+lng+".php", {mail: mailAdr,notify: mehrAlsNull},function(){if(mehrAlsNull){ window.setTimeout("getMail(true)",5000)};});	

	 }	
	 
function getPrefix(l){
 	 $.ajax({
         type: "GET",
         url: "names.php",
	 data: "l="+l,
         success: function(msg){
            document.getElementById("mailAdr").value = msg;      
            }
          });
	
	 }

function fixPNG(myImage) 
{
if (window.ie55up)
 {
  var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
  var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
  var imgTitle = (myImage.title) ? "title='" + myImage.title + "' " : "title='" + myImage.alt + "' "
  var imgStyle = "display:inline-block;" + myImage.style.cssText 
  var strNewHTML = "<span " + imgID + imgClass + imgTitle
  strNewHTML += " style=\"" + "width:" + myImage.width + "px; height:" + myImage.height + "px;" + imgStyle + ";"
  strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
  strNewHTML += "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>" 
  myImage.outerHTML = strNewHTML
  }
}

