function showtt(id) {
		var picshow_tip = '<TABLE cellSpacing=0 cellPadding=0 width=120 border=0><TBODY><TR><TD width=28><IMG height=26 alt="" src="/images/tt_01.png" width=28></TD><TD vAlign=baseline background="/images/tt_02.png">&nbsp;<A href="javascript:oldshow(\'mainImage\')">Zoom</A></TD><TD width=28><IMG onclick=javascript:closett() height=26 alt="" src="/images/tt_04.png" width=28 border=0></TD></TR></TBODY></TABLE><TABLE cellSpacing=0 cellPadding=0 width=120 border=0><TBODY><TR><TD width=35><IMG height=24 alt="" src="/images/tt_12.png" width=35></TD><TD background="/images/tt_13.png">&nbsp;</TD><TD width=28><IMG height=24 alt="" src="/images/tt_14.png" width=28></TD></TR></TBODY></TABLE>';
		var popTip = document.getElementById("popTip")
        var tt = document.getElementById(id);
        popTip.innerHTML = picshow_tip
        var  daps   =  popTip.style;
        var  ttop   =  tt.offsetTop;          
        var  thei   =  tt.clientHeight;         
        var  tleft  =  tt.offsetLeft;        
        var  ttyp   =  tt.type;                    
        while( tt   =  tt.offsetParent )
        {
                ttop+=tt.offsetTop;  tleft+=tt.offsetLeft;
        }
        daps.top = ttop;  
        daps.left = tleft+820;  
        popTip.style.display = "block";
}
function closett()
{
        document.getElementById("popTip").style.display="none";
}

oldwidth = 0;
oldheight = 0;
function newshow(img) { 
	oldwidth = img.width;
	oldheight = img.height;
	if(img.width>730) {
		img.width=730;
		img.height=oldheight*730/oldwidth;
		showtt('mainImage');
	}
}
function newshow2(img,photoID,photoUrl) { 
	oldwidth = img.width;
	oldheight = img.height;
	if(img.width>730) {
		img.width=730;
		img.height=oldheight*730/oldwidth;
		showtt('mainImage');
	}
	
	showScore(photoID);
}
function oldshow(id) { 
	var img = document.getElementById(id);
	window.open("/showimage.html?"+img.src);
	document.getElementById("popTip").style.display="none";
}

function showEndDiv(id,mtype,name,pictype,ishave){
	var returnurl = ""
	var urlname = buileUrlName(name)
	if(mtype==1){
		switch(pictype){
			case 1:
				returnurl = "/movie/"+ urlname + "-" + id + "/photo_gallery.html";break;
			case 2:
				returnurl = "/movie/"+ urlname + "-" + id + "/poster.html";break;
			case 3:
				returnurl = "/movie/"+ urlname + "-" + id + "/wallpaper.html";break;
			case 4:
				returnurl = "/movie/"+ urlname + "-" + id + "/dvd_cover.html";break;
		}
	}else{
		switch(pictype){
			case 1:
				returnurl = "/celebrity/"+ urlname + "-" + id + "/photo.html";break;
			case 2:
				returnurl = "/celebrity/"+ urlname + "-" + id + "/daily_photo.html";break;
			case 3:
				returnurl = "/celebrity/"+ urlname + "-" + id + "/wallpaper.html";break;
		}

	}
	//alert(returnurl);
	window.location.href=returnurl;
	//if (document.readyState!='complete') return;
	//var str = '<iframe frameborder="0" width="100%" scrolling="no" marginheight="0" marginwidth="0" align="middle" height="100%" src="/cmd/showendpicpage4en.aspx?id='+id+'&type='+mtype+'&name='+encodeURIComponent(name)+'&pictype='+pictype+'&ishave='+ishave+'"></iframe>';
	//showWindow(str);
}
function hiddenThis(){
	document.body.removeChild(document.getElementById("center"));
	if(document.getElementById("TB_overlay"))
	document.body.removeChild(document.getElementById("TB_overlay"));
}

function showWindow(str){
	if (document.readyState!='complete') return;
	var odiv = document.createElement("div");
	odiv.setAttribute("id","center");
	odiv.innerHTML = str;
	odiv.style.display='';
	odiv.onclick=function(){
		odiv.style.display='none';
	}
	var overflow = document.createElement("div");
	overflow.setAttribute("id","TB_overlay");
	document.body.appendChild(overflow);
	document.body.appendChild(odiv);
	return odiv;
}
function OKSelected() {
	return;
}

function showScore(photoid){
	var template = '<fieldset class="rate_fieldset"><legend>Rate</legend><a class="portrait" href="{pre}"><img src="http://blog.bitcomet.com/Photos/style/images/slider_left.gif" alt="Tips: Use 0-9 to rate. 0 equals to 10 points. ¡ú to Next, ¡û Previous." /></a><label class="portrait"><input type="radio" name="qops" id="qops0" value="1" photoid="{photoid}" onclick="window.open(doScore(this),\'game_photo\');"/><span>1</span> </label><label class="portrait"><input photoid="{photoid}" type="radio" name="qops" id="qops1" value="2" onclick="window.open(doScore(this),\'game_photo\');"/><span>2</span> </label><label class="portrait"><input photoid="{photoid}" type="radio" name="qops" id="qops2" value="3" onclick="window.open(doScore(this),\'game_photo\');"/><span>3</span> </label><label class="portrait"><input photoid="{photoid}" type="radio" name="qops" id="qops3" value="4" onclick="window.open(doScore(this),\'game_photo\');"/><span>4</span> </label><label class="portrait"><input photoid="{photoid}" photoid="{photoid}" type="radio" name="qops" id="qops4" value="5" onclick="window.open(doScore(this),\'game_photo\');"/><span>5</span> </label><label class="portrait"><input photoid="{photoid}" type="radio" name="qops" id="qops5" value="6" onclick="window.open(doScore(this),\'game_photo\');"/><span>6</span> </label><label class="portrait"><input photoid="{photoid}" type="radio" name="qops" id="qops6" value="7" onclick="window.open(doScore(this),\'game_photo\');"/><span>7</span> </label><label class="portrait"><input photoid="{photoid}" type="radio" name="qops" id="qops7" value="8" onclick="window.open(doScore(this),\'game_photo\');"/><span>8</span> </label><label class="portrait"><input photoid="{photoid}" type="radio" name="qops" id="qops8" value="9" onclick="window.open(doScore(this),\'game_photo\');"/><span>9</span> </label><label class="portrait"><input photoid="{photoid}" type="radio" name="qops" id="qops9" value="10" onclick="window.open(doScore(this),\'game_photo\');"/><span>10</span></label><a class="portrait" href="{next}"><img src="http://blog.bitcomet.com/Photos/style/images/slider_right.gif" alt="Tips: Use 0-9 to rate. 0 equals to 10 points. ¡ú to Next, ¡û Previous." /></a></fieldset>';

	var c = document.getElementById("userPhotoControl");

	var cc = document.createElement("span");
	cc.id = "markBox";
	cc.innerHTML = showScore_parse(template,photoid);

	//c.appendChild(cc);
	c.parentNode.insertBefore(cc,c);
}

function showScore_parse(str,photoid){
	var re = /(\{pre\})/g;
    str = str.replace(re,showScore_getPNPhoto('Prev'));
	var re = /(\{next\})/g;
    str = str.replace(re,showScore_getPNPhoto('Next'));
	var re = /(\{photoid\})/g;
    str = str.replace(re,photoid);
	return str;
}

function showScore_getPNPhoto(schvalue){
	var c = document.getElementById("page_content2");
	var alist = c.getElementsByTagName("a");
	for(var i = 0;i<alist.length;i++){
		if(alist[i].innerHTML.indexOf(schvalue) != -1){
			return alist[i].href;
		}
	}
	return "#";
}


function doScore(obj){
	var durl = "http://blog.bitcomet.com/photos/";
	var i = obj.value,photoid = obj.getAttribute('photoid')
	if (!isLogin())
	{
		return durl;
	}
	var photoType = showScore_getPhotoType();
	var value = photoid + '|' + i + '|' + photoType;
	var url = '/web/aspx/ajax.aspx?value='+value+'&act=doscore';
	var xmlVote = XmlHttpPool.pick();
    try
	{
		document.getElementById('markBox').innerHTML = "Rating...";
		xmlVote.open("GET", url, false);
		xmlVote.send(null);
		return showScore_showresult(eval(xmlVote.responseText));
		
	}
	catch(e)
	{
	    alert('Communication Error!');
		return durl;
	}

	return durl;
}


function showScore_getPhotoType(){
	//1 = movie 2 = person
	var url = document.URL;
	if(url.indexOf('celebrity/') != -1) return 2;
	if(url.indexOf('movie/') != -1) return 1;
}



function showScore_showresult(json){
	//Serial No.1028£¬Participantes:1£¬Total:3£¬Accuracy:3.00£¬Your Rate:3¡£
	document.getElementById('markBox').style.display = 'none';
	var c = document.getElementById("userPhotoControl");
	var frag = document.createDocumentFragment();

	var sdiv = document.createElement("fieldset");
	sdiv.id = "voteinfo";
	sdiv.className = "rate_fieldset";
	frag.appendChild(sdiv);

	var le = document.createElement("legend");
	le.appendChild(document.createTextNode('Result'));
	sdiv.appendChild(le);
	
	var c_dl = document.createElement("dl");
	var c_dl_frag =  document.createDocumentFragment();
	c_dl_frag.appendChild(showScore_showresult_x("Accuracy:","vmark",json));
	c_dl_frag.appendChild(showScore_showresult_x("Total:","totalmark",json));
	c_dl_frag.appendChild(showScore_showresult_x("Participantes:","totalnum",json));
	
	var c_dt = document.createElement("dt");
	var c_dt_a = document.createElement("a");
	if(json.successflag > 0){
		c_dt_a.href = "http://blog.bitcomet.com/photos/"+json.successflag;
	}else{
		c_dt_a.href = "http://blog.bitcomet.com/photos/"
	}
	c_dt_a.target = "_blank";
	c_dt_a.appendChild(document.createTextNode('more>>>'));
	c_dt.appendChild(c_dt_a);
	c_dl_frag.appendChild(c_dt);

	c_dl.appendChild(c_dl_frag);
	sdiv.appendChild(c_dl);

	//c.appendChild(frag);
	c.parentNode.insertBefore(frag,c);

	return c_dt_a.href;
}

function showScore_showresult_x(title,id,json){
	var frag = document.createDocumentFragment();

	var c_dt = document.createElement("dt");
	c_dt.appendChild(document.createTextNode(title));
	frag.appendChild(c_dt);
	var c_dd = document.createElement("dd");
	c_dd.id = id;
	c_dd.appendChild(document.createTextNode(eval("json."+id)));
	frag.appendChild(c_dd);

	return frag;
}