﻿// JScript 文件

//使IE 7以下版本能正确显示PNG图像
function correctPNG(){
    for(var i=0; i<document.images.length; i++){
        var img = document.images[i];
        var imgName = img.src.toUpperCase();
        if (imgName.substring(imgName.length-3, imgName.length) == "PNG"){
            var imgID = (img.id) ? "id='" + img.id + "' " : "";
            var imgClass = (img.className) ? "class='" + img.className + "' " : "";
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
            var imgStyle = "display:inline-block;" + img.style.cssText;
            if (img.align == "left") imgStyle = "float:left;" + imgStyle;
            if (img.align == "right") imgStyle = "float:right;" + imgStyle;
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;        
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
                            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
                            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
            img.outerHTML = strNewHTML;
            i--;
        }
    }
}

//获得IE版本
function ieVersion(){
    var ua=window.navigator.userAgent;
    var msieIndex=ua.indexOf("MSIE");
    if(msieIndex== -1) return 0;
    var thisVersion=ua.substring(msieIndex,ua.length-1);
    thisVersion=thisVersion.substring(0,thisVersion.indexOf(";"));  
    var tempStr="";
    var tempVersion="";
    var numStr="0123456789.-";
    for(i=0;i<thisVersion.length;i++){
        tempStr=thisVersion.substr(i,1);
        if(numStr.indexOf(tempStr)>-1) tempVersion+=tempStr;
    }
    thisVersion=tempVersion;
    return thisVersion;
}

var ie=Math.ceil((ieVersion().toString()).split(".")[0]);
if(ie>0&&ie<7) window.attachEvent("onload", correctPNG);

//加入收藏夹
function myAddPanel(title,url,desc) 
{ 
    if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function'))

//Gecko 
    { 
        window.sidebar.addPanel(title,url,desc); 
    } 
    else

//IE 
    { 
        window.external.AddFavorite(url,title); 
    } 
} 

//生成无边框的FLASH
function buildFlash(swfName,width,height,objectName,parentNodeName,FlashVars)
{
	s="";
	s+="<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=9,0,28,0' WIDTH='"+width+"' HEIGHT='"+height+"' id='"+objectName+"'>";
	s+="<PARAM NAME='movie' VALUE='"+swfName+"' />";
	s+="<PARAM NAME='quality' VALUE='high' /> ";
	s+="<PARAM NAME='wmode' VALUE='transparent' /> ";
	s+="<param name='allowFullScreen' value='true' />";
	s+="<param name='menu' value='false' />";
	s+="<param name='allowScriptAccess' value='*' />";
	if(FlashVars) s+="<param name='FlashVars' value='"+FlashVars+"' />";
	s+="<EMBED src='"+swfName+"' quality='high' name='"+objectName+"' swLiveConnect='true' allowScriptAccess='*' TYPE='application/x-shockwave-flash' PLUGINSPAGE='http:\/\/www.macromedia.com\/go\/getflashplayer' WIDTH='"+width+"' HEIGHT='"+height+"' wmode='transparent'";
	if(FlashVars) s+=" FlashVars='"+FlashVars+"'";
	s+="></EMBED>";
	s+="</OBJECT>";
	if(parentNodeName) parentNodeName.innerHTML=s;
	else document.write(s);
}

//生成video flash[BarTransparent 底部播放栏颜色，IconColor 暂停时的屏幕中间的播放图标颜色和底部的按钮颜色，TextColor 底部播放栏的文字颜色，GlowColor 控制按钮颜色的外围光的颜色]
function buildFlashvideo(swf_width,swf_height,files,autoplay){
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'+ swf_width +'" height="'+ swf_height +'">');
    document.write('<param name="movie" value="/images/video.swf"><param name="quality" value="high">');
    document.write('<param name="menu" value="false"><PARAM NAME="wmode" VALUE="transparent" /><param name="allowFullScreen" value="true" />');
    document.write('<param name="FlashVars" value="vcastr_file='+files+'&BarPosition=1&IsShowBar=1&IsAutoPlay='+autoplay+'&BarTransparent=100&BarColor=0x333333&IconColor=0xFFFFFF&TextColor=0xFFFFFF&GlowColor=0x000000&IsContinue=0">');
    document.write('<embed src="/images/video.swf" allowFullScreen="true" FlashVars="vcastr_file='+files+'&BarPosition=1&IsShowBar=1&IsAutoPlay=0&BarTransparent=100&BarColor=0x33333&IconColor=0xFFFFFF&TextColor=0xFFFFFF&GlowColor=0x000000&IsContinue=1" menu="false" quality="high" width="'+ swf_width +'" height="'+ swf_height +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); document.write('</object>'); 
}



//判断是否为空
function FormIsempty(_s)
{
	if(!_s) return true;
	if(_s.replace(/(^\s*)|(\s*$)/g, "")=="") return true;
	return false;
}

//开始搜索
function toSearch(e,v){
    var key=window.event?window.event.keyCode:e.which;
    if(key==13){
        location.href='/member/search.aspx?v='+v;
        return false;
    }
    return true;
}



//获取元素的纵坐标
function getTop(e){
    var offset=e.offsetTop;
    if(e.offsetParent!=null) offset+=getTop(e.offsetParent);
    return offset;
}

//获取元素的横坐标
function getLeft(e){
    var offset=e.offsetLeft;
    if(e.offsetParent!=null) offset+=getLeft(e.offsetParent);
    return offset;
}

//文本框mouseover变色
function fEvent(sType,oInput)
{
		switch (sType){
			case "focus" :
				oInput.isfocus = true;
			case "mouseover" :
				//oInput.style.borderColor = '#9ecc00';
				oInput.style.borderColor = '#990000';
				break;
			case "blur" :
				oInput.isfocus = false;
			case "mouseout" :
				if(!oInput.isfocus){
					oInput.style.borderColor='#84a1bd';
				}
				break;
		}
}



