$(document).ready(function(){
  $(document).pngFix();
  openComment(1);
  $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());
  if ($.browser.chrome)
  {
	$("#top_menu_bar").css("top","0px;");
	$("#mini-story").css("line-height", "2em;");
    $("#top_bar_message").css("width", "600px");
    $("#status-message li").css({"font-size":"14pt;","margin-top":"8px;"});
    //font-size: 14pt;
    
    
    
    var bWidth = $("body").width();
    if(bWidth > 1650)
    {
      $("#Table_01").css("left", "1px");
    }

  }
  
  var value = $('#top_bar_search_input').attr('value');
  if(value != ""){
    $("#top_bar_search_label").css("display", "none");
  }
//  $('iframe#iFrame-ads').attr({src: $('iframe#iFrame-ads').attr("src")});
});

function displayCheck(t)
{
    if((t*1)==1)
    {
      $("#tabs-2,#tabs-3").css({'display' : 'none', 'z-index' : '5'});
      $("#tabs-1").css({'display' : '', 'z-index' : '15'});
      loadVdo(1);
    }
    else if ((t*1)==2)
    {
      $("#tabs-1,#tabs-3").css({'display' : 'none', 'z-index' : '5'});
      $("#tabs-2").css({'display' : '', 'z-index' : '15'});
      loadVdo(2);
    }
    else if ((t*1)==3)
    {
      $("#tabs-1,#tabs-2").css({'display' : 'none', 'z-index' : '5'});
      $("#tabs-3").css({'display' : '', 'z-index' : '15'});
      loadVdo(1);
    }

}
function searchCss(x)
{
  if((x*1) == 1){
    $("#top_bar_search_label").css("display", "none");
  }
  else{
    var value = $('#top_bar_search_input').attr('value');
    if(value == "" || value == "none"){
      $("#top_bar_search_label").css("display", "");
    }
  }
}
function loadVdo(x)
{
  if((x*1) == 2)
  {
    $('#vdo-result').html('<div id="loading-image" style="position: absolute; left: 268px; top: 150px;"><img src="assets/asura_iyara/ajax_load.gif" width="40" height="40" alt="Loading..." /></div>')
        .delay(1500).fadeOut(0).queue(function(n) {
            $(this).html('<iframe id="iFrame-ads" name="iframe1" width="546" height="528" scrolling="no" src="asura_list.html" frameborder="0" allowtransparency="true" style="margin-left: -1em;"></iframe>');
            n();
        }).fadeIn(2000);
  }
  else $('#vdo-result').html('');
}

$.getJSON('http://www.asura.in.th/patcher.php/ads/ajax/message-ads', function(data) {
  $.each(data, function(index, value) 
  {
    if  (value.status == 'DOWN')
    {
      $("#status-message").append("<li class='black'>"+value.name+"  สถานะ :</li><li class='red'> ออฟไลน์ </li>");
    }
    else
    {
      $("#status-message").append("<li class='black'>"+value.name+"  สถานะ :</li><li class='green'> ออนไลน์ </li>");
    }
  });
});

function openComment(x){
  if((x*1) == 1){$('#facebook_comment_box_right').fadeIn(700);}
  else {
    $('#facebook_comment_box_right').fadeOut(700);
    $('#facebook_comment_box_right_comment_box').fadeIn(700);
  }
  return false;
}

function openTag(tag)
{
  //auto close
  var listTag=new Array("#register","#refill","#download");
  //var i=0;
  for (var i=0;i<3;i++) {
    if(tag != listTag[i]) {
      closeTag(listTag[i]);
      //break;
    }
  }

  var tagConvert = 'iframe#iframe-'+tag.substr(1);
  $(tagConvert).attr({
    src: $(tagConvert).attr("src")
  });
  
  $(tag).slideDown(1500,"easeOutExpo");
  $(tag).css({display: ""});
  return false;
}

function closeTag(tag)
{
  $(tag).slideUp(1300,"easeOutExpo");
  $(tag).css({display: "none"});
  return false;
}

function searchCss(x)
{
  if((x*1) == 1){
    $("#search-label").css("display", "none");
  }
  else{
    var value = $('#search_input').attr('value');
    if(value == "" || value == "none"){
      $("#search-label").css("display", "");
    }
  }
}


$(function() {
  $("#tabs").tabs();
});




//facebook
function resizeWindow()
{
//var b = $('#avatar-webpage-new-14_').innerWidth();
//c = (b-10)+'px';
//$('#avatar-webpage-new-14_ iframe').css("width", c);
}

window.fbAsyncInit = function() {
FB.init({appId: '157282437621814', status: true, cookie: true,xfbml: true});
FB.Event.subscribe('xfbml.render', resizeWindow);
};

(function()
{
 var e = document.createElement('script');
 e.async = true;
 e.src = document.location.protocol +
   '//connect.facebook.net/en_US/all.js';
 document.getElementById('fb-root').appendChild(e);
}());
//facebook

//google
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-8042742-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
//google
