﻿/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;

//初始化：是否开启DIV弹出窗口功能
//0 表示开启; 1 表示不开启;
var popupStatus = 0;

//使用Jquery加载弹窗
function loadPopup(){
	//仅在开启标志popupStatus为0的情况下加载
	if(popupStatus==0){
		$("#contact").css({
			"opacity": "1"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#contact").fadeIn("slow");
		popupStatus = 1;
	}
}

//使用Jquery去除弹窗效果 
function disablePopup(){
	//仅在开启标志popupStatus为1的情况下去除 
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#contact").fadeOut("slow");
		popupStatus = 0;
	}
}



//将弹出窗口定位在屏幕的中央
function centerPopup(){
	//获取系统变量
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#contact").height();
	var popupWidth = $("#contact").width();
	//居中设置 
	$("#contact").css({
		"position": "absolute",
		
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//以下代码仅在IE6下有效
	
	$("#backgroundPopup").css({
		"height":"2500px",
		"opacity":"0.5"
	});
	
}


//执行触发事件的代码区域
$(document).ready(function(){
	
	 
	//打开弹出窗口    
//按钮点击事件! 
	$("#button").click(function(){
		//调用函数居中窗口
		centerPopup();
		//调用函数加载窗口
		loadPopup();
		
	});
	
//测试
//var inputs=document.getElementsByTagName("Repeater");

//for(j=0;j<inputs.length;j++) 
//	alert(j);
//	    if(inputs[j].type=="HyperLink") 
//	    {
//	        inputs[j].setAttribute("onclick", "javascript:alert('测试');");


//	    }
	
//	$("[id*=shopbody___beidouleft__ctl]").each(function()
//	{
//	    var tepid=$(this).attr("id");
//	    var url=$("HiddenField").attr("id");
//	    
//	    
//	    $("#"+tepid).click(function(){
//		//调用函数居中窗口
//		centerPopup();
//		//调用函数加载窗口
//		loadPopup();
//		//alert(tepid);
//		$("#win").arrt({src:url});
//	});
//	}
//	);
//alert($(".L dt").html());


	//});	


	
				
	//关闭弹出窗口 
	//点击"X"所触发的事件
	$("#popupContactClose").click(function(){
		disablePopup();
	});
//	//点击窗口以外背景所触发的关闭窗口事件!
//	$("#backgroundPopup").click(function(){
//		disablePopup();
//	});
//	//键盘按下ESC时关闭窗口!
//	$(document).keypress(function(e){
//		if(e.keyCode==27 && popupStatus==1){
//			disablePopup();
//		}
//	});

});
