﻿//弹出层
function opendiv(m,w,h){
$("#"+m).show();setPos(m,w,h);
var nav=window.navigator.userAgent;
var shield = document.getElementById("shield");
shield.style.position = "absolute";
shield.style.left = "0px";
shield.style.top = "0px";
shield.style.width = "100%";
if (nav.indexOf("MSIE")>=1) 
{shield.style.height = document.body.scrollHeight+"px";}else
{shield.style.height = "100%";}
shield.style.background = "white";
shield.style.textAlign = "center";
shield.style.zIndex = "10";
shield.style.filter = "alpha(opacity=80)";
shield.style.opacity = 0.8;
shield.style.display="block";
}
function setPos(p,w,h){
document.getElementById(p).style.left=(document.body.scrollWidth-w)/2+"px";
document.getElementById(p).style.top=h+"px";
}
function exit(m)
{
 $("#"+m).hide();
}
function open(m)
{
 $("#"+m).show();
}
//取得URL参数
function getParameter(key)
{
	var parameters = unescape(window.location.search.substr(1)).split("&");
	for( var i = 0 ; i < parameters.length ; i++ )
	{
		var paramCell = parameters[i].split("=");
		if( paramCell.length == 2 && paramCell[0].toUpperCase() == key.toUpperCase() )
		{
			return paramCell[1];
		}
	}
	return new String();
}

function proDownImage(ImgD,ImgHeight,ImgWidth){
var proMaxHeight = ImgHeight;
var proMaxWidth  = ImgWidth;
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
var rate = (proMaxWidth/image.width < proMaxHeight/image.height)?proMaxWidth/image.width:proMaxHeight/image.height;
    if(rate <= 1){   
     ImgD.width = image.width*rate;  
               ImgD.height =image.height*rate;
    }else{  
               ImgD.width = image.width;
               ImgD.height =image.height;
    }
     }
}




//图片按比例缩放
var flag=false;
function DrawImage(ImgD,width_I,Height_I){
var image=new Image();
var iwidth = width_I; //定义允许图片宽度，当宽度大于这个值时等比例缩小
var iheight = Height_I; //定义允许图片高度，当宽度大于这个值时等比例缩小
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= iwidth/iheight){
if(image.width>iwidth){
ImgD.width=iwidth;
ImgD.height=(image.height*iwidth)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}

//ImgD.alt=image.width+"×"+image.height;
}
else{
if(image.height>iheight){
ImgD.height=iheight;
ImgD.width=(image.width*iheight)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
//ImgD.alt=image.width+"×"+image.height;
}
}
}
//调用cg1_b.jpg：<img src="图片" onload="JavaScript:DrawImage(this,120,120)">

// 切换
function set_tab(a,b,c){
	for(i=1; i<=c; i++){
		$("#tab_"+a+"_"+i).removeClass("checked");
		$("#content_"+a+"_"+i).hide();
	}
	$("#tab_"+ a + "_" + b).addClass("checked");
	$("#content_"+ a + "_" + b).show();
}

function set_tabDetial(a,b,c){
	for(i=1; i<=c; i++){
		$("#tab1_"+a+"_"+i).removeClass("checked");
		
		if(b==1){
		    $("#content1_"+a+"_"+i).show();
		    $("#nav1_"+a+"_"+i).show();
		}
		else{
		    $("#content1_"+a+"_"+i).hide();
		    $("#nav1_"+a+"_"+i).hide(); 
		}
		  
	}
	$("#tab1_"+ a + "_" + b).addClass("checked");
	$("#content1_"+ a + "_" + b).show();
	

}



var DivTipSTYLE = "";
var offsetX = 0;
var	offsetY = 20;
var x = 0;
var y = 0;
    
    
function showImg(src,sprice,mprice,event)
{
   DivTipSTYLE = document.getElementById("dz");
	if(src=="") 
  {
    DivTipSTYLE.style.display = "none";   
    
  }
  else 
  {     document.onmousemove = function(event){moveToMouseLoc(event)};  
     var content ='<img src="' + src +'" onload="DrawImage(this,280,280)" style=" border:1px #cccccc solid"/>';                  
     DivTipSTYLE.innerHTML=content;      
     DivTipSTYLE.style.display='';
  }
}

function initToolTips(event,id)
{
    DivTipSTYLE = document.getElementById(id);
    document.onmousemove = function(event){moveToMouseLoc(event)};
}


function moveToMouseLoc(eTag)//获取鼠标当前坐标
{
    DivTipSTYLE = document.getElementById("dz");
    var event = window.event || eTag;  
	var posX,posY;      
  
  //判断当前浏览器
  if(navigator.userAgent.indexOf("MSIE")>0)   //IE6.0-7 or marthon
  {  
      if(screen.width == 800)  
      {
            posX = event.clientX + document.documentElement.scrollLeft - document.body.clientLeft+10;
  	        posY = event.clientY + document.documentElement.scrollTop- document.body.clientTop+5; 
      } 
      else if(screen.width == 1024) 
      {
           posX = event.clientX + document.documentElement.scrollLeft - document.body.clientLeft+10;
  	       posY = event.clientY + document.documentElement.scrollTop- document.body.clientTop+5; 
      } 
      else if(screen.width >=  1280) 
      {
           posX = event.clientX + document.documentElement.scrollLeft - document.body.clientLeft+10;
  	       posY = event.clientY + document.documentElement.scrollTop- document.body.clientTop+20; 
      }      
         
  }  
  
  if(isFirefox=navigator.userAgent.indexOf("Firefox")>0)  //firefox
  {  
      if(screen.width == 800)  
      {
            posX = event.pageX+5;
            posY = event.pageY+5; 
      } 
      else if(screen.width == 1024) 
      {
           posX = event.pageX+5;
           posY = event.pageY+5; 
      } 
      else if(screen.width >=  1280) 
      {
           posX = event.pageX+5-120;
           posY = event.pageY+5; 
      }           
           
  }
 
//  if(isopera=navigator.userAgent.indexOf("Opera")>0)return 3;//opera
//  if(isSafari=navigator.userAgent.indexOf("Safari")>0)return 4;  
//  if(isCamino=navigator.userAgent.indexOf("Camino")>0)return 5;
//  if(isMozilla=navigator.userAgent.indexOf("Gecko")>0)return 6;
     	   
  try{ 
     
    DivTipSTYLE.style.top= posY +"px";  
    DivTipSTYLE.style.left= posX +"px"; 
  
  }catch(E){}
  return true;
}


/*
 * Url preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.screenshotPreview = function(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.screenshot").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p style='border-color:Gray;border-width:1px;' id='screenshot'><img style= 'float:left' src='"+ this.rel +"' onload='DrawImage(this,280,280)' alt='"+this.title+"' /></p>");								 
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#screenshot").remove();
    });	
	$("a.screenshot").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	screenshotPreview();
});

function WebForm_FireDefaultButton(event, target) {
    if (!__defaultFired && event.keyCode == 13 && !(event.srcElement && (event.srcElement.tagName.toLowerCase() == "textarea"))) {
        var defaultButton;
        if (__nonMSDOMBrowser) {
            defaultButton = document.getElementById(target);
        }
        else {
            defaultButton = document.all[target];
        }
        if (defaultButton && typeof(defaultButton.click) != "undefined") {
            __defaultFired = true;
            defaultButton.click();
            event.cancelBubble = true;
            if (event.stopPropagation) event.stopPropagation();
            return false;
        }
    }
    return true;
}

function ResumeError() { return true; }
window.onerror = ResumeError; //屏蔽JS错误，这样状态栏就不会显示“网站上有错误了”
