// 常规
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function openw(theURL,features) { //v2.0
  window.open(theURL,"",features);
}

// flash Document
function playswf(sFile,sWidth,sHeight,svar){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+ sWidth +'" height="'+ sHeight +'"> ');
document.write(' <param name="allowScriptAccess" value="sameDomain" /> ');
document.write(' <param name="movie" value="'+ sFile +'"> ');
document.write(' <param name="quality" value="high"> ');
document.write(' <param name="scale" value="noscale"> ');
document.write(' <param name="wmode" value="transparent"> ');
document.write(' <param name="salign" value="t">');
document.write('<param name="FlashVars" value="'+ svar +'">')
document.write(' <embed src="'+ sFile +'" quality="high" scale="noscale" wmode="transparent" salign="t" FlashVars="'+ svar +'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ sWidth +'" height="'+ sHeight +'"></embed> ');
document.write('</object> ');
}

//set thie images'size
var flag=false; 
var w;
w=150;
var h;
h=150;
function DrawImage(ImgD)
{ 
	var image=new Image(); 
	image.src=ImgD.src; 
	if(image.width>0 && image.height>0)
	{ 
		flag=true; 
		if(image.width/image.height>= w/h)
		{ 
			 if(image.width>w)
			 {   
				 ImgD.width=w; 
				 ImgD.height=(image.height*h)/image.width; 
			 }else{ 
				 ImgD.width=image.width;   
				 ImgD.height=image.height; 
			 } 
		}else{ 
			 if(image.height>h)
			 {   
				 ImgD.height=h; 
				 ImgD.width=(image.width*w)/image.height; 
				 if(ImgD.width>w)
				 {
					 ImgD.width=w;
					 ImgD.height=(image.height*h)/image.width;
				 }
			 }else{ 
				 ImgD.width=image.width;   
				 ImgD.height=image.height; 
			 } 
		 } 
	} 
}

//open full windows
var imgObj;
function checkImg(theURL,winName){
  if (typeof(imgObj) == "object"){
	if ((imgObj.width != 0) && (imgObj.height != 0))
	  OpenFullSizeWindow(theURL,winName, ",width=" + (imgObj.width+20) + ",height=" + (imgObj.height+30));
	else
	  setTimeout("checkImg('" + theURL + "','" + winName + "')", 100)
  }
}

function OpenFullSizeWindow(theURL,winName,features) {
  var aNewWin, sBaseCmd;
  sBaseCmd = "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,";
  if (features == null || features == ""){
	imgObj = new Image();
	imgObj.src = theURL;
	checkImg(theURL, winName)
  }
  else{
	aNewWin = window.open(theURL,winName, sBaseCmd + features);
	aNewWin.focus();
  }
}

// 透明弹出系列

function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = yScroll; 
	return arrayPageScroll;
}


function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

// start:
function getNav()
{
	if (window.navigator.userAgent.indexOf('Opera')>=1)
	{
		//alert('Opera');
		return 'Opera';
	}
	else if (window.navigator.userAgent.indexOf('Firefox')>=1)
	{
		//alert('FireFox');
		return 'Firefox';
	}
	else if (window.navigator.userAgent.indexOf('MSIE')>=1)
	{
		//alert('MSIE');
		return 'MSIE';
	}
	else
	{
		//alert('Other');
		return 'other';
	}
}

var minAlpha = 30;
var maxAlpha = 60;
var BGCOLOR = '#353535';
var BGURL = 'url(images/p_alpha.png)';
var outTime = 5;
var changeA = ""; //setTimeoutID

function startAlpha()
{
	getPageScroll();
	getPageSize();
	var alphaObj = document.getElementById('alpha');
	alphaObj.style.position = 'absolute';
	alphaObj.style.top = 0;
	alphaObj.style.left = 0;
	alphaObj.style.zIndex = 1;
	alphaObj.style.width = arrayPageSize[2];
	alphaObj.style.height = arrayPageSize[1];
	alphaObj.style.background = BGCOLOR;
	alphaObj.style.filter="Alpha(opacity="+minAlpha+")";
	alphaObj.style.opacity= minAlpha/100;
	alphaObj.style.display = 'block';
}

function ieAlpha()
{
	if (minAlpha>=maxAlpha)
	{
		clearTimeout(changeA);
		return true;
	}
	var  alpha = document.getElementById('alpha');
		 alpha.style.background = BGCOLOR;
		 alpha.style.filter="Alpha(opacity="+(minAlpha+=5)+")";
		 changeA = setTimeout(ieAlpha,outTime);
}

function foxAlpha()
{
	if (minAlpha>=maxAlpha)
	{
		clearTimeout(changeA);
		return true;
	}
	alpha = document.getElementById('alpha');
	alpha.style.background = BGCOLOR;
	alpha.style.opacity=(minAlpha+=5)/100;
	changeA = setTimeout(foxAlpha,outTime);		
}

function otherAlpha()
{
	alpha = document.getElementById('alpha');
	alpha.style.background = BGURL;
	return true;
}



function disAlpha(){
	var navType = getNav();
	switch (navType)
	{
		case 'Opera':
			otherAlpha();
			break;
		case 'Firefox':
			foxAlpha();
			break;
		case 'MSIE':
			ieAlpha();
			break;
		default:
			otherAlpha();
			break;
	}
}


function endAlpha(disObj)
{
	clearTimeout(changeA);
	minAlpha = 30;
	maxAlpha = 60;
	BGCOLOR = '#353535';
	disObj.style.display = "none";
	var alpha = document.getElementById('alpha');
	alpha.style.display = 'none';
}


function popw(sFile,sWidth,sHeight,svar)
{
	startAlpha();

	var code = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\""+ sWidth +"\" height=\""+ sHeight +"\"> ";
	code += " <param name=\"allowScriptAccess\" value=\"sameDomain\" /> ";
	code += " <param name=\"movie\" value=\""+ sFile +"\"> ";
	code += " <param name=\"quality\" value=\"high\"> ";
	code += " <param name=\"scale\" value=\"noscale\"> ";
	code += " <param name=\"wmode\" value=\"transparent\">";
	code += " <param name=\"FlashVars\" value=\""+ svar +"\">";
	code += " <embed src=\""+ sFile +"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+ sWidth +"\" height=\""+ sHeight +"\"></embed> ";
	code += "</object> ";
	var mailf = document.getElementById('code');
	mailf.style.position = 'absolute';
	mailf.style.left = (arrayPageSize[2]-sWidth)/2;
	mailf.style.top = arrayPageScroll + (arrayPageSize[3]-sHeight)/2;
	mailf.style.zIndex = 999;
	mailf.innerHTML = code;
	mailf.style.display = "block";
	disAlpha();
}
function showpic(sFile)
{
	startAlpha();
	imgObj = new Image();
	imgObj.src = sFile;
	if ((imgObj.width != 0) && (imgObj.height != 0)){
		var code = "<a href=\"javascript:\" title=\"返回\"><img src=\""+sFile+"\" onclick=\"endAlpha(code);\" border=\"0\" class=\"img\" /></a>";
		var mailf = document.getElementById('code');
		mailf.style.position = 'absolute';
		mailf.style.left = (arrayPageSize[2]-imgObj.width)/2;
		mailf.style.top = arrayPageScroll + (arrayPageSize[3]-imgObj.height)/2;
		mailf.style.zIndex = 999;
		mailf.innerHTML = code;
		mailf.style.display = "block";
		disAlpha();
	}else{
	  	setTimeout("showpic('"+sFile+"')",100)
	}
}

// end
