var comp = document.getElementById('competition');
var complink = document.getElementById('complink');
var jokerlink = document.getElementById('jokerlink');

comp.href="javascript:void(0)";

if (navigator.appName != 'Microsoft Internet Explorer')
	{ // e.g. Firefox, Opera, Safari
	       	comp.setAttribute("onclick", "popup();");
	}
	else
	{ // e.g. Internet Explorer (also would work on Opera)
	        comp.attachEvent("onclick", function() {popup()});
	}

if (complink!=null)
{
   complink.href="javascript:void(0)";

   if (navigator.appName != 'Microsoft Internet Explorer')
	{ // e.g. Firefox, Opera, Safari
	       	complink.setAttribute("onclick", "popup();");
	}
	else
	{ // e.g. Internet Explorer (also would work on Opera)
	        complink.attachEvent("onclick", function() {popup()});
	}
}

if (jokerlink!=null)
{
   jokerlink.href="javascript:void(0)";

   if (navigator.appName != 'Microsoft Internet Explorer')
	{ // e.g. Firefox, Opera, Safari
	       	jokerlink.setAttribute("onclick", "popup();");
	}
	else
	{ // e.g. Internet Explorer (also would work on Opera)
	        jokerlink.attachEvent("onclick", function() {popup()});
	}
}

function popup()
{
	window.open("http://msn-darkknight-comp.co.uk", "Competition", "width=799,height=730,scrollbars=no,toolbar=no,menubar=no,resizable=no");
}


/// <summary>
/// 获取屏幕高宽。
/// </summary>
/// <author>Mike Cheers</author>
/// <date>2006-10-27</date>
function getScreenArea()
{ 
this.clientWidth = 0;
this.clientHeight = 0;
this.scrollLeft = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
this.scrollTop = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
this.scrollWidth = (document.documentElement.scrollWidth ? document.documentElement.scrollWidth : document.body.scrollWidth);
this.scrollHeight = (document.documentElement.scrollHeight ? document.documentElement.scrollHeight : document.body.scrollHeight);

if (window.innerWidth) {
this.clientWidth = (window.__safari ? window.innerWidth : Math.min(window.innerWidth, document.documentElement.clientWidth));
} else {
this.clientWidth = document.documentElement.clientWidth;
}

if (window.innerHeight) {
this.clientHeight = (window.__safari ? window.innerHeight : Math.min(window.innerHeight, document.documentElement.clientHeight));
} else {
this.clientHeight = document.documentElement.clientHeight;
}
}
/// <summary>
/// 获取页面元素。
/// </summary>
/// <author>Mike Cheers</author>
/// <date>2006-1-20</date>
function GE(elementId){
return document.getElementById(elementId);
}
/// <summary>
/// 创建Mask层。
/// </summary>
/// <author>Mike Cheers</author>
/// <date>2006-11-6</date>
/// <summary>
function creatMaskLayer(){
var myObj = GE("loadBgLayer");
if(myObj == null){
var oDiv = document.createElement("Div");
oDiv.id = "loadBgLayer";
oDiv.style.position = "absolute";
oDiv.style.zIndex = 1250;
document.body.appendChild(oDiv);
} 
}


/// <summary>
/// 创建Dialog层。
/// </summary>
/// <author>Mike Cheers</author>
/// <date>2006-11-6</date>
/// <summary>
function creatDialogLayer(){

var dmyObj = GE("dialogLayer");
if(dmyObj == null){
var dDiv = document.createElement("Div");
dDiv.id = "dialogLayer";
dDiv.style.position = "absolute";
dDiv.style.zIndex = 1251;
document.body.appendChild(dDiv);
} 

var dClsObj = GE("dialogCloseLayer");
if(dClsObj == null){
var cDiv = document.createElement("Div");
cDiv.id = "dialogCloseLayer";
cDiv.style.position = "absolute";
cDiv.style.zIndex = 1252;
document.body.appendChild(cDiv);
} 

}

function closeDialog(){
	var dialogCloseLayer = GE("dialogCloseLayer");
	if(dialogCloseLayer != null){
		dialogCloseLayer.style.display = "none";
	}
	
	var dialogLayer = GE("dialogLayer");
	if(dialogLayer != null){
		dialogLayer.style.display = "none";
	}

	var maskLayer = GE("loadBgLayer");
	if(maskLayer != null){
		maskLayer.style.display = "none";
	}
}

function redirectAsBlank()
{
    var dialogLayer = GE("dialogLayer");
	if(dialogLayer != null){
		window.open("http://entertainment.uk.msn.com/movies/features/article.aspx?cp-documentid=8917317");
		closeDialog();
	}
}

function showDialog(){
	var sa = new getScreenArea();

	var maskLayer = GE("loadBgLayer");
	if(maskLayer == null){
		creatMaskLayer();
		maskLayer = GE("loadBgLayer");
	}
	maskLayer.style.top = sa.scrollTop+"px";
	maskLayer.style.left = "0px";
	maskLayer.style.width = "100%";
	maskLayer.style.height = "100%";
	maskLayer.style.backgroundColor = "#333333";
	maskLayer.style.opacity = .90;
	maskLayer.style.filter = "alpha(opacity=90)";
	maskLayer.style.display = "";


	var dialogLayer = GE("dialogLayer");
	if (dialogLayer == null){
		creatDialogLayer();
		dialogLayer = GE("dialogLayer");
	}
	dialogLayer.style.width = "700px";
	dialogLayer.style.height = "436px";
	dialogLayer.style.top = 100+sa.scrollTop+"px";
	dialogLayer.style.left = (sa.scrollWidth - 700)/2 + sa.scrollLeft + "px";
	dialogLayer.style.background = "url('/images/tdk_popup.jpg')";
        dialogLayer.style.cursor = "pointer";
	dialogLayer.style.display = "";
   	dialogLayer.onclick = redirectAsBlank;


	var dialogCloseLayer = GE("dialogCloseLayer");
	if (dialogCloseLayer == null){
		creatDialogLayer();
		dialogCloseLayer = GE("dialogCloseLayer");
	}
	dialogCloseLayer.style.top = 108+sa.scrollTop+"px";
	dialogCloseLayer.style.left = sa.scrollWidth/2 + (630 - 350) + sa.scrollLeft + "px";
	dialogCloseLayer.style.width = "55px";
	dialogCloseLayer.style.height = "20px";
	dialogCloseLayer.style.cursor = "pointer";
	dialogCloseLayer.style.border =  "none";
	dialogCloseLayer.style.display = "";
	dialogCloseLayer.onclick = closeDialog;
}

