﻿
//网游首页所有游戏层

//实现外部边框的定位80617//
   
 $(document).ready(function(){
     //页面初始化
      $("#gMenu").css({"cursor":"hand"}); 
       getGamePanel("Type=GamePanel&getTypeOL=WL");
       $('#gMenu').bind('click', function()  { 
      
       showmenu('gMenu','tabs','show','bottom');
     
	   });
	  
 });
  function setQuery(ganme){
                              $(".keywords").val(ganme);
                               callopen();
	   	                  }
  function setPageHotkey(key){
   
                             $(".leftkeys").html(key);
	   	                  }
	   	                  
	   	                  
 function getGamePanel(url){
	   	                        $.ajax({   
		                            type: "POST",                                     
		                            url: "AjaxgetGamePanel.aspx",                                      
		                            data:url ,                             
		                            success: function(result){  $("#tabs").html(result); }
		                           
		
                                 });
                        }
                        
  function fungetHotKey(url){
	   	                        $.ajax({   
		                            type: "POST",                                     
		                            url: "AjaxgetGamePanel.aspx",                                      
		                            data:url ,                             
		                            success: function(result){ 
		                             
		                             var keyword =result.split('$');
		                             
		                             if(keyword.length==3)
		                             {
		                              //alert( 'ss');
		                              $(".leftkeys").html(keyword[0]);
		                             
		                            }else
		                            {
		                               
		                              $(".leftkeys").html("热门关键词");
		                            }
		                                                     }
		                           
		
                                 });
                        }                      
  function getHotKey(url){
	   	                        $.ajax({   
		                            type: "POST",                                     
		                            url: "AjaxgetGamePanel.aspx",                                      
		                            data:url ,                             
		                            success: function(result){ 
		                             
		                             var keyword =result.split('$');
		                             
		                             if(keyword.length==3)
		                             {
		                              
		                              $(".leftkeys").html(keyword[0]);
		                              if(keyword[1]=="ajax")
		                              {
		                              $(".keywords").val(keyword[2]);
		                              }
		                            }else
		                            {
		                              $(".keywords").val("");
		                              $(".leftkeys").html("热门关键词");
		                            }
		                                                     }
		                           
		
                                 });
                        }
                        
                        
  var menuTimer =null; 
 function showmenu(obj1,obj2,state,location){ 
 }
 
    function showmenu(obj1,obj2,state,location){ 
    var btn=document.getElementById(obj1);
    var obj=document.getElementById(obj2);
    var h=btn.offsetHeight;
    var w=btn.offsetWidth;
    var x=btn.offsetLeft;
    var y=btn.offsetTop;
     obj.onmouseover =function(){
        showmenu(obj1,obj2,'show',location);
       //alert("obj1="+obj1+"obj2="+obj2);
       
     
        
    }
       obj.onmouseout =function(){
       showmenu(obj1,obj2,'hide',location);  
    }
    
    while(btn=btn.offsetParent){y+=btn.offsetTop;x+=btn.offsetLeft;  }//节点的绝对偏移量的
   
    var hh=obj.offsetHeight;
    var ww=obj.offsetWidth;
    var xx=obj.offsetLeft;//style.left;
    var yy=obj.offsetTop;//style.top;
    var obj2state=state.toLowerCase();
    var obj2location=location.toLowerCase();
    
    var showx,showy;

    if(obj2location=="left" || obj2location=="l" || obj2location=="top" || obj2location=="t" || obj2location=="u" || obj2location=="b" || obj2location=="r" || obj2location=="up" || obj2location=="right" || obj2location=="bottom"){
        if(obj2location=="left" || obj2location=="l"){showx=x-ww;showy=y;}
        if(obj2location=="top" || obj2location=="t" || obj2location=="u"){showx=x;showy=y-hh;}
        if(obj2location=="right" || obj2location=="r"){showx=x+w;showy=y;}
        if(obj2location=="bottom" || obj2location=="b"){showx=x;showy=y+h;}
    }else{ 
        showx=xx;showy=yy;
    }
    obj.style.left=showx+10+"px"; //可以修改与父标签的距离
    obj.style.top=showy+20+"px";
    if(state =="hide")
    {
       menuTimer =setTimeout("hiddenmenu('"+ obj2 +"')", 500);
     }
   
  else{
         clearTimeout(menuTimer);
         $(obj).css("visibility","visible");
 
  }
}
function hiddenmenu(psObjId){
         $("#"+psObjId).css("visibility","hidden"); //style="visibility:hidden;"
                             } 
                        
                        
 

function setTab(n){
var tli=$("#gameMenu>li");
var mli=$("#gameMenuContent>ul"); 
 $('#gameMenuContent>ul').each(function (nn)
 {
    tli[nn].className=nn==n?"hover":"";
    mli[nn].style.display=nn==n?"block":"none";
  
});
 
}

function closeTab()
{
     $("#tabs").css("visibility","hidden");
}
function setGame(name,setval)//设置游戏
{     var gmid=$("#gmId").val();
      var  gMenu=$("#gMenu").val();
     
 	if(gmid!=null)
      $("#gmId").val(setval); 
 
	if(gMenu!=null)
	{   $("#gMenu").val(name);
 	  
 	   getNew(); 
  
        	 
	}
	
}

 function getNew()
 {
  var setval=$("#gmId").val();
  var tp=getTypeValue("rbtn_type"); 
  
 getHotKey("Type=Gethotkey&gi="+setval+"&tp="+tp+"&DataType=ajax"); 
 closeTab();
 }
 
function getTypeValue(typeName)
{
    var rbtn_type=document.getElementsByName(typeName);
    for(var i=0;i<rbtn_type.length;i++)
    {
        if(rbtn_type[i].checked)
        {
            return rbtn_type[i].value;
        }    
    } 
}
function setDefault(q,gn,gi,tp)
{
    $('.selectkey').val(gn);
    //alert(q);
    if(gn==null)
    {
    $('.selectkey').val("请选择游戏");
    } 
   
    $('#gmId').val(gi);  
    $('.keywords').val(q);
     
    var rbtn_type=$("input[@name='rbtn_type']") ;
     for(var i=0;i<rbtn_type.length;i++)
    {
        if(rbtn_type[i].value==tp)
        {
             rbtn_type[i].checked=true;
             break;
        }    
    } 
      
     
}
 
 
function callopen()
{   var msg="Raiders";
	var url="Type=GetVirtualUrl"
	var q=$('#keyword').val();
    var gmId=$('#gmId').val();
    var glType=$('#glType').val();
    var sFlag=$('#sFlag').val();
    var pageSize=$('#pageSize').val();
    var tp=getTypeValue("rbtn_type");
    url+="&tp="+tp;
    
    var others="";
    if(gmId!=null&&gmId!="")
        others+="&gi="+gmId;   
    if(glType!=null&&glType!="")
        others+="&gl="+glType;
    if(sFlag!=null&&sFlag!="")
        others+="&sf="+sFlag;
    if(pageSize!=null&&pageSize!="")
        others+="&ps="+pageSize;
    var actionPage="";
    if(tp=="1011")
     {
      msg="Raiders";
     } 
     else if (tp=="1031")
     {
     msg="PicPage";
     }  
     window.location.href=msg+"?q="+encodeURIComponent(q)+"&tp="+tp+others;                        
 
//   	   	$.ajax({   
//		type: "POST",                                     
//		url: "AjaxgetGamePanel.aspx",                                      
//		data:url ,                             
//		success: function(msg){ window.location.href=msg+"?q="+encodeURIComponent(q)+"&tp="+tp+others;  }   
//	    
//        }); 
}
    
  
   
 

