﻿function Showmark(w,h,ctrlName)
{

    var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var pageW=(arrayPageSize[2]-w)/2;
	var pageH=(arrayPageSize[3]-h)/2+arrayPageScroll[1];

	var d = $c("div");
	with(d){
		id = "filterMark";
		style.width =arrayPageSize[2]+"px";
		
		style.height = arrayPageSize[1]+"px";
		style.left = style.top = "0";
		style.position = 'absolute';
		style.backgroundColor = "black";
 	    style.filter = "alpha(opacity=40)";
 		style.opacity=0.3;
		style.zindxe="1000";
	}
     
	 
	document.body.style.overflow = "hidden";
	$('#UI_DataIsland').append(d);
    //创建弹出层
	var	ctrlDiv = $c("div");
	with(ctrlDiv){
		id = ctrlName;
		//style.width = w+"px";
		//style.height = h+"px";
		style.position = 'absolute';
 
        style.left=pageW+"px";
        style.top=pageH+"px";
		//style.border = "2px solid #069";
		style.backgroundColor = "#FFFFEE";
		//style.padding = '5px';
		style.zindxe="1100"
	}
     //遮罩层出现时影藏dropDownList控件
     $("#li_PriceType").css("display","none");
     $("#li_EffectDate").css("display","none");
    $("#li_city").css("display","none");
     
	 ctrlDiv.innerHTML="<h4><a class=\"fr\" href=\"javascript:removeCtrl('"+ctrlName+"')\"  title='关闭' ><span class=\"dis\">关闭</span></a>货物已经成功添加到购物车</h4><ul><li><input type='button' id='goStructe' value='查看购物车' onclick=\"removeCtrlAndGoStruct('"+ctrlName+"')\"></input><input type='button' id='goGoods' value='继续挑选货物' onclick=\"removeCtrl('"+ctrlName+"')\"></input></li></ul>";
	 
	 obj = document.body.appendChild(ctrlDiv);



}




//移除弹出 和遮罩
function removeCtrl(ctrlName){

     //遮罩层出现时影藏dropDownList控件
     $("#li_PriceType").css("display","");
     $("#li_EffectDate").css("display","");
         $("#li_city").css("display","");
	  
	document.body.removeChild(document.getElementById(ctrlName));
	$("#filterMark").remove();
	document.body.style.overflow = "auto";

         
}

//移除弹出 和遮罩 跳转到购物车
function removeCtrlAndGoStruct(ctrlName){
    //alert("ddd");
	document.body.removeChild(document.getElementById(ctrlName));
	
	$("#filterMark").remove();
	document.body.style.overflow = "auto";
  
  document.location="http://pay.xiuma.com/ShoppingCart.aspx";
         
}

//移除弹出 和遮罩 跳转到列表也
function removeCtrlAndGoodsList(ctrlName){
	document.body.removeChild(document.getElementById(ctrlName));
	
	$("#filterMark").remove();
	document.body.style.overflow = "auto";

   document.location="";   
}







function $c(s){
	return document.createElement(s)
}





// getPageScroll()
// Returns array with x,y page scroll values.

function getPageScroll(){
	var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

//
// getPageSize()
// Returns array with page width, height and window width, height
//
function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


