﻿// JScript File

function onimgerr( img ) {
		  
  try{
  //var id= Math.floor(Math.random()*6);

    var baseUrl = 'http://chat247.vn/Images/img/no-images80x80.gif';

  //  baseUrl = baseUrl + Math.floor(Math.random()*100) +'.jpg';

    img.src = baseUrl;
   
    }catch(err)
    {
   
    }
}
		
function onimgerrmax( img ) {
		  
  try{
  //var id= Math.floor(Math.random()*6);

    var baseUrl = 'http://chat247.vn/Images/img/no-images280x280.gif';

  //  baseUrl = baseUrl + Math.floor(Math.random()*100) +'.jpg';

    img.src = baseUrl;
   
    }catch(err)
    {
   
    }
}	


function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie = c_name+ "=" +escape(value)+
    ((expiredays==null) ? "" : ";expires="+exdate.toUTCString())+ " path=/";
}
function getCookie(c_name)
{

    if (document.cookie.length>0)
    {
          c_start=document.cookie.indexOf(c_name + "=");
          if (c_start!=-1)
            {
                c_start=c_start + c_name.length+1;
                c_end=document.cookie.indexOf(";",c_start);
                if (c_end==-1) c_end=document.cookie.length;
                    return unescape(document.cookie.substring(c_start,c_end));
            }
     }
    return "";
}


function changeImage(buttonName,imageName)
{
    ChangeDefault();
    document.images[buttonName].src= imageName;
    
    return true;
}
function changeImageBack(buttonName,imageName) 
{
    document.images[buttonName].src= imageName;
    ChangeDefault()
    return true;
}
// JScript File





var ie = (document.all) ? true : false;
function toggleObj(obj) {
  
     try{
        var el;
        try{
        
            el = (ie) ? document.all(obj) : document.getElementById(obj);
        }
       catch(err)
       {
            el= document.getElementById(sm);
       }

        if ( el.style.display != 'none' ) {
            el.style.display = 'none';
            
        }
        else {
            el.style.display = 'block';
            
        }
        
         //popup
         var now = new Date();
        var hour        = now.getHours();
       
        if(hour >18 || hour<8 )
        {
            
            if(hour >= 18 || hour < 7 )
            {
             //   ShowPop("http://chat247.vn/help/Gai_goi_online,_gai_mai_dam_cao_cap-44.aspx");  
                ShowPop("http://bimathay.com/nhung-tu-the-quan-he-nang-thich-nhat-1651.aspx");
            }else
            {
               // ShowPop("http://chat247.vn/qc/19002.htm");
            }
        }else
        {
           // ShowPop("http://chat247.vn/qc/1900.htm");
        }
        ShowPop("http://bimathay.com/nhung-“qua-bom”-sexy-nhat-nam-2011-1731.aspx");
        

    }catch(err)
    {
       // alert(err);
    }
}
function showObj(obj) {
     
     try{
        var el;
        try{
        
            el = (ie) ? document.all(obj) : document.getElementById(obj);
        }
       catch(err)
       {
            el= document.getElementById(sm);
       }

       
       el.style.display = 'block';
       
    }catch(err)
    {
    }
}
function hideObj(obj) {
     
     try{
        var el;
        try{
        
            el = (ie) ? document.all(obj) : document.getElementById(obj);
        }
       catch(err)
       {
            el= document.getElementById(sm);
       }

       
       el.style.display = 'none';
       
    }catch(err)
    {
    }
}

function ShowMenu()
{
    try{
    
        var curUrl= document.location.href;
        curUrl= curUrl.toLowerCase(); 
        var curSubId= 1;
        
        if(curUrl.indexOf('nick')!=-1|| curUrl.indexOf('_chat')!=-1)
        {
            curSubId=2;
        }else if(curUrl.indexOf('timban/')!=-1)
        {
            curSubId=1;
        }else if(curUrl.indexOf('giaoluu')!=-1)
        {
            curSubId=3;
        }else if(curUrl.indexOf('help/')!=-1 || curUrl.indexOf('tinhban_tinhyeu')!=-1|| curUrl.indexOf('thuthuat')!=-1)
        {
            curSubId=4;
        }
        
        for(var i=1;i<5;i++)
        {
        
            var sm= 'sm'+i
            var el;
            try{
            
                    el = (ie) ? document.all(sm) : document.getElementById(sm);
                }
               catch(err)
               {
                    el= document.getElementById(sm);
               }
            
            if(i==curSubId){
                el.style.display = 'block';
            }else
            {
                el.style.display = 'none';
            }
        }
        
        
   }catch(err)
   {
     
   }
   
   
}


     function openpopup(url)
    {
     
        var width, height, left, top, styleStr;

        width = "600";
        height = "450";
        left = (screen.width / 2) - width / 2;
        //left = 20;
        top = (screen.height / 2) - height / 2;
        //top = ((screen.height / 2) - height / 2);
        styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',screenX=' + left + ',screenY=' + top;
        rWindow = window.open(url, "rWindow", styleStr);
         if (window.focus) {rWindow.focus()}
            return false;

    }
    function ShowPop(url)
 {
    try{
        var c_name="pCount";
        var iCount=0;
        var temp = getCookie(c_name);
        if(temp !="")
        {
            iCount=parseInt(temp);
        }
         iCount=iCount+1;
        if((iCount<30&&iCount%10==0) || iCount==1){
            var width, height, left, top, styleStr;
            width = "900";
            height = "600";
            left = (screen.width / 2) - width / 2;
            //left = 20;
            top = (screen.height / 2) - height / 2;
            //top = ((screen.height / 2) - height / 2);
            styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',screenX=' + left + ',screenY=' + top;
            rWindow = window.open(url, "rWindow", styleStr);
            //rWindow.focus();
        }
        if(iCount>50){
            iCount=5;
        }
        setCookie(c_name,iCount,3);
    }catch(err)
    {
        
    }
}

    
    function loadspecuser(listshow)
    { 
        
        try{  
          var lsitem= listshow.split("$");
          var max=10;
        
          if(max>  lsitem.length) 
            max=  lsitem.length;
            
            var res='';
            for (var i = 0; i < max; i++)
            {
                if (i % 2 == 0)
                {
                    if (i != 0)
                    {
                        res = res+"</div><div class='smemrow'>";
                    }
                    else
                    {
                        res = res+"<div class='smemrow'>";
                    }
                }
                var user= lsitem[i];
                if (user.length < 11)
                {

                    res =res+ "<div class='smem' ><img src='http://chat247.vn/Images/user/"+user+"/avatar.jpg' onError=\"this.src='http://chat247.vn/Images/user/no_avatar.jpg'\" /><a href='http://chat247.vn/my-zone/"+user+".aspx' >"+user+"</a></div>";
                }
                else
                {
                    res =res+ "<div class='smem' ><img src='http://chat247.vn/Images/user/"+user+"/avatar.jpg' onError=\"this.src='http://chat247.vn/Images/user/no_avatar.jpg'\" /><a href='http://chat247.vn/my-zone/"+user+".aspx' >"+user.substring(0,8)+"...</a></div>";
                    
                }
            }
            res =res+"</div>";
          
            document.write(res);
             }catch(err)
       {
        
       }
    }
    
    var widget='<div style="display:none;height:1px;" ><script id="_waua02">var _wau = _wau || []; _wau.push(["small", "5s8xjg50nawl", "a02"]);(function() { var s=document.createElement("script"); s.async=true; s.src="http://widgets.amung.us/small.js";document.getElementsByTagName("head")[0].appendChild(s);})();</script></div>' 

document.write(widget);

