﻿//显示Flash
function ShowFlash(url,width,height){
        document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+width+'" height="'+height+'" VIEWASTEXT>');
        document.write('<param name="movie" value="' + url + '">');
        document.write('<param name="quality" value="high"> ');
//        document.write('<param name="wmode" value="transparent"> ');
//        document.write('<param name="menu" value="false"> ');
        document.write('<embed src="' + url + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed> ');
        document.write('</object> ');
}

//显示带参数的Flash
function ShowFlashByParam(url,param,width,height)
{
	var value = getQueryString(param);
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + width + '" height="' + height + '" VIEWASTEXT>');
	document.write('<param name="movie" value="' + url + '" />');
	document.write('<param name="FlashVars" value="' + param + '=' + value + '" />');
	document.write('<param name="quality" value="high" />');
	document.write('<embed src="' + url + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>');
	document.write('</object>');
}

//显示Flash广告
function ShowFlashAD(images, links, texts, width, height)
{
	var focus_width=width
	var focus_height=height
	var text_height=21
	var swf_height = focus_height+text_height
	var pics=images
	var links=links
	var texts=texts
	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"><param name="movie" value="../images/flash/pixviewer.swf"><param name="quality" value="high"><param name="bgcolor" value="#F0F0F0">');
	document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
	document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
	document.write('<embed src="../images/flash/pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&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 ShowVideo(url,width,height)
{
	document.write( '<EMBED id=MediaPlayer src="' + url + '" width="' + width + '" height="' + height + '" loop="false" autostart="true"></EMBED>');
}

//获取查询字符串
function getQueryString(key)
{
	var strS, re , qValue;
	re = "\?";
	strS = document.location.search.replace(re, "");
	var sList = strS.split('&');
	var i , sList2;
	qValue = "";
	for(var i=0;i < sList.length ; i++)
	{
		sList2 = sList[i].split('=');
		if ( sList2[0] == key )
		{
			qValue = sList2[1];
		}
	}
	return unescape(qValue);
}

//切换Tab
function ChangeTab(tag,index,length,sel,nusel)
{
	var flag = true;
	var obj = null;
	for( var i = 0; i < length; i++ )
	{
		obj = document.getElementById( tag + i );
		if( i == index )
		{
			if( obj.className == sel )
			{
				return false;
			}
			else
			{
				obj.className = sel;
			}
		}
		else
		{
			obj.className = nusel;
		}
	}
	return true;
}

function TabChangeEvent(tag, index, length, select, nuselect)
{
	if( ChangeTab(tag, index, length, select, nuselect) )
	{
		for( var i = 0; i < length; i++ )
		{
			if( i != index )
			{
				document.getElementById( tag + "_" + i ).style.display = "none";
			}
		}
		document.getElementById( tag + "_" + index ).style.display = "block";
	}
}

//创建单个商品显示块
function CreateProductBlock(name,imgScr,url)
{
	var html = '';
	html += '<div class="box">';
	html += '<a href="' + url + '">';
	html += '<div class="border_c7c5c5"><img src="' + imgScr + '" width="92" height="72"></div>';
	html += '<div>' + name + '</div>';
	html += '</a>';
	html += '</div>';
	
	return html
}
	
//转换日期
function ConvertDate(date)
{
	date = date.toLocaleDateString();
	date = date.replace('年','-');
	date = date.replace('月','-');
	date = date.replace('日','');
	return date;
}

//截取字符串
function SubString(str, length) 
{     
	var r = /[^\x00-\xff]/g; 
	
	if(str.replace(r, "mm").length <= length) return str;
	
	var m = Math.floor(length / 2); 
	for(var i = m; i < str.length; i++) 
	{ 
		if(str.substr(0, i).replace(r, "mm").length >= length) 
		{
			return str.substr(0, i); 
		} 
	} 

	//document.write(str);
	return str;
} 
//图片自适应大小
function ResizeImage(obj, MaxW, MaxH)
{  
    var imageObject;
    if (obj != null) imageObject = obj;
    
    var oldImage = new Image();
    oldImage.src = imageObject.src;
    var dW=oldImage.width; var dH=oldImage.height;
    if(dW>MaxW || dH>MaxH) {
        a=dW/MaxW; b=dH/MaxH;
        if(b>a) a=b;
        dW=dW/a; dH=dH/a;
    }
    if(dW > 0 && dH > 0) {
        imageObject.width=dW;
		imageObject.height=dH;
	}
}