﻿// JScript 文件
function addIco(){
     var icoLink = document.createElement('link');
     icoLink.href="/fav.ico";
     icoLink.rel="shortcut icon";
     document.documentElement.firstChild.appendChild(icoLink);
}

addIco();//加入ICO图标

function Resize(ImgD,my_w,my_h){ 
 var image=new Image(); 
 image.src=ImgD.src; 
 if(image.width>0 && image.height>0){ 
  flag=true; 
  if(image.width/image.height>= my_w/my_h){ 
   if(image.width>my_w){
    ImgD.width=my_w; 
    ImgD.height=(image.height*my_w)/image.width; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
  } 
  else{ 
   if(image.height>my_h){
    ImgD.height=my_h; 
    ImgD.width=(image.width*my_h)/image.height; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
  } 
 }
}

function URLencode(sStr) 
{
    return escape(sStr).replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27').replace(/\//g,'%2F');
}

function URLdecode(sStr) 
{
    return  unescape(sStr.replace('%2F','/').replace('%27','\'').replace('%22','/"').replace('%2B','+'));
}


function openwin(url,w,h){
	window.open(url,'','width='+w+',height='+h);
}


function doSearch(pid){
var keywd = $("#keywd").val();
var purl ="/showResult.shtml?pid="+pid+"&";
if(keywd!=''){
purl+='keywd='+URLencode(keywd);

if(/^[\w:\./]+showResult\.shtml\?[\w%=&]+$/gi.test(location.href)) //搜索页
location.href=purl;
else
window.open(purl,'');

}
}

//--------------------------------------------------------
//网站登录 8-22 , 12-19
//--------------------------------
function loginck(){
var account = $("#top .apb #account").val();
var passwd = $("#top .apb #passwd").val();

if(account!='' && passwd!=''){
var sendatas;
sendatas ="cmd=loginck&account="+account+"&passwd="+passwd;
$.ajax({ type: "POST", url: "/login.aspx",data:sendatas,dataType:"json",success: function(callback){dologinback(callback,"loginck");},error:function(){return false;}});
}
}

function dologinback(json,cmd){
var pass =json.pass;
if(pass == 'True')
loginedRender();
else{
if(cmd == "loginck" )
location.href='/login.aspx?err=loginfailed';
}
}

function islogin(){
var sendatas;
sendatas ="cmd=loginck2";
$.ajax({ type: "POST", url: "/login.aspx",data:sendatas,dataType:"json",success: function(callback){dologinback(callback,"islogin");},error:function(){return false;}});
}

function loginedRender(){
$("#top .apb .unlogin").hide(0);
$("#top .apb .logined").html('欢迎登录台州在线 <a href="/ubackmg" target="_blank" > [用户后台管理] </a>');
$("#top .apb .logined").css({"text-align":"left","padding-top":"3px","display":"block"});
$("#top .apb .logined").fadeIn();
}
//--------------------------------------------------------

function gdw_Loadbar(){
	
	this.top =10;
	this.left =10;
	this.bs =3;
		
	this.init = function(){
	
	    $('#loadbar').remove();
		var htmstr ='';
		htmstr +='<div id="loadbar" style="position:absolute;top:'+this.top+'px;left:'+this.left+'px;z-index:18;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=80,style=0);-moz-opacity: 0.8;">';
		htmstr +='<div style="color:#333333;background-color:#F1F1Ff; border:1px #CCCCCC solid;width:200px;padding:5px;">';
		htmstr +='<div id="l_info">初始化完成.</div>';
		htmstr +='</div>';
		
		$(document.body).append(htmstr);		
	}
	
	this.cinfo= function(ifo){
		$("#l_info").html(ifo);
	}
	
	this.dispose =function(){
	$("#loadbar").fadeOut(1200);
	setTimeout("$('#loadbar').remove();",3000); 
	}
}


var oDiv,oDialog
//建立背景层
function Create_div(bgcolor,alpha)
{
	if($("#oDiv").attr("id")!="oDiv"){
	oDiv = jQuery(document.createElement("div"));
    var ht=document.body.scrollHeight;
	var wh=document.body.clientWidth;
	if(ht<document.body.clientHeight) ht=document.body.clientHeight;
	
	oDiv.css({zIndex: 50, position	: 'absolute',  top	: '0', left: '0', width : ''+wh+'px', height: ''+ht+'px', opacity: ''+alpha+'',  backgroundColor: ''+bgcolor+''	});
	oDiv.attr("id","oDiv");
	jQuery('body').append(oDiv);
	}
}

function oCreate(top,left,w,bgcolor,alpha)
{
	$("#oDialog").remove();
	Create_div(bgcolor,alpha);
    oDialog=jQuery(document.createElement("div"));
	oDialog.attr("id","oDialog");
	
	oDialog.css({zIndex: 100, position	: 'absolute',  top	: ''+top+'', left: ''+left+'',  backgroundColor: '#ffffff'	});
	var dghtm ="<div class='con' style='width:"+w+";border:3px #666666 solid;color:#666666;'>Loading...</div>";
	oDialog.html(dghtm);
	
	jQuery('body').append(oDialog);
	
	var oDDivCon = $("#oDialog .con");
	return oDDivCon;
}


function Loadswf(src,w,h){		 
var html="";
html+='<object codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 width="'+w+'" height="'+h+'" '; 
html+='classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000>';
html+='<param name="movie" value="'+src+'">';
html+='<param name="quality" value="high">';
html+='<param ="false" name="menu"/>';
//<param ="opaque" name="wmode"/>
html+='<param name="wmode" value="opaque">';
//html+='<param name="wmode" value="transparent">';
html+='<embed src="'+src+'" quality="high"  pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'" >';
html+='</embed></object>';
return html;
//结束	
}

function ShowHAD(focus_width,focus_height,text_height,pics,links,texts){
var swf_height = focus_height+text_height;

document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
document.write('<param name="allowScriptAccess" value="sameDomain"/>');
document.write('<param name="movie" value="/CFolders/pixviewer.swf"/>');
document.write('<param name="quality" value="high"/>');
document.write('<param name="bgcolor" value="#FFFFFF"/>');
document.write('<param name="menu" value="false"/>');
document.write('<param name="wmode" value="opaque"/>');
document.write('<param name="FlashVars" value="pics='+pics+'&amp;links='+links+'&amp;texts='+texts+'&amp;borderwidth='+focus_width+'&amp;borderheight='+focus_height+'&amp;textheight='+text_height+'"/>');
document.write('<embed src="/CFolders/pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&amp;links='+links+'&amp;texts='+texts+'&amp;borderwidth='+focus_width+'&amp;borderheight='+focus_height+'&amp;textheight='+text_height+'" menu="false" bgcolor="#F0F0F0" quality="high" width="'+ focus_width +'" height="'+ focus_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write('</object>');	
//结束	
}	

function flvplay(flv,width,height,pcolor){
var flvHtml ='';

flvHtml+='<object type="application/x-shockwave-flash"';
flvHtml+=' data="/CFolders/vcastr3.swf?xml=<vcastr>';
flvHtml+='	<channel>';
flvHtml+='		<item>';
flvHtml+='			<source>'+flv+'</source>';
flvHtml+='			<duration></duration>';
flvHtml+='			<title></title>';
flvHtml+='		</item>';
flvHtml+='	</channel>';

flvHtml+=' </vcastr>"';
flvHtml+=' width="'+width+'" height="'+height+'" id="vcastr3">';
flvHtml+=' <param name="movie" value="/CFolders/vcastr3.swf?xml=<vcastr>';
flvHtml+='	<channel>';
flvHtml+='		<item>';
flvHtml+='			<source>'+flv+'</source>';
flvHtml+='			<duration></duration>';
flvHtml+='			<title></title>';
flvHtml+='		</item>';
flvHtml+='	</channel>';
flvHtml+='	        <config>';
flvHtml+='                <bufferTime>4</bufferTime>';
flvHtml+='                <contralPanelAlpha>0.75</contralPanelAlpha>';
flvHtml+='                <controlPanelBgColor>0x'+pcolor+'</controlPanelBgColor>';
flvHtml+='                <controlPanelBtnColor>0xffffff</controlPanelBtnColor>';
flvHtml+='                <contralPanelBtnGlowColro>0xffff00</contralPanelBtnGlowColro>';
flvHtml+='                <controlPanelMode>float</controlPanelMode>';
flvHtml+='                <defautVolume>0.8</defautVolume>';
flvHtml+='                <isAutoPlay>true</isAutoPlay>';
flvHtml+='                <isLoadBegin>true</isLoadBegin>';
flvHtml+='                <isShowAbout>falsel</isShowAbout>';
flvHtml+='                <scaleMode>showAll</scaleMode>';
flvHtml+='        </config>';

flvHtml+=' </vcastr>" />';
flvHtml+=' <param name="allowFullScreen" value="true" />';
flvHtml+='</object>';

return flvHtml;
}

function showCpInf(cpage,maxpage,pm){
var pinfHtmStr ='';
pinfHtmStr +=' <span class="infbak">当前第'+cpage+'页/共'+maxpage+'页</span> ';

if(cpage>1){
pinfHtmStr +=' <span class="link"><a href="?page=1'+pm+'">首页</a></span> ';
pinfHtmStr +=' <span class="link"><a href="?page='+(cpage-1)+pm+'">上页</a></span> ';
}
else{
pinfHtmStr +=' <span>首页</span> ';
pinfHtmStr +=' <span>上页</span> ';
}

var sid,eid;
var pz =3;
sid = cpage-pz; if(sid<1)sid=1;
eid = cpage+pz; if(eid>maxpage)eid=maxpage;

for(p=sid;p<=eid;p++){
if(p == cpage)
pinfHtmStr +=' <span class="cp">'+p+'</span> ';
else
pinfHtmStr +=' <span class="link"><a href="?page='+p+pm+'">'+p+'</a></span> ';
}

if(cpage<maxpage){
pinfHtmStr +=' <span class="link"><a href="?page='+(cpage+1)+pm+'">下页</a></span> ';
pinfHtmStr +=' <span class="link"><a href="?page='+maxpage+pm+'">尾页</a></span> ';
}
else{
pinfHtmStr +=' <span>下页</span> ';
pinfHtmStr +=' <span>尾页</span> ';
}

pinfHtmStr +=' <div style="clear:both" ></div>';

$("div.gd_pinf").html(pinfHtmStr);
$("div.gd_pinf span.link").mouseover(function(){this.style.borderColor="blue"});
$("div.gd_pinf span.link").mouseout(function(){this.style.borderColor="#cccccc"});
}

