// JavaScript Document
function InitSpecoffers(type, city)
{

/*$("#specoffers_div").html("<iframe width=100  src='http://hotels.avelonbeta.ru/get_specoffers.php'></iframe>");*/

//alert(city);
  $.post("http://hotels.avelonbeta.ru/get_specoffers.php",
  {
    type: type,
    city: city
  },
  LoadSpecoffers)
}

function LoadSpecoffers(data)
{
  $("#specoffers_div").html(data);
  //$("#specoffers_div").html(toEntity(data));
  //$("#specoffers_div").html(decode_utf8(data));
}

function decode_utf8(utftext) {
             var plaintext = ""; var i=0; var c=c1=c2=0;
             // while-Schleife, weil einige Zeichen uebersprungen werden
             while(i<utftext.length)
                 {
                 c = utftext.charCodeAt(i);
                 if (c<128) {
                     plaintext += String.fromCharCode(c);
                    i++;}
                 else if((c>191) && (c<224)) {
                     c2 = utftext.charCodeAt(i+1);
                     plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
                     i+=2;}
                 else {
                     c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);                 plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));                    i+=3;}
                }            return plaintext;
        }
        
        
function toEntity(aa) {
 
 var bb = '';
 for(i=0; i<aa.length; i++)
 {
   if(aa.charCodeAt(i)>127)
   {
     bb += '&#' + aa.charCodeAt(i) + ';';
   }
   else
   {
     bb += aa.charAt(i);
   }
 }
 return bb;
} 