 
 function eyunCookie(){   
     this.key="";//初始化key。   
     this.value="";//初始化key's value。   
     this.expires=0;//初始化cookie的有效时间，单位毫秒。   
     this.init=function(){//对象初始化   
         this.key="";   
         this.value="";   
         this.expires=0;   
     }   
     this.set=function(key,value,expires){//设置cookie   
         if(this.key=="")this.key=key;   
         if(this.value=="")this.value=value;   
         if(this.expires<=0)this.expires=expires;   
         if(this.key==""||typeof(this.key)!="string"){   
             alert("请先设置欲保存的cookie名称！");   
             this.init();   
             return false;   
         }   
         if(this.key.match(/[,; ]/)){   
             alert("cookie名称中不能包含“,”、“;”或空格！");   
             this.init();   
             return false;   
         }   
         if(this.value.toString().match(/[,; ]/)||typeof(this.value)=="undefined"){   
             alert("cookie值中不能包含“,”、“;”或空格！");   
             this.init();   
             return false;   
         }   
         if(this.expires<=0||typeof(this.expires)!="number"){   
             alert("请先正确设置cookie的有效时间！");   
             this.init();   
             return false;   
         }   
         var cookie=document.cookie;

         var dt=new Date();   
         dt.setTime(dt.getTime()+this.expires);   
         document.cookie=this.key+"="+this.value+";path=/"+";expires="+dt.toGMTString();   
         this.init();   
         return true;   
     }   
   
     this.get=function(key){//取得名为key的cookie的值   
         if(key==""||key.match(/[,; ]/)){   
             alert("请正确设置欲查找的cookie名称！")   
             return false;   
         }   
         var cookie=document.cookie;   
         var start=cookie.indexOf(key+"=");   
         if(start==-1){   
             //alert("欲查找的cookie不存在！")   
             return false;   
         }   
         var end=cookie.indexOf(";",start);   
         if(end==-1)end=cookie.length;   
         var getCookie=cookie.substring(start+key.length+1,end);   
         //alert("cookie："+key+"的值为"+getCookie);   
         return getCookie;   
     }   
     this.showAll=function(){//显示所有cookie   
         alert("共有以下cookie对：\n"+document.cookie.split(";").toString().replace(/,/g,"\n"));   
     }   
     this.del=function(key){//删除名为key的cookie   
         if(key==""||key.match(/[,; ]/)){   
             alert("请正确设置欲删除的cookie名称！")   
             return false;   
         }   
         var dt=new Date();   
         dt.setTime(dt.getTime());   
         document.cookie=key+"=eyunDelete;expires="+dt.toGMTString();   
         this.init();   
         return true;   
     }   
     this.destroy=function(){//销毁所有cookie   
         var dt=new Date();   
         dt.setTime(dt.getTime());   
         while(document.cookie!=""){   
             document.cookie=document.cookie+";expires="+dt.toGMTString();   
             this.init();   
             return true;   
         }   
     }   
 }   
 
 var cookieTest=new eyunCookie();
 function settest(){
     cookieTest.key="test";
     cookieTest.value="ok";
     cookieTest.expires=30*86400000;
     cookieTest.set();
 }



function adjustImageSize(pagePic,image,iwidth,iheight)
{
    var picWidth=0;
    var picHeight=0;

    picWidth=image.width;
    picHeight=image.height;
    if(image.width>0 && image.height>0)
    {
        if(image.width/image.height >= iwidth/iheight)
        {
            if(image.width>iwidth)
            {
                pagePic.width=iwidth;
                pagePic.height=(image.height*iwidth)/image.width;
            }
            else
            {
                pagePic.width=image.width;
                pagePic.height=image.height;
            }
        }
        else
        {
            if(image.height>iheight)
            {
                pagePic.height=iheight;
                pagePic.width=(image.width*iheight)/image.height;
            }
            else
            {
                pagePic.width=image.width;
                pagePic.height=image.height;
            }
        }
    }
    else
    {
        pagePic.width=iwidth;
    }
}



function adjustPageSize(pagePic,obj)
{
    var picWidth=0;
    var picHeight=0;
    
    
    var image=new Image();
    image.src = pagePic.src;

    var selectId=obj.selectedIndex;
    var selectVa=obj.options[selectId].value;
    if(selectVa=='0')
    {
        adjustImageSize(pagePic,image,iwidth,iheight);
    }
    else if(selectVa=='1')
    {
        picWidth=image.width;
        picHeight=image.height;
        pagePic.width=picWidth;
        pagePic.height=picHeight;
    }
}

function movemouse(e)
{

    if (isdrag)
    {
        dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
        dobj.style.top = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
        return false;
    }
}
function selectmouse(e)
{

    var fobj = nn6 ? e.target : event.srcElement;
    var topelement = nn6 ? "HTML" : "BODY";
    while (fobj.tagName != topelement && fobj.className != "dragme")
    {
        fobj = nn6 ? fobj.parentNode : fobj.parentElement;
    }
    if (fobj.className=="dragme")
    {
        isdrag = true;
        dobj = fobj;
        tx = parseInt(dobj.style.left+0);
        ty = parseInt(dobj.style.top+0);
        x = nn6 ? e.clientX : event.clientX;
        y = nn6 ? e.clientY : event.clientY;
        document.onmousemove=movemouse;
        return false;
    }
}

var ie=document.all;
var nn6=document.getElementById&&!document.all;
var isdrag=false;
var x,y;
var dobj;

var isIeWheel=navigator.userAgent.indexOf('MSIE') > 0 ? true : false;
function zoomimg(e)
{
//alert(e);
    var ev;
    if (ie)
    {
        ev=event;
    }else{
        ev=e;
    }
    
    if (ev.altKey)
    {
        var delta = 0;
        if (e.wheelDelta)
        {
            delta = e.wheelDelta/120;
            if (window.opera)
            delta = -delta;
        }
        else if (e.detail)
        {
            delta = -e.detail / 3;
        }
        var objImage = nn6 ? e.target : e.srcElement;
        var topelement = nn6 ? "HTML" : "BODY";
        while (objImage.tagName != topelement && objImage.className != "dragme")
        {
            objImage = nn6 ? objImage.parentNode : objImage.parentElement;
        }
        if (objImage.className=="dragme")
        {
            var int_zoom=delta;
            var int_zoom_width = 0;
            var int_zoom_height = 0;
            var int_zoomout_ie = 10;
            var int_zoomout_ff = 10;
            var int_min_width = 50;
            var int_min_height = 80;
            if (isIeWheel)
            {
                var int_zoom_ie = parseInt(objImage.style.zoom) || 100;
                int_zoom_ie += int_zoomout_ie * int_zoom;
                if (int_zoom_ie > 0 ) objImage.style.zoom = int_zoom_ie + "%";
            }
            else
            {
                if (objImage.width > objImage.height)
                {
                    int_zoom_height = objImage.height + int_zoomout_ff * int_zoom;
                    int_zoom_width = objImage.width * int_zoom_height / objImage.height;
                }
                else
                {
                    int_zoom_width = objImage.width + int_zoomout_ff * int_zoom;
                    int_zoom_height = objImage.height * int_zoom_width / objImage.width;
                }
                if (int_zoom_width > int_min_width && int_zoom_height > int_min_height)
                {
                    objImage.width = int_zoom_width;
                    objImage.height = int_zoom_height;
                }
            }
        }
        if (e.preventDefault)
        e.preventDefault();
        e.returnValue = false;
        //return false;
    }
   
}

		
function changeImageSize(selectVa){

        var image=new Image();
    	var pagePic=document.getElementById("page_image");
		image.src = pagePic.src;

	    if(selectVa=='1')
	    {
	        var picWidth=image.width;
	        var picHeight=image.height;
	        pagePic.width=picWidth;
	        pagePic.height=picHeight;
	    }
	    else if(selectVa=='0')
	    {
	        adjustImageSize(pagePic,image,iwidth,iheight);
	    }
}

//注册快捷键
function returnDefault(e)
{
    var ev;
    if (ie){ev=event;}else{ev=e;}
    
    //alert(ev.keyCode);
	//shift+'z' 文字大小切换
    if(ev.keyCode==90&&ev.shiftKey)
    {
        var obj= document.getElementById("pageShowSel");
        var selectId=obj.selectedIndex;
	    var selectVa=obj.options[selectId].value;
	    if(selectVa=='0')
	    {
	    	changeImageSize('1');
	    	obj.options[1].selected=true;
	    }
	    else if(selectVa=='1')
	    {
	    	changeImageSize('0');
	    	obj.options[0].selected=true;
	    }
	 }
	 
	// shift+A 上一版
	if(ev.keyCode==65&&ev.shiftKey)
    {
       changeOrder(0);
    }
    
    // shift+S 下一版
	if(ev.keyCode==83&&ev.shiftKey)
    {
	   changeOrder(1);
    }
	
    
}
function rememberPageSize(obj){
    if (obj.checked)
    {
       var obj= document.getElementById("pageShowSel");
       var selectId=obj.selectedIndex;
       var selectVa=obj.options[selectId].value;
       
	   var cookieTest=new eyunCookie();
       cookieTest.key="PageSize";
       cookieTest.value=selectVa;
       cookieTest.expires=90*86400000;;
       cookieTest.set();
       
    }else{
       var cookieTest=new eyunCookie();
       cookieTest.del("PageSize");
    }
}

document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=false");
if(document.attachEvent)
{
    document.attachEvent("onmousewheel",zoomimg);
}
else
{
    window.addEventListener("DOMMouseScroll", zoomimg, false);
}
document.onkeydown=returnDefault;


function makeUrl(key,value)
{
    var oldUrl = window.location.href;
    var ipage = oldUrl.lastIndexOf(key+"=");
    var clienurl = oldUrl;
    if (ipage >= 0)
    {
        var clienurl = oldUrl.substr(0, ipage);
        var pageURL = clienurl + key+"=" + value;
    }
    else
    {
        var ipa = oldUrl.lastIndexOf("?");
        if (ipa > 0)
        {
            var pageURL = clienurl + "&"+key+"=" + value;
        }
        else
        {
            var pageURL = clienurl + "?"+key+"=" + value;
        }
    }
    return pageURL;
}


function changeOrder(type,defOrder){
    var toPageOrder=1;
    var flag=false;
    
    if(defOrder != null&& defOrder !="undefined"&& defOrder!=""){
       toPageOrder=defOrder;
    }else{
        if(type==0){
            toPageOrder=pageOrder-2;
        }else {
            toPageOrder=pageOrder+2;
        }
    }
    if(toPageOrder<=0){
   
        toPageOrder=pageOrder-1;
         if(toPageOrder<=0){
        alert("没有上一版");
        return;
        }
        flag=false;
    }else
    {
     
    flag=true;}
    
     if(toPageOrder>pageCount){
     alert(toPageOrder+"dfds"+pageOrder);
        toPageOrder=pageOrder+1;
         if(toPageOrder>pageCount){
        alert("没有下一版");
        return;
        }
        flag=false;
    }else
    {
       
    flag=true;}
  
    if(flag){
    if(type!="0"){
    var normalPage=normalPages[toPageOrder-2];
    document.getElementById('page_image').src=normalPage.src;
      var normalPage1=normalPages[toPageOrder-1];
    document.getElementById('page_image1').src=normalPage1.src;
       document.getElementById('page_image1').style.display="";
       }else
       {
        var normalPage=normalPages[toPageOrder-1];
    document.getElementById('page_image').src=normalPage.src;
      var normalPage1=normalPages[toPageOrder-0];
    document.getElementById('page_image1').src=normalPage1.src;
       document.getElementById('page_image1').style.display="";
       }
    }else
    {
   
          var normalPage1=normalPages[toPageOrder-1];
    document.getElementById('page_image').src=normalPage1.src;
     document.getElementById('page_image1').style.display="none";
   
    }

    document.getElementById('currPageOrder_n').innerHTML="共"+pageCount+"版.当前是第"+toPageOrder+"版";
    document.getElementById('currPageOrder_c').innerHTML="共"+pageCount+"版.当前是第"+toPageOrder+"版";
    document.getElementById('pageList').options[toPageOrder-1].selected=true;
    
//    for(var i=1;i<=pageCount;i++){
//        var smallImg=document.getElementById('nav_img_'+i);
//        if(toPageOrder==i){
//            smallImg.style.borderColor="#ff6315";
//            smallImg.border="3";
//        }else{
//            smallImg.border="0";
//        }
//     }

    if(type=="0"&&flag){
 
    pageOrder=toPageOrder+1;
    }else
    {
         pageOrder=toPageOrder;
    }
       
    if(pageOrder>=pageCount){
        document.getElementById('goToNextPage').style.display="none";
    }else{
        document.getElementById('goToNextPage').style.display="";
    }
    
    if(pageOrder<=1){
        document.getElementById('goToPerPage').style.display="none";
    }else{
        document.getElementById('goToPerPage').style.display="";
    }
    
    var url=makeUrl("order",pageOrder);
    document.getElementById('currUrl').value=url;
    
    var obj= document.getElementById("pageShowSel");
    var selectId=obj.selectedIndex;
	var selectVa=obj.options[selectId].value;
    changeImageSize(selectVa);
   // TPR(); 
}

function changeOrder1(type,defOrder){
    var toPageOrder=1;

    alert(pageOrder);
    if(defOrder != null&& defOrder !="undefined"&& defOrder!=""){
       toPageOrder=defOrder;
    }else{
        if(type==0){
            toPageOrder=pageOrder-1;
        }else{
            toPageOrder=pageOrder+1;
        }
    }
    if(toPageOrder<=0){
        alert("没有上一版");
        return;
    }
    if(toPageOrder>pageCount){
        alert("没有下一版");
        return;
    }

    var normalPage=normalPages[toPageOrder-1];
    document.getElementById('page_image').src=normalPage.src;
        document.getElementById('page_image1').style.display="none";
    document.getElementById('currPageOrder_n').innerHTML="共"+pageCount+"版.当前是第"+toPageOrder+"版";
    document.getElementById('currPageOrder_c').innerHTML="共"+pageCount+"版.当前是第"+toPageOrder+"版";
    document.getElementById('pageList').options[toPageOrder-1].selected=true;
    
    for(var i=1;i<=pageCount;i++){
        var smallImg=document.getElementById('nav_img_'+i);
        if(toPageOrder==i){
            smallImg.style.borderColor="#ff6315";
            smallImg.border="3";
        }else{
            smallImg.border="0";
        }
     }

    
    pageOrder=toPageOrder;
     
    if(pageOrder>=pageCount){
        document.getElementById('goToNextPage').style.display="none";
    }else{
        document.getElementById('goToNextPage').style.display="";
    }
    
    if(pageOrder<=1){
        document.getElementById('goToPerPage').style.display="none";
    }else{
        document.getElementById('goToPerPage').style.display="";
    }
    
    var url=makeUrl("order",pageOrder);
    document.getElementById('currUrl').value=url;
    
    var obj= document.getElementById("pageShowSel");
    var selectId=obj.selectedIndex;
	var selectVa=obj.options[selectId].value;
    changeImageSize(selectVa);
}

function switchNav(navId){
	if(navId==1){
		document.getElementById('Nav_page').style.display="";
		document.getElementById('Nav_op').style.display="none";
		document.getElementById('nav_Title_page').style.color="#ff6315";
		document.getElementById('nav_Title_page').style.cursor="default";
		document.getElementById('nav_Title_op').style.color="#ffffff";
		document.getElementById('nav_Title_op').style.cursor="pointer";
	}else{
		document.getElementById('Nav_page').style.display="none";
		document.getElementById('Nav_op').style.display="";
		document.getElementById('nav_Title_page').style.color="#ffffff";
		document.getElementById('nav_Title_page').style.cursor="pointer";
		document.getElementById('nav_Title_op').style.color="#ff6315";
		document.getElementById('nav_Title_op').style.cursor="default";
	}
	showNav('Nav_Container','Nav_MainColumn','Nav_Tool',1);
}

function showNav(nav_container_id,nav_main_id,nav_tool_id,type){
    var nn6=document.getElementById&&!document.all;
   
    if(document.getElementById(nav_main_id).style.display=="none"&&(type == null||type==1)){
	    document.getElementById(nav_main_id).style.display="";
	    
	    if(nn6){
	        document.getElementById(nav_container_id).style.width=203;
	    }else{
	        document.getElementById(nav_container_id).style.width=203;
	    }
	   
	    
	    document.getElementById(nav_container_id).style.left=document.body.scrollLeft+document.body.clientWidth-document.getElementById(nav_container_id).offsetWidth;
	    document.getElementById(nav_tool_id).innerHTML="<img title='单击隐藏导航栏' src='image/1.gif'/>";
    }else if(document.getElementById(nav_main_id).style.display==""&&(type == null||type==0)){
	    document.getElementById(nav_main_id).style.display="none";
	    document.getElementById(nav_container_id).style.width=32;
	    
	 
	    if(nn6){
	         document.getElementById(nav_container_id).width=32;
	         
	    }else{
	       
	    }
	    
	    document.getElementById(nav_container_id).style.left=document.body.scrollLeft+document.body.clientWidth-32;
	    document.getElementById(nav_tool_id).innerHTML="<img title='单击显示导航栏' src='image/2.gif'/>";
    }
}

function nav_move(nav_container_id,nav_main_id){
    if(document.getElementById(nav_main_id).style.display=="none"){
	    document.getElementById(nav_container_id).style.left=document.body.scrollLeft+document.body.clientWidth-32;
    }else{
	    document.getElementById(nav_container_id).style.left=document.body.scrollLeft+document.body.clientWidth-document.getElementById(nav_container_id).offsetWidth;
    }
    document.getElementById(nav_container_id).style.top=document.body.scrollTop+(document.body.clientHeight-document.getElementById(nav_container_id).offsetHeight)/2;
}

function scall(){
nav_move('Nav_Container','Nav_MainColumn');
}



var ie = navigator.appName == "Microsoft Internet Explorer" ? true : false;

function $(objid){
	return document.getElementById(objid);
}

function copytext(str,alertinfo){
	alertinfo=alertinfo||'复制成功';
	if (ie)
	{
		window.clipboardData.setData("Text",str);
	}else{
		var flashObj=$("flashCopyDiv");
		if (!flashObj){
			flashObj = document.createElement("div");
			flashObj.id='flashCopyDiv';
			document.body.appendChild(flashObj)
		}
		flashObj.innerHTML = '<embed src="js/clipboard.swf" FlashVars="clipboard=' + encodeURIComponent(str) + '" width="0" height="0" type="application/x-shockwave-flash"></embed>';
	}
	alert(alertinfo);
	return false;
}
