
var nowdv=null, zindex=0, x, y
var IsDirty = false;
function sel(dv)
{
	nowdv = dv;
	x=event.clientX;
	y=event.clientY;
	
	nowdv.style.zIndex = zindex++;

	// set capture
	// document.onmousemove=moveit;
}

function release(e)
{

	// release capture
	// document.onmousemove=null;
    
   
	nowdv = null;
}

function moveit(e)
{
	nx = event.clientX;
	ny = event.clientY;

	if(nx < 0 || ny < 0)
		return;

	if(event.button!=1)
		nowdv=null;
	if(nowdv)
	{
		nowdv.style.pixelLeft += nx-x;
		nowdv.style.pixelTop  += ny-y;
		x=nx;
		y=ny;
	}
}

function move_draws() {
	if( nowdv != null ) {
	    IsDirty = true;
		moveit(event);
	}
}

function hiddenit(dv)
{
    dv.style.display = "none"    
}

function MoveDiv(dv, posx, posy)
{
	dv.style.pixelLeft = posx;
	dv.style.pixelTop  = posy;
}
    
function CenterWindow()
{
    var dv = document.getElementById('invitationLayer');
    
    if(dv == null)
        return;

    var curWidth = dv.clientWidth;
    var curHeight = dv.clientHeight;
    
    var width = document.body.clientWidth ;
    var height = document.body.clientHeight; 
    var wPos = (width-curWidth)/2;
    var hPos = (height-curHeight)/2- curHeight/3;

    
    //alert("a")
    MoveDiv(dv, wPos, hPos);
    
}

function CenterWindow2()
{
    var dv = document.getElementById('clearLayer');

    var curWidth = dv.clientWidth;
    var curHeight = dv.clientHeight;
    
    var width = document.body.clientWidth ;
    var height = document.body.clientHeight; 
    var wPos = (width-curWidth)/2;
    var hPos = (height-curHeight)/2- curHeight/3;

    
    //alert("a")
    MoveDiv(dv, wPos, hPos);
    
}

var divObj, divWidth, divHeight, divLeft, maxHeight, currentHeight;
var timeID

function showNotice(value, name)
{
    creatediv(name, value);
    
    var dv = document.getElementById('invitationLayer');
    
    divObj = dv;
    
    divObj.style.display = "";

    divWidth = dv.clientWidth;
    divHeight = dv.clientHeight;
    
    var width = document.body.clientWidth ;
    var Height = document.body.clientHeight; 

    divLeft = (width-divWidth)/2;
    maxHeight = (Height-divHeight)/2 - divHeight/3;
    
    divObj.style.pixelLeft = divLeft;
    

    currentHeight = 0-Height;
    
    timeID = window.setInterval("MoveDivDH()", 19);
    
    
}


function showNotice1(value, name)
{
    creatediv1(name, value);
    
    var dv = document.getElementById('invitationLayer');
    
    divObj = dv;
    
    divObj.style.display = "";

    divWidth = dv.clientWidth;
    divHeight = dv.clientHeight;
    
    var width = document.body.clientWidth ;
    var Height = document.body.clientHeight; 

    divLeft = (width-divWidth)/2;
    maxHeight = (Height-divHeight)/2 - divHeight/3;
    
    divObj.style.pixelLeft = divLeft;
    

    currentHeight = 0-Height;
    
    timeID = window.setInterval("MoveDivDH()", 19);
    
    
}

function MoveDivDH()
{
    currentHeight += 20;
    
    if ( currentHeight > maxHeight )
    {
        window.clearInterval(timeID);
    }
    
    //MoveDiv(divObj, divObj.style.pixelLeft, currentHeight);
}
    
	function tuneto(area){		
	    var redirecturl = theredirecturl;		
		var regionCookie = GetCookie("regionCookie");
		var zt = redirecturl.indexOf("/zhuanti/");
		
		DWREngine.beginBatch();
	if(area == "1"){
			document.frames["regioniframe"].location.replace("http://buy.officedepot.com.cn/resources/regionSessionSet.jsp?region=1");
			if(regionCookie != "1")setAreaCookie("regionCookie","1");
			
			if(zt != -1){			    
				redirecturl = redirecturl.substring(0, zt)+"/zhuanti/" + redirecturl.substring(zt+ 9, redirecturl.length);
			}
			if(redirecturl.indexOf("/zhuanti/") != -1){
				redirecturl = redirecturl.substring(0,redirecturl.indexOf("/zhuanti/"))+"/zhuanti/bj/" + redirecturl.substring(redirecturl.indexOf("/zhuanti/") + 9,redirecturl.length);
			}
			if(redirecturl.indexOf("/bj/gift.html") != -1){
				redirecturl = "http://en.officedepot.com.cn/bj/gift.html";
			}			
		}else if(area== "2"){
			document.frames["regioniframe"].location.replace("http://buy.officedepot.com.cn/resources/regionSessionSet.jsp?region=2");
			if(regionCookie != "2")setAreaCookie("regionCookie","2");
			if(zt != -1){			    
				redirecturl = redirecturl.substring(0, zt)+"/zhuanti/" + redirecturl.substring(zt+ 9, redirecturl.length);
			}
			if(redirecturl.indexOf("/zhuanti/") != -1){
				redirecturl = redirecturl.substring(0,redirecturl.indexOf("/zhuanti/"))+"/zhuanti/sh/" + redirecturl.substring(redirecturl.indexOf("/zhuanti/") + 9,redirecturl.length);
			}
			if(redirecturl.indexOf("http://en.officedepot.com.cn/") != -1&& redirecturl.indexOf("/bj/gift.html") == -1){
				redirecturl= "http://en.officedepot.com.cn/sh/" + redirecturl.substring(redirecturl.indexOf("http://en.officedepot.com.cn/") + 29,redirecturl.length);
			}
			if(redirecturl.indexOf("/bj/gift.html") != -1){redirecturl = "http://buy.officedepot.com.cn/goldbean.html";}					
		}
		
		else if(area== "3"){
			document.frames["regioniframe"].location.replace("http://buy.officedepot.com.cn/resources/regionSessionSet.jsp?region=3");
			if(regionCookie != "3")setAreaCookie("regionCookie","3");

			if(redirecturl.indexOf("http://en.officedepot.com.cn/") != -1&& redirecturl.indexOf("/bj/gift.html") == -1){
				redirecturl= "http://en.officedepot.com.cn/gz/" + redirecturl.substring(redirecturl.indexOf("http://en.officedepot.com.cn/") + 29,redirecturl.length);
			}
		}
		
				else if(area== "5"){
			document.frames["regioniframe"].location.replace("http://buy.officedepot.com.cn/resources/regionSessionSet.jsp?region=5");
			if(regionCookie != "5")setAreaCookie("regionCookie","5");

			if(redirecturl.indexOf("http://en.officedepot.com.cn/") != -1&& redirecturl.indexOf("/bj/gift.html") == -1){
				redirecturl= "http://en.officedepot.com.cn/tj/" + redirecturl.substring(redirecturl.indexOf("http://en.officedepot.com.cn/") + 29,redirecturl.length);
			}
		}
		
		else if(area== "6"){
			document.frames["regioniframe"].location.replace("http://buy.officedepot.com.cn/resources/regionSessionSet.jsp?region=6");
			if(regionCookie != "6")setAreaCookie("regionCookie","6");

			if(redirecturl.indexOf("http://en.officedepot.com.cn/") != -1&& redirecturl.indexOf("/bj/gift.html") == -1){
				redirecturl= "http://en.officedepot.com.cn/sz/" + redirecturl.substring(redirecturl.indexOf("http://en.officedepot.com.cn/") + 29,redirecturl.length);
			}
		}
		DWREngine.endBatch({timeout:2000});
		//alert(redirecturl);
		window.location = redirecturl;
	}			


function creatediv1(name, value)
{
    var strdiv = "";
    
    strdiv +=	"<table cellSpacing=\"0\" width=\"310\" border=\"0\" id=\"table2\" >"
    strdiv +=		"<tr>"
    strdiv +=			"<td>"
    strdiv +=			"<table cellSpacing=\"0\" cellPadding=\"1\" width=\"100%\" bgColor=\"#006FE0\" border=\"0\" >"
    strdiv +=				"<tr>"
    strdiv +=					"<td>"
    strdiv +=					"<table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" bgColor=\"#ffffff\" border=\"0\" id=\"table4\">"
    strdiv +=						"<tr vAlign=\"top\">"
    strdiv +=							"<td>"
    strdiv +=							"<table cellPadding=\"0\" width=\"100%\" id=\"table5\" border=0 cellSpacing=\"0\">"
    strdiv +=								"<tr bgcolor=\"#006FE0\" height=\"20\" style=\"cursor:move;\" onmousedown=\"sel(document.getElementById('invitationLayer'))\">"
    strdiv +=									"<td width=\"301\" height=\"20\" style=\"font-size: 11px; color: #FFFFFF; padding-left:10px;font-family: Verdana, Arial, Helvetica, sans-serif\">"
    strdiv +=									    "<strong>Please select your location:</strong>"
    strdiv +=									"</td>"
    strdiv +=								    "<td >"
    strdiv +=    									"<img src=\"http://img.officedepot.com.cn/englishimg1/tc_03.gif\" align=right style=\"cursor:default\" onclick=\"hiddenit(document.getElementById('invitationLayer'))\">    "
    strdiv +=							    	"</td>"
    strdiv +=								"</tr>"
    strdiv +=								"<tr>"
    strdiv +=									"<td colspan=2 height=\"116\">"
    strdiv +=									"<div style=\"font-size: 12px; color: #000000; font-family: Arial, Helvetica, sans-serif\">"
    strdiv +=									    "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"radio\" value=\""+value+"\" id=\"rdzgz\" name=\"rdtogo\" onclick=\"tuneto('1')\"> <label for=\"rdzgz\">Beijing</label>"
    strdiv +=									    "&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"radio\" value=\"index\" id=\"rdzrc\" name=\"rdtogo\" onclick=\"tuneto('2')\"> <label for=\"rdzrc\">Shanghai</label>"    
	strdiv +=									    "&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"radio\" value=\""+value+"\" id=\"rdzgz\" name=\"rdtogo\" onclick=\"tuneto('3')\"> <label for=\"rdzgz\">Guangzhou</label><br><br>"
    strdiv +=									    "&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"radio\" value=\"index\" id=\"rdzrc\" name=\"rdtogo\" onclick=\"tuneto('6')\"> <label for=\"rdzrc\">Shenzhen</label>"
	strdiv +=									    "&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"radio\" value=\"index\" id=\"rdzrc\" name=\"rdtogo\" onclick=\"tuneto('5')\"> <label for=\"rdzrc\">Tianjin</label>"
    strdiv +=								    "</div>"
    strdiv +=									"<!-- Footer text. -->"
    strdiv +=									"<div style=\"font-size: 11px; color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; margin-top: 0px\">"
    strdiv +=									"<!--input type=\"checkbox\" value=\"0\" id=\"chkNoNotice\"> <label for=\"chkNoNotice\">以后不要再提示我</label-->"
    strdiv +=									"</div>"
    strdiv +=									"</td>"
    strdiv +=								"</tr>"
    strdiv +=							"</table>"
    strdiv +=						    "</td>"
    strdiv +=						"</tr>"
    strdiv +=					"</table>"
    strdiv +=					"</td>"
    strdiv +=				"</tr>"
    strdiv +=			"</table>"
    strdiv +=			"</td>"
    strdiv +=		"</tr>"
    strdiv +=	"</table>"
        

    var dv = document.getElementById('invitationLayer');
    
    dv.innerHTML = strdiv
    
    //alert(dv.innerHTML)
}

function creatediv(name, value)
{
    var strdiv = "";
    
    strdiv +=	"<table cellSpacing=\"0\" width=\"310\" border=\"0\" id=\"table2\" >"
    strdiv +=		"<tr>"
    strdiv +=			"<td>"
    strdiv +=			"<table cellSpacing=\"0\" cellPadding=\"1\" width=\"100%\" bgColor=\"#006FE0\" border=\"0\" >"
    strdiv +=				"<tr>"
    strdiv +=					"<td>"
    strdiv +=					"<table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" bgColor=\"#ffffff\" border=\"0\" id=\"table4\">"
    strdiv +=						"<tr vAlign=\"top\">"
    strdiv +=							"<td>"
    strdiv +=							"<table cellPadding=\"0\" width=\"100%\" id=\"table5\" border=0 cellSpacing=\"0\">"
    strdiv +=								"<tr bgcolor=\"#006FE0\" height=\"20\" style=\"cursor:move;\" onmousedown=\"sel(document.getElementById('invitationLayer'))\">"
    strdiv +=									"<td width=\"301\" height=\"20\" style=\"font-size: 11px; color: #FFFFFF; padding-left:10px;font-family: Verdana, Arial, Helvetica, sans-serif\">"
    strdiv +=									    "<strong>Note：Please select location</strong>"
    strdiv +=									"</td>"
    strdiv +=								    "<td >"
    strdiv +=    									"<img src=\"http://img.officedepot.com.cn/englishimg1/tc_03.gif\" align=right style=\"cursor:default\" onclick=\"hiddenit(document.getElementById('invitationLayer'))\">    "
    strdiv +=							    	"</td>"
    strdiv +=								"</tr>"
    strdiv +=								"<tr>"
    strdiv +=									"<td colspan=2 height=\"116\">"
    strdiv +=									"<div style=\"font-size: 12px; color: #000000; font-family: Arial, Helvetica, sans-serif\">"
    strdiv +=									    "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"radio\" value=\""+value+"\" id=\"rdzgz\" name=\"rdtogo\" onclick=\"tuneto('1')\"> <label for=\"rdzgz\">I'd like to visit the<strong> Beijing</strong> site directly next time</label><br><br>"
    strdiv +=									    "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"radio\" value=\"index\" id=\"rdzrc\" name=\"rdtogo\" onclick=\"tuneto('2')\"> <label for=\"rdzrc\">I'd like to visit the<strong> Shanghai</strong> site directly next time</label><br>"
    strdiv +=								    "</div>"
    strdiv +=									"<!-- Footer text. -->"
    strdiv +=									"<div style=\"font-size: 11px; color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; margin-top: 0px\">"
    strdiv +=									"<!--input type=\"checkbox\" value=\"0\" id=\"chkNoNotice\"> <label for=\"chkNoNotice\">以后不要再提示我</label-->"
    strdiv +=									"</div>"
    strdiv +=									"</td>"
    strdiv +=								"</tr>"
    strdiv +=							"</table>"
    strdiv +=						    "</td>"
    strdiv +=						"</tr>"
    strdiv +=					"</table>"
    strdiv +=					"</td>"
    strdiv +=				"</tr>"
    strdiv +=			"</table>"
    strdiv +=			"</td>"
    strdiv +=		"</tr>"
    strdiv +=	"</table>"
        

    var dv = document.getElementById('invitationLayer');
    
    dv.innerHTML = strdiv
    
    //alert(dv.innerHTML)
}

function showClearDiv()
{
    var strdiv = "";
    
    strdiv +=	"<table cellSpacing=\"0\" cellPadding=\"3\" width=\"360\" bgColor=\"#ffffff\" border=\"0\" id=\"table2\">"
    strdiv +=		"<tr>"
    strdiv +=			"<td>"
    strdiv +=			"<table cellSpacing=\"0\" cellPadding=\"1\" width=\"100%\" bgColor=\"#999999\" border=\"0\" id=\"table3\">"
    strdiv +=				"<tr>"
    strdiv +=					"<td>"
    strdiv +=					"<table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" bgColor=\"#ffffff\" border=\"0\" id=\"table4\">"
    strdiv +=						"<tr vAlign=\"top\">"
    strdiv +=							"<td>"
    strdiv +=							"<table cellPadding=\"0\" width=\"100%\" id=\"table5\" border=0 cellSpacing=\"0\">"
    strdiv +=								"<tr bgcolor=\"#FF3C3C\" height=\"20\" style=\"cursor:move;\" onmousedown=\"sel(document.getElementById('clearLayer'))\">"
    strdiv +=									"<td style=\"font-size: 11px; color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif\">"
    strdiv +=									    "&nbsp;清除默认设置"
    strdiv +=									"</td>"
    strdiv +=								    "<td>"
    strdiv +=    									"<img src=\"images/tc_03.gif\" align=right style=\"cursor:default\" onclick=\"hiddenit(document.getElementById('clearLayer'))\">    "
    strdiv +=							    	"</td>"
    strdiv +=								"</tr>"
    strdiv +=								"<tr>"
    strdiv +=									"<td colspan=2>"
    strdiv +=									"<div align=center style=\"font-size: 11px; color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif\"><br>"
    strdiv +=									    "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;确实要清除设置吗？</label><br><br>"
    strdiv +=								    "</div>"
    strdiv +=									"<!-- Footer text. -->"
    strdiv +=									"<div align=center style=\"font-size: 11px; color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; margin-top: 0px\">"
    strdiv +=									    "<input type=\"button\" value=\" 是 \" onclick=\"clearCookie()\" size=3>&nbsp;&nbsp;&nbsp;<input type=\"button\" value=\" 否 \" onclick=\"hiddenit(document.getElementById('clearLayer'))\" size=6><br>&nbsp;"
    strdiv +=									"</div>"
    strdiv +=									"</td>"
    strdiv +=								"</tr>"
    strdiv +=							"</table>"
    strdiv +=						    "</td>"
    strdiv +=						"</tr>"
    strdiv +=					"</table>"
    strdiv +=					"</td>"
    strdiv +=				"</tr>"
    strdiv +=			"</table>"
    strdiv +=			"</td>"
    strdiv +=		"</tr>"
    strdiv +=	"</table>"
        

    var dv = document.getElementById('clearLayer');
    
    dv.innerHTML = strdiv;
    
    
    
    dv.style.display = "";
    
    CenterWindow2();
    
    //alert(dv.innerHTML)
}
    
    
document.onmouseup=release;

document.onmousemove = move_draws;

window.onresize  = CenterWindow;

//document.onmousewheel = CenterWindow;
//window.onload = showNotice;
