//**********************************************************
//编成与2010.6.13
//JS程序员：Mr.Huang
//程序公司:森泊品牌设计公司
//**********************************************************

	$(document).ready(function(){
		$("head").append('<link href="/Js/Rcss/tcc.css" rel="stylesheet" type="text/css">');
		$("body").append("<div id='backgroundPopup' ></div>");
		$("body").append("<div id=\"popupContact\"><a id=\"popupContactClose\">x</a><Strong><span id='HuangH1'>弹出窗口的标题</span></Strong><p id=\"contactArea\">内容</p></div>");
	//初始化：是否开启DIV弹出窗口功能
	//0 表示开启; 1 表示不开启;
	var popupStatus = 0;

	//使用Jquery加载弹窗 
	function loadPopup(){   
	//仅在开启标志popupStatus为0的情况下加载  
	if(popupStatus==0){   
		$("#backgroundPopup").css({   
			"opacity": "0.1"  
		});   
		$("#backgroundPopup").fadeIn("slow");   
		$("#popupContact").fadeIn("slow");   
		popupStatus = 1;   
		}   
	}  
	//使用Jquery去除弹窗效果 
	function disablePopup(){   
	//仅在开启标志popupStatus为1的情况下去除
		if(popupStatus==1){   
				$("#backgroundPopup").fadeOut("slow");   
				$("#popupContact").fadeOut("slow"); 
				//清楚Con内容。
				setTimeout(function(){$("#contactArea").html("森泊品牌设计公司");},600);
				popupStatus = 0;   
			}   
	} 
	//加载更多颜色
	function YanZhaoHide()
	{
		
		$("#backgroundPopup")
		.css("height",(document.body.scrollHeight+20)+"px");
	}
	//将弹出窗口定位在屏幕的中央
	function centerPopup(){   
	//获取系统变量
		var windowWidth = document.body.offsetWidth;   
		var windowHeight =document.body.offsetHeight; 
		
		var popupHeight = $("#popupContact").height();   
		var popupWidth = $("#popupContact").width();   
		//居中设置   
		$("#popupContact").css({   
			"position": "absolute",   
			"top": windowHeight/2-popupHeight/2,   
			"left": windowWidth/2-(popupWidth/2+20)
		});   
		//以下代码仅在IE6下有效
		  
		$("#backgroundPopup").css({   
			"height": windowHeight   
		});   
	}


	//ajax
	function Ajax(ID,o)
	{ 
	var URL="";
	var Name="";
		switch(o)
		{
			case 0:
			
			URL="/aj/article_view.asp";
			
			Name="board=2&table=a_about&id="+ID;
			break;
			case 1:
			URL="/aj/product_view.asp";
			
			Name="id="+ID;
			break;
		}

		$.ajax({	
   async: false,
   type: "GET",
   url:URL,//请求URL
   data:Name,
   success: function(data){

   		$("#contactArea").html(unescape(data));	
   }});
	}
	//打开弹出窗口   
	//按钮点击事件!
	$("a.HuangJian").click(function(){
		
		//调用函数居中窗口
		centerPopup();   
		//调用函数加载窗口
		loadPopup();
		$("#HuangH1").html(this.title);
		$("#contactArea").html("<img src='/Js/Rcss/Img/loader.gif'>加载中.....");
		Ajax(this.rev,0);
		YanZhaoHide();
	});
	//定义产品弹出窗口
	//按钮点击事件!
	$("a.prodcts").click(function(){
		
		//调用函数居中窗口
		centerPopup();   
		//调用函数加载窗口
		loadPopup();
		$("#HuangH1").html(this.title);
		$("#contactArea").html("<img src='/Js/Rcss/Img/loader.gif'>加载中.....");
		Ajax(this.rev,1);
		YanZhaoHide();
	});
	//关闭弹出窗口   
	//点击"X"所触发的事件
	$("#popupContactClose").click(function(){   
			disablePopup();   
	});   
	//点击窗口以外背景所触发的关闭窗口事件!
	$("#backgroundPopup").click(function(){   
		disablePopup();   
	});   
	//键盘按下ESC时关闭窗口!
	$(document).keypress(function(e){   
		if(e.keyCode==27 && popupStatus==1){   
			disablePopup();   
		}   
	});  


});