/*弹出消息效果*/
popalert = function(txt,title,vclose)
{
if 	(!title) title = 'System info';

if 	(!vclose) vclose = ' style="display:none" ';

if ((navigator.userAgent.indexOf('MSIE') >= 0) && (navigator.userAgent.indexOf('Opera') < 0)){
	//alert('你是使用IE')
	var ie = true;
}else{	
}


if(document.readyState=="complete" || !ie )	 {
	var shield = document.createElement("DIV");
	 shield.id = "shield";
	 shield.style.position = "absolute";
	 shield.style.left = "0px";
	 shield.style.top = "0px";
	 shield.style.width = "100%";
	 shield.style.height = document.body.scrollHeight+"px";
	 shield.style.background = "#333";
	 shield.style.textAlign = "center";
	 shield.style.zIndex = "10000";
	 shield.style.filter = "alpha(opacity=0)";
	 var alertFram = document.createElement("DIV");
	 alertFram.id="alertFram";
	 alertFram.style.position = "absolute";
	 alertFram.style.left = "50%";
	 alertFram.style.top = "100px";
	 alertFram.style.marginLeft = "-225px";
	 alertFram.style.marginTop = "120px";
	 alertFram.style.width = "450px";
	 alertFram.style.height = "150px";
	// alertFram.style.background = "#ccc";
	 alertFram.style.textAlign = "center";
	 alertFram.style.lineHeight = "20px";
	 alertFram.style.zIndex = "10001";
	strHtml ="<div style='width:500px; height:300px'><table cellpadding=\"0\" cellspacing=\"0\">";
	strHtml +="	<tr>";
	strHtml +="		<td width=22 height=50 style='border-width: 0pt; background: url(/images/topleft.png);'><\/td>";
	strHtml +="		<td width=411 align=right style='border-width: 0pt; padding: 1px; background-repeat: repeat-x; background: url(/images/top.png);'>";
	strHtml +="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
	strHtml +="      <tr>";
	strHtml +="        <td width=\"80%\" align=left ><b style='color:#ffffff'>"+title+"</b><\/td>";
	strHtml +="        <td width=\"20%\" align=\"right\"><img style=\"cursor: pointer;\" "+vclose+" src=\"\/images\/closewindow.gif\" class=\"js_ui_BaseWindow_Button\" onclick=\"doOk();doSelects('')\">&nbsp;<\/td>";
	strHtml +="      <\/tr>";
	strHtml +="    <\/table>";
	
	strHtml +="<\/td>";
	strHtml +="		<td width=\"23\"  style=\"border-width: 0pt; background-repeat: repeat-x; background: url(\/images\/topright.png);\">&nbsp;<\/td>";
	strHtml +="	<\/tr>";
	strHtml +="	<tr>";
	strHtml +="		<td height=\"200\"  style=\"border-width: 0pt; background: url(/images\/left.png);\">&nbsp;<\/td>";
	strHtml +="		<td style=\"background: url(/images\/rms.png); background-repeat:no-repeat; background-color:#fff;  color:#000000;background-position:right bottom; \">"+txt+"<\/td>";
	strHtml +="		<td style=\"border-width: 0pt; background: url(/images\/right.png);\" class=\"js_ui_BaseWindow_BorderRight\">&nbsp;<\/td>";
	strHtml +="	<\/tr>";
	strHtml +="	<tr class=\"js_ui_BaseWindow_BorderBottom\">";
	strHtml +="		<td height=\"30\" style=\"border-width: 0pt; background-repeat: repeat-x; background: url(/images\/bottomleft.png);\">	<\/td>";
	strHtml +="		<td style=\"border-width: 0pt; background-repeat: repeat-x; background: url(\/images\/bottom.png);\">			<\/td>";
	strHtml +="		<td style=\"border-width: 0pt; background-repeat: repeat-x;background: url(\/images\/bottomright.png)\">			<\/td>";
	strHtml +="	<\/tr>";
	strHtml +="<\/table></div>";

	 alertFram.innerHTML = strHtml;
	 //abc.innerText =  encodeURIComponent(strHtml);
	 document.body.appendChild(alertFram);
	 document.body.appendChild(shield);
	 
	 setTimeout('doSelects(\'hidden\');',1);
	
	 //table_png();
		
	 var c = 0;
	 this.doAlpha = function(){
	 if (c++ > 20){clearInterval(ad);return 0;}
	 shield.style.filter = "alpha(opacity="+c+");";
	 }
	 var ad = setInterval("doAlpha()",5);
	 this.doOk = function(){
	 alertFram.style.display = "none";
	 shield.style.display = "none";	 
	 }	 
	 alertFram.focus();
	 document.body.onselectstart = function(){return false;};
	 
}else{
	setTimeout('popalert("'+txt+'","'+title+'","'+vclose+'");',1000);
}
	
 
}
function doSelects(str){//隐藏或者显示
var selects = document.getElementsByTagName('select');
if(selects) 
{
	for(var i=0;i<selects.length;i++){
		 selects[i].style.visibility= str;		
	}
}
}
 
function table_png(){
	var tables =  document.getElementsByTagName('td');
	if(tables) 
	{
		for(var i=0;i<tables.length;i++){
		var x   =   tables[i].style.background;   
			x   =   x.replace("url(", "");  
			x   =   x.replace(")", "");
			x   =   x.toUpperCase();
			if (x.substring(x.length-3, x.length) == 'PNG'){
			tables[i].style.background ='';
			tables[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+x+"',sizingMethod='scale' )";
			//  filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='FOIABack2.png',sizingMethod='image')
	
			}
			
		}
	}
}
/*帐号 评语检查*/
function check_comment(f){
	
	if (f.username.value.replace(/\s+/, "") == "") {
		alert('Please input your name');
		f.username.focus();
		return false;
	}	

	if (f.email.value.replace(/\s+/, "") == "") {
		alert('Please input your Email Address.');
		f.email.focus();
		return false;
	}	
	if (!checkmail(f.email.value)) {
		f.email.focus();
		return false;
	}

	if (f.comment.value.replace(/\s+/, "") == "") {
		alert('Please input the your Comment.');
		f.comment.focus();
		return false;
	}	
}
/*按比例缩放图片,使用方法: <IMG onload=DrawImage(this,300,180)  ...*/	
function DrawImage(ImgD,FitWidth,FitHeight){
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
   if(image.width/image.height>= FitWidth/FitHeight){ 
   if(image.width>FitWidth){
    ImgD.width=FitWidth;
    ImgD.height=(image.height*FitWidth)/image.width;
    }else{
     ImgD.width=image.width;
     ImgD.height=image.height;
     }
    }
    else{
     if(image.height>FitHeight){
       ImgD.height=FitHeight;
       ImgD.width=(image.width*FitHeight)/image.height;
       }else{
        ImgD.width=image.width;
        ImgD.height=image.height;
       }
      }
     }
}

//显示tab
function showtab(tabId,titleTag,contentTag){
	
	h=document.getElementById(tabId).getElementsByTagName(titleTag);
	d=document.getElementById(tabId).getElementsByTagName(contentTag);
	for(var i=0;i<h.length;i++){	  
	  	 h[i].rel = i+1;	   
	  	 h[i].onclick = function(){
			 go_to(this.rel);
		 }
	  }
	go_to =  function (ao){
	  for(var i=0;i<h.length;i++){
	   if(ao-1==i){
	   h[i].className+=" up";
	   d[i].className+=" block";
	   }
	   else {
	   h[i].className=" ";
	   d[i].className=" ";
	   }
	  }
	}


}

function addWatch(obj,id){
	
	$.get('/index.php?action=auction&act=watch&operate=add&id='+id,function(d,e){

		if(d=='1'){			
			ShowHtmlString('<h3 align="center">You have successfully added this item to your watching list on My Account Center department.</h3><h3 align="center"><a href="/?action=member&operate=auction#watching"><u>See watching</u></a></h3>','Attention',500,100);//添加到关注列表成功
		}else{
			ShowHtmlString('<h3 align="center">This item has already been in your watching list.</h3><h3 align="center"><a href="/?action=member&operate=auction#watching"><u>See watching</u></a></h3>','Attention',500,100);//已经添加过
		}
	
	});

}

function deleteWatch(obj,id){
	if(confirm('Are you sure to delete this item?')){
		
		$.get('/index.php?action=auction&act=watch&operate=delete&id='+id,function(d,e){
		obj.parent().parent().hide();
			//alert(e);
			//alert(d);
		});
	
	}else{
		return false;	
	}


}