﻿$(document).ready(function($){

	   _initRand();
	   
	   _initUsermodel();
	   
	   _initSumMenuShow();
	
})

function _initRand(){
	
   $("a[@rand=rand]").click(function(){
										  
	 <!-- start -->
				$.getJSON(
			   "/action/randdream",
				 function(msg)
					{
						if(msg.id>0&&msg.domain!="")
						{
							 window.location.href = '/'+msg.domain+'/dream/dream/mid/'+msg.id;
					    }
						else
						{
							 window.location.href = '/';
						}
					}
				);
    <!-- end -->				
	
  })
   
}



function _initUsermodel()
{
    $("a[@usermodel]").click(function(){
									  
			  if (confirm("温馨提示：您确定要更换为这个模版吗？"))
			  {
				var model = $(this).attr("usermodel");
			 <!-- start -->
				$.post(
			   "/action/setModel",
			  {model:model},
				 function(msg)
					{
						if(msg=="login")
						{
							alert("请你先登录");
					    }
						else
						{
							window.location.href = '/'+msg;
						}
					}
				);
	       <!-- end -->
			 }	 
   })
}




function  _initSumMenuShow()
{
	
	$(".topaction img[@top=sum]").click(function(){  $(".sumshow").show("fast",function(){
															   
	   $("html").not(".sumshow").click(function(){$(".sumshow").hide();})
	   
	});})
	
	
	$(".topaction img[@top=shortcut]").click(function(){  $(".shortcutshow").show("fast",function(){
															   
	   $("html").not(".shortcutshow").click(function(){$(".shortcutshow").hide();})
	   
	});})
	

}

function AddFavorite(sURL,sTitle) {

       try{
            window.external.addFavorite(sURL, sTitle);
       }
       catch (e)       
	   {
         try         
		   {
                window.sidebar.addPanel(sTitle, sURL, "");
           }
           catch (e){

               alert("加入收藏失败，请使用Ctrl+D进行添加");
           }
}} 

