checkB();

if (NS4){
	document.writeln( "<layer id='watermark' left='0' top='0' width='" + cz_image_width + "' height='" + cz_image_height + "' visibility='hide'>");
	document.writeln( "<a href='"+cz_crazy_adlink+ "'><img src='" + cz_image_url + "' width='" + cz_image_width + "' height='" + cz_image_height + "' border='0'></a> </layer> " );
}
else{
	document.writeln( "<div class=xsbody align=center id='watermark' style='position:absolute;left:0;top:0;visibility:hidden;width:" + cz_image_width + ";height:" + cz_image_height + "'>");
	document.writeln( "<a href='" + cz_crazy_adlink + "'><img src='" + cz_image_url + "' width='" + cz_image_width + "' height='" + cz_image_height + "' border='0'></a>  " );
	document.writeln( "<a href=javascript:cz_playAgain()><font color=#999999>ÖØ²¥¹ã¸æ</font></a></div> " );
}

if (IE) {
	document.all("watermark").style.visibility = "hidden";
	cz_playFlash();
}
else if (NS6) {
    document.getElementById("watermark").style.visibility="hidden";
}
else if(NS4){
	document.layers["watermark"].visibility = "hide";
}
else if (OP6){
	document.all("watermark").style.visibility = "hidden";	
}
   
   
var htmlLeft;
var flash_width;
var htmlTop;
var swf_width;
var swf_height;
function cz_playFlash(){

    if (IE){
        if(!htmlLeft) { htmlLeft =  (document.body.clientWidth - 750) / 2; }
        if(!flash_width) { flash_width = document.body.clientWidth; }
        if(!htmlTop) { htmlTop = 175; }
        if(!swf_width) { swf_width = 500; }
        if(!swf_height) { swf_height = 380; }
        document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
        document.write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"');
        document.write(' style="POSITION:absolute; VISIBILITY:hidden; WIDTH:' + swf_width + '; HEIGHT:' + swf_height + '; LEFT:' + htmlLeft + ';  top:' + htmlTop + '" z-index:0 name="hsbc_hpe" id="hsbc_hpe">');
        document.write('<param name=movie VALUE="' + cz_mantel_flash + '">');
        document.write('<param name=wmode value=transparent>');
        document.write('<param name=quality VALUE=autohigh>');
        document.write('<param name=LOOP value=false>');
        document.write('<param name=visibility value=\'hidden\'>');
        document.write('</OBJECT>');
        if (!cz_overtime){
            document.write('<param name=visibility value=\'visible\'>');
        }
    }
	
}

function do_crazy() {

checkB();
	if (IE){
		if (!cz_overtime){
			window.onresize = new Function("window.location.reload()");
			document.all.hsbc_hpe.style.visibility = "visible";
		}
		else{
//			window.onload = cz_leftIcon();
			window.onresize = new Function("window.location.reload()");
			cz_leftIcon();
		}
	}
	else if (NS4){
		window.onload = cz_leftIcon();
		window.onresize = new Function("window.location.reload()");
		cz_leftIcon();
	}
	else if (NS6){
		window.onload = cz_leftIcon();
		window.onresize = new Function("window.location.reload()");
		cz_leftIcon();
	}
	else if (OP6){
		window.onload = cz_leftIcon();
		window.onresize = new Function("window.location.reload()");
		cz_leftIcon();
	}

}


function hideSwf(){
	if (IE){
		document.all.hsbc_hpe.style.visibility = "hidden";
		cz_leftIcon();
		RePlayAds();
	}
}	

function pop_cz_window()
{
	window.open(cz_crazy_adlink);
}

function cz_leftIcon(){
  
	if (IE||OP6) {
		document.all("watermark").style.visibility = "hidden";
	}
	else if (NS6) {
		document.getElementById("watermark").style.visibility="hidden";
	}
	else if (NS4){
		document.layers["watermark"].visibility = "hide";
	}
   setTimeout('cz_moveBall()',5);
   
}

var couplet_has_left='';
function cz_moveBall() {
		if (IE || OP6) {
			document.all("watermark").style.left = cz_xPos;
            if(!couplet_has_left) {
			    document.all("watermark").style.top = cz_yPos + document.body.scrollTop;
            } else {
			    document.all("watermark").style.top = 450;
            }
			document.all("watermark").style.visibility = "visible";
        }
		else if (NS6) {
			document.getElementById("watermark").style.left = cz_xPos;
			document.getElementById("watermark").style.top = cz_yPos + pageYOffset;
			document.getElementById("watermark").style.visibility="visible";
		}
		else if (NS4) {
			document.layers["watermark"].left = cz_xPos;
			document.layers["watermark"].top = cz_yPos + pageYOffset;
			document.layers["watermark"].visibility = "show";
		}
      setTimeout('cz_moveBall()',400);
}

function checkB(){
    this.ver = navigator.appVersion;
    this.name = navigator.appName;
    this.agent = navigator.userAgent;
    this.dom = document.getElementById?1:0;
    this.OP6 = ((this.agent.indexOf("Opera 6")>-1)) ?1:0;
    this.IE = ((this.ver.indexOf("MSIE")>-1) && !this.OP6) ?1:0;
    this.NS4  = (document.layers && !this.dom) ?1:0;
    this.NS6 = (this.dom && (parseInt(this.ver) >=5)) ?1:0;
}

function openWindow(theURL,winName) { //v2.0

    abc=window.open(theURL,'popupwin','width=800,height=549,top=100,left=100,status=yes,alwaysRaised=yes, scrollbars=no, resizable=yes, statusbar=no' );

}

function cz_playAgain()
{
	if(IE)
    {
        document.all.hsbc_hpe.style.visibility = "visible";
        document.all.hsbc_hpe.play();
		window.onresize = new Function("window.location.reload()");
	}
	else
    {
		window.location.reload();
		window.onresize = new Function("window.location.reload()");
	}
}


function RePlayAds() {
  if(document.all && window.navigator.product==null){
  var Ads = document.images;
  for(var i=0;i<Ads.length;i++)
  {
    var rpad = true;
	rpad =  ( Ads[i].src.toString().toLowerCase().indexOf("cn.yimg.com/a/")>=0);
	rpad = rpad || ( Ads[i].src.toString().toLowerCase().indexOf("cn.yimg.com/i/")>=0);
	rpad = rpad && (  ( parseInt(Ads[i].width) * parseInt(Ads[i].height) ) > 10       );
	if(rpad){Ads[i].src = Ads[i].src ;}
  }
  }
}


