﻿// JScript 文件

//addFlash添加Flash广告 width长,height高,pics图片,links链接,texts文字
function addFlash(width,height,pics,links,texts)
{

    var pic_width=width; //图片宽度//this param387
    var pic_height=height; //图片高度//this param244

    var button_pos=4; //按扭位置 1左 2右 3上 4下//this param
    var stop_time=4000; //图片停留时间(1000为1秒钟)//this param
    var show_text=0; //是否显示文字标签 1显示 0不显示//this param
    var txtcolor="000000"; //文字色

    var bgcolor="DDDDDD"; //背景色


    var imag=new Array();
    var link=new Array();//this param
    var text=new Array();//this param

    //可编辑内容结束
    var swf_height=show_text==0?pic_height:pic_height;//this param

    var pics=pics;
    var links=links;
    var texts=texts;

    var wmode = 'movie';
    var flashurl = 'focus.swf';
    var htmlstr = '<embed wmode="transparent" style="position:relative;top:0px;" src="' + flashurl + '" wmode=' + wmode +
    ' quality="high" FlashVars="pics='+pics
        +'&links='+links
        +'&texts='+texts+
        '&pic_width='+pic_width+
        '&pic_height='+pic_height+
        '&show_text='+show_text+
        '&txtcolor='+txtcolor+
        '&bgcolor='+bgcolor+
        '&button_pos='+button_pos+
        '&stop_time='+stop_time+
        '" quality="high" width="'+ pic_width +
        '" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
    document.write(htmlstr);
                
  }
//加FLASH
function addFlash2(flsh,width,height)
{

    var pic_width=width; //图片宽度//this param387
    var pic_height=height; //图片高度//this param244

    var button_pos=4; //按扭位置 1左 2右 3上 4下//this param
    var stop_time=4000; //图片停留时间(1000为1秒钟)//this param
    var show_text=0; //是否显示文字标签 1显示 0不显示//this param
    var txtcolor="000000"; //文字色

    var bgcolor="DDDDDD"; //背景色


    var imag=new Array();
    var link=new Array();//this param
    var text=new Array();//this param

    //可编辑内容结束
    var swf_height=show_text==0?pic_height:pic_height;//this param

    var pics=pics;
    var links=links;
    var texts=texts;

    var wmode = 'movie';
    var flashurl =  flsh;
    var htmlstr = '<embed wmode="transparent" style="position:relative;top:0px;" src="' + flashurl + '" wmode=' + wmode +
    ' quality="high" width="'+ pic_width +
        '" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
    document.write(htmlstr);
}


    function formatFloat(src, pos)
    {
        var f = src.toString();
        if (f.indexOf(".")<0){
            f = src +"." +repeatStr("0",pos);
        }else{
            f = Math.round(src*Math.pow(10, pos))/Math.pow(10, pos).toString();
            var l = f.toString().split(".")[0];
            var r = f.toString().split(".")[1];
            if (r.length<pos){
                r = r.toString().concat(repeatStr("0",pos-r.length));
                f = l.toString()+"."+ r.toString();
            }
        }
        return f;
    }
    
    function repeatStr(src, pos){
        var s="";
        for(var i=0; i<pos; i++){
           s += src;
        }
        return s;
    }
  
  
  //左右两边的DIV自动对齐
  function AutoResizeLeftAndRight()
  {
    try{
	      var leftJquery=$("div .red_box").height()?$("div .red_box"):$("div .ChildKindList");
    	  
	      var leftHeight=leftJquery.height();
          var rightHeight=$("div .ProListCommon").height();
    	 
	      //alert("leftHeight:"+leftHeight+",rightHeight:"+rightHeight);
	      var left=478; var right=26;
	      if($("div .red_box").height())
	      {
		      left=458;   
	      }
    	  
	      if(rightHeight+right>leftHeight+left)
	      {
		      $("div .red_box").height(rightHeight+rightHeight-left);
	      }
	      else
	      {
		      $("div .ProListCommon").height(leftHeight+left-right);
	      }
	  }catch(exception){
	  
	  }
	  
  }
//  window.onload=AutoResizeLeftAndRight;  


function isFloat(input)
{
     var re = /^[0-9]+.?[0-9]*$/;   //判断字符串是否为数字     //判断正整数 /^[1-9]+[0-9]*]*$/   
    return re.test(input);
   
}

function isInt(input)
{
    var re=/^[0-9]$/;
      return re.test(input);
}


///验证是不是IE
function isIE(){
    var isie = true;

    if((navigator.userAgent.indexOf("MSIE")>0) && (parseInt(navigator.appVersion) >=4))isie = true;
    if(navigator.userAgent.indexOf("Firefox")>0)isie = false;
    if(navigator.userAgent.indexOf("Safari")>0)isie = false;
     
    return isie;
}
            

//////Cookies

function SetCookie(name,value)//两个参数，一个是cookie的名子，一个是值
{
    var Days = 30; //此 cookie 将被保存 30 天
    var exp  = new Date();    //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]); return null;

}
function delCookie(name)//删除cookie
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}



///key code

var isIE = false;
var isFF = false;
var isSa = false;

if ((navigator.userAgent.indexOf("MSIE")>0) && (parseInt(navigator.appVersion) >=4))isIE = true;
if(navigator.userAgent.indexOf("Firefox")>0)isFF = true;
if(navigator.userAgent.indexOf("Safari")>0)isSa = true;

function onlyNumber(e)
{
    var key;
    iKeyCode = window.event?e.keyCode:e.which;
    //alert(iKeyCode);
    if( !(((iKeyCode >= 48) && (iKeyCode <= 57)|| (iKeyCode >= 96) && (iKeyCode <= 105)) || iKeyCode == 110 || iKeyCode == 190 || (iKeyCode == 13) || (iKeyCode == 46) || (iKeyCode == 45) || (iKeyCode == 37) || (iKeyCode == 39) || (iKeyCode == 8)))
    {   
        if (isIE)
        {
            e.returnValue=false;
            return false;
        }
        else
        {
            e.preventDefault();
            return true;
        }
    }
}

function onlyNumber2(field){
    field.value=field.value.replace(/[^\.\d]/g,'');
    if(field.value.split('.').length>2)
    {
        field.value=field.value.split('.')[0]+'.'+field.value.split('.')[1]
    }
}
        
///显示图片
function showImg(fileId, imgId){
    try{
        var img = document.getElementById(imgId);
        var file= document.getElementById(fieldId);
        img.style.display="inline";
        img.src=file.value;
    }
    catch(exception){}
}
        
