// JavaScript Document
function show_m(n)
{
t=1;
while(t<=2){ $('#mo_'+t).hide(100);t++;}
$('#mo_'+n).show(100);
}
var skinwindow="<div style='padding:5px 5px 5px 5px;height:20px;background-color:#666' onclick=\"$('#ttps').hide(300);$('#ttps').replaceWith('');\"><div style='float:right;cursor:pointer;color:#fff'>关闭</div></div>\
<div align=left style='margin-top:10px;margin-left:5px;'>\
<span style='padding:5px 5px 5px 5px;margin-left:3px;background-color:#FDEAE1;border:solid 1px #ff0000;cursor:pointer' onclick='show_m(1)'>企业通用模板</span>\
<span style='padding:5px 5px 5px 5px;margin-left:3px;background-color:#FDEAE1;border:solid 1px #ff0000;cursor:pointer' onclick='show_m2(2)'>单位通用模板制作中。。。</span>\
<span style='padding:5px 5px 5px 5px;margin-left:3px;background-color:#eee;border:solid 1px #999;cursor:pointer' onclick='show_mt(1)'>企业行业模板制作中。。。</span>\
<span style='padding:5px 5px 5px 5px;margin-left:3px;background-color:#eee;border:solid 1px #999;cursor:pointer' onclick='show_mt(2)'>单位行业模板制作中。。。</span>\
</div>\
<div id='mo_1'><table align=center style='margin-top:30px;' width=100% border=0 height:100%><tr>\
<td align=center><img src=images/skintemp/free_1.gif style='widht:120px;height:80px;cursor:pointer' style='border:1px solid #333;margin-bottom:3px;' onclick=\"$('#webskin').val('free_1');$('#ttps').replaceWith('');\"><br>梦想黄</td>\
<td align=center><img src=images/skintemp/free_2.gif style='widht:120px;height:80px;cursor:pointer' style='border:1px solid #333;margin-bottom:3px;' onclick=\"$('#webskin').val('free_2');$('#ttps').replaceWith('');\"><br>科技蓝</td>\
<td align=center><img src=images/skintemp/free_3.gif style='widht:120px;height:80px;cursor:pointer' style='border:1px solid #333;margin-bottom:3px;' onclick=\"$('#webskin').val('free_3');$('#ttps').replaceWith('');\"><br>激情红</td>\
<td align=center><img src=images/skintemp/free_4.gif style='widht:120px;height:80px;cursor:pointer' style='border:1px solid #333;margin-bottom:3px;' onclick=\"$('#webskin').val('free_4');$('#ttps').replaceWith('');\"><br>心情绿</td>\
<td align=center><img src=images/skintemp/free_5.gif style='widht:120px;height:80px;cursor:pointer' style='border:1px solid #333;margin-bottom:3px;' onclick=\"$('#webskin').val('free_5');$('#ttps').replaceWith('');\"><br>灵动灰</td>\
</tr><tr>\
<td align=center><img src=images/skintemp/free_6.gif style='widht:120px;height:80px;cursor:pointer' style='border:1px solid #333;margin-bottom:3px;' onclick=\"$('#webskin').val('free_6');$('#ttps').replaceWith('');\"><br>梦想黄二</td>\
<td align=center><img src=images/skintemp/free_7.gif style='widht:120px;height:80px;cursor:pointer' style='border:1px solid #333;margin-bottom:3px;' onclick=\"$('#webskin').val('free_7');$('#ttps').replaceWith('');\"><br>科技蓝二</td>\
<td align=center><img src=images/skintemp/free_8.gif style='widht:120px;height:80px;cursor:pointer' style='border:1px solid #333;margin-bottom:3px;' onclick=\"$('#webskin').val('free_8');$('#ttps').replaceWith('');\"><br>激情红二</td>\
<td align=center><img src=images/skintemp/free_9.gif style='widht:120px;height:80px;cursor:pointer' style='border:1px solid #333;margin-bottom:3px;' onclick=\"$('#webskin').val('free_9');$('#ttps').replaceWith('');\"><br>心情绿二</td>\
<td align=center><img src=images/skintemp/free_10.gif style='widht:120px;height:80px;cursor:pointer' style='border:1px solid #333;margin-bottom:3px;' onclick=\"$('#webskin').val('free_10');$('#ttps').replaceWith('');\"><br>灵动灰二</td>\
</tr><tr>\
<td></td>\
<td></td>\
<td></td>\
<td></td>\
<td></td>\
<td></td>\
</tr></table></div>\
<div id='mo_2' style='display:none' ><table align=center style='margin-top:30px;' width=100% border=0 height:100%><tr>\
<td align=center><img src=images/skintemp/dw_free_1.gif style='widht:120px;height:80px;cursor:pointer' style='border:1px solid #333;margin-bottom:3px;' onclick=\"$('#webskin').val('dw_free_1');$('#ttps').replaceWith('');\"><br>梦想黄</td>\
<td align=center><img src=images/skintemp/free_2.gif style='widht:120px;height:80px;cursor:pointer' style='border:1px solid #333;margin-bottom:3px;' onclick=\"$('#webskin').val('free_2');$('#ttps').replaceWith('');\"><br>科技蓝</td>\
<td align=center><img src=images/skintemp/free_3.gif style='widht:120px;height:80px;cursor:pointer' style='border:1px solid #333;margin-bottom:3px;' onclick=\"$('#webskin').val('free_3');$('#ttps').replaceWith('');\"><br>激情红</td>\
<td align=center><img src=images/skintemp/free_4.gif style='widht:120px;height:80px;cursor:pointer' style='border:1px solid #333;margin-bottom:3px;' onclick=\"$('#webskin').val('free_4');$('#ttps').replaceWith('');\"><br>心情绿</td>\
<td align=center><img src=images/skintemp/free_5.gif style='widht:120px;height:80px;cursor:pointer' style='border:1px solid #333;margin-bottom:3px;' onclick=\"$('#webskin').val('free_5');$('#ttps').replaceWith('');\"><br>稳重灰</td>\
<td></td>\
<td></td>\
</tr><tr>\
<td></td>\
<td></td>\
<td></td>\
<td></td>\
<td></td>\
<td></td>\
</tr><tr>\
<td></td>\
<td></td>\
<td></td>\
<td></td>\
<td></td>\
<td></td>\
</tr></table></div>"
////////////取cookies函数 
function getCookie(name){var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));if(arr != null) return unescape(arr[2]); return null;}
////////////////
function ajax_postcheckcode()
{
$.ajax({
url: 'ajax.php?tag=postcodecheck',
type: 'post',
dataType: 'script',
data:'code='+$('#postcheckcode').val(),
timeout: 10000,
error: function(){//alert('Error loading XML document');
                 },
success: function(){if(tp==0){$('#postcheckcode_f').val('0');}else $('#postcheckcode_f').val('1');}
})
 

}
function k(t)
{
	//alert();
}
////////
function reloadcode(id){
 var d = new Date();
 document.getElementById(id).src="./postcheckcode.php?t="+d.toTimeString()
}
///////////////
function wait(str,time)
{
Interval_control=setTimeout(str,time);
}
/*验证手机号码*/
function checkMobile(id){
  var mobile=document.getElementById(id).value;
  var reg0=/^13\d{5,9}$/;   //130--139。至少7位
  var reg1=/^153\d{8}$/;  //联通153。至少7位
  var reg2=/^159\d{8}$/;  //移动159。至少7位
  var reg3=/^158\d{8}$/;
  var reg4=/^150\d{8}$/;
  var reg5=/^18\d{5,9}$/;   //180--189。至少7位
  var reg6=/^14\d{5,9}$/;   //140--149。至少7位
  var my=false;
  if (reg0.test(mobile))my=true;
  if (reg1.test(mobile))my=true;
  if (reg2.test(mobile))my=true;
  if (reg3.test(mobile))my=true;
  if (reg4.test(mobile))my=true;
  if (reg5.test(mobile))my=true;
  if (reg6.test(mobile))my=true;
  return my;
}
/*姓名验证*/
function isname(id)
{
if(document.getElementById("shouji").value.search(/^[\u0391-\uffe5\w]+$/)!=-1)return true;
else return false;
}
/*邮箱验证*/
function checkemail(id)
    {
        var temp = document.getElementById(id);
        var myreg = /(\S)+[@]{1}(\S)+[.]{1}(\w)+/;
        if(temp.value!=""){if(!myreg.test(temp.value))return false;else return true;}
    } 

/*
作者：网络转载
功能：png透明
*/
function correctPNG()  
{ 
for(var i=0; i<document.images.length; i++) 
{ 
  var img = document.images[i] 
  var imgName = img.src.toUpperCase() 
  if (imgName.substring(imgName.length-3, imgName.length) == "PNG") 
  { 
   var imgID = (img.id) ? "id='" + img.id + "' " : "" 
   var imgClass = (img.className) ? "class='" + img.className + "' " : "" 
   var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " 
   var imgStyle = "display:inline-block;" + img.style.cssText  
   if (img.align == "left") imgStyle = "float:left;" + imgStyle 
   if (img.align == "right") imgStyle = "float:right;" + imgStyle 
   if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle   
   var strNewHTML = "<span " + imgID + imgClass + imgTitle 
   + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" 
  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" 
   + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"  
   img.outerHTML = strNewHTML 
   i = i-1 
  } 
} 
} 
window.attachEvent("onload", correctPNG); 
/*jquery实例
$.ajax({
    url: 'ajax.php?tag=test',
    type: 'post',
    dataType: 'html',
	data:"bb=aa",
    timeout: 5000,
    error: function(){alert('Error loading XML document');},
    success: function(html){alert(html);}
});
*/


/*层覆盖*/
var W = screen.width;
var H = screen.height;
function isIE(){return (document.all && window.ActiveXObject && !window.opera) ? true : false;} 
function getBodySize(){
   var bodySize = [];
   with(document.documentElement) {
    bodySize[0] = (scrollWidth>clientWidth)?scrollWidth:clientWidth;//如果滚动条的宽度大于页面的宽度，取得滚动条的宽度，否则取页面宽度
    bodySize[1] = (scrollHeight>clientHeight)?scrollHeight:clientHeight;//如果滚动条的高度大于页面的高度，取得滚动条的高度，否则取高度
   }return bodySize;
}
function popCoverDiv(){
   if (document.getElementById("cover_div")) {
    document.getElementById("cover_div").style.display = 'block';
   } else {
    var coverDiv = document.createElement('div');
    document.body.appendChild(coverDiv);
    coverDiv.id = 'cover_div';
    with(coverDiv.style) {
     position = 'absolute';
     background = '#000000';
     left = '0px';
     top = '0px';
     var bodySize = getBodySize();
     width = bodySize[0] + 'px'
     height = bodySize[1] + 'px';
     zIndex = 0;
     if (isIE()) {
      filter = "Alpha(Opacity=80)";//IE逆境
     } else {
      opacity = 0.8;
     }
    }
   }
}
function showceng(){popCoverDiv();void(0);} 
/*消除覆盖层*/
function outceng(){ document.getElementById("cover_div").style.display = 'none';void(0);}
/*
浏览器类型判断
*/
        var Sys = {};
        var ua = navigator.userAgent.toLowerCase();
        window.ActiveXObject ? Sys.ie = ua.match(/msie ([\d.]+)/)[1] :
        document.getBoxObjectFor ? Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1] :
        window.MessageEvent && !document.getBoxObjectFor ? Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1] :
        window.opera ? Sys.opera = ua.match(/opera.([\d.]+)/)[1] :
        window.openDatabase ? Sys.safari = ua.match(/version\/([\d.]+)/)[1] : 0;
/*
按钮上传时用的函数
*/
            var temppath;
            function printup()
            {document.getElementById('filepath').value=xmlhttp.responseText;}
            function upvalue(temp)
            {
             temppath=temp;
             //document.getElementById('upfilediv').style.display='block';
            $('#upfilediv').toggle(400);
             document.getElementById('filepath').value=document.getElementById(temp).value;
            }
            function editupvalue()
            {
             document.getElementById('editupfilediv').style.display='block';
            }

/*
可以移动的层
*/
var drag_=false
var D=new Function('obj','return document.getElementById(obj);')
var oevent=new Function('e','if (!e) e = window.event;return e')
function Move_obj(obj){
 var x,y;
 D(obj).onmousedown=function(e){
  drag_=true;
  with(this){
   style.position="absolute";var temp1=offsetLeft;var temp2=offsetTop;
   x=oevent(e).clientX;y=oevent(e).clientY;
   document.onmousemove=function(e){
    if(!drag_)return false;
    with(this){
     style.left=temp1+oevent(e).clientX-x+"px";
     style.top=temp2+oevent(e).clientY-y+"px";
    }
   }
  }
  document.onmouseup=new Function("drag_=false");
 }
}
function stopMove_obj(obj)
{ 
 D(obj).onmousedown=function(e){document.onmousemove=function(e){}}
}
/*
捕获控件位置
*/
function  divcome(id,e,top,left,iframename,height)
 {    
  l   =   e.offsetLeft;   
  t   =   e.offsetTop;   
  while(   e=e.offsetParent   )   
  {   
  l   +=   e.offsetLeft;   
  t   +=   e.offsetTop;   
  }   
//document.getElementById(id).style.display="block"; 
$("#"+id).show(300);
//$("#"+id)[0].focus();
//document.getElementById(iframename).style.height=height+"px";
document.getElementById(id).style.position="absolute";
document.getElementById(id).style.top=t+top+'px';
document.getElementById(id).style.left=l+left+'px';
 }
/*
作者：易行
功能：判断文件是否存在
参数：file、文件路径
*/
function okfile(file)
{ 
if(window.XMLHttpRequest)
{xmlhttp=new XMLHttpRequest();
 if(xmlhttp.overrideMimeType)xmlhttp.overrideMimeType('text/xml')
 }
else if(window.ActiveXObject)
{try{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}//测试是否IE
   catch (e)
           {
		     try{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}//是否IE5.5
				 catch(e2)
				 {
				 xmlhttp=false;
				 }
            }
 }
  xmlhttp.open("GET",file,false);
  xmlhttp.send(null);
  if(xmlhttp.readyState==4)
  { 

  if(xmlhttp.status==200)
    {return 1;
    }
  else 
    {return 0;
    } 
  } 
}
/*
作者：易行
功能：发送ajax请求
参数：tag、ajax.php中的case值
          canshu 、ajax.php中需要处理的参数
          func、用来接收返回的函数
          otherpage、不支持ajax跳转的网页
调用范例：setajax('Ajax.php',"addweb","qq="+qq,prinaddweb,'userinto2.php')
var ajaxfuncname;
function setajax(page,tag,canshu,func,otherpage)
{ 
//---------------------------------------------------------
ajaxfuncname=func;
if(window.XMLHttpRequest)
{xmlhttp=new XMLHttpRequest();
 if(xmlhttp.overrideMimeType)xmlhttp.overrideMimeType('text/xml')
 }
else if(window.ActiveXObject)
{try{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}//测试是否IE
   catch (e)
           {
		     try{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}//是否IE5.5
				 catch(e2)
				 {
				 xmlhttp=false;
				 }
            }
 }
//----------------------------------------------------------

if(!xmlhttp){alert("本页面采用ajax技术，您的浏览器不支持ajax，即将跳转到没有采用ajax技术的注册页面！");location=otherpage;return false;}
//alert(page+"?tag="+tag+"&"+canshu);
xmlhttp.open("GET",page+"?tag="+tag+"&"+canshu,true);
xmlhttp.onreadystatechange=reception;
xmlhttp.send(null);
}
/*
接收ajax返回
 
function reception()
{   //alert(xmlhttp.readyState);
	if(xmlhttp.readyState==4)
    {
    if(xmlhttp.status==200)
      {
		  ajaxfuncname();
	  //temp();
	  }
    else alert(xmlhttp.status);
  }

}
*/
/*
判断oNum是否数字              
*/
function isNumber(oNum)
{
  if(!oNum) return false;
  var strP=/^\d+(\.\d+)?$/;
  if(!strP.test(oNum)) return false;
  try{
  if(parseFloat(oNum)!=oNum) return false;
  }
  catch(ex)
  {
   return false;
  }
  return true;
}
/*
返回s所占用的字节数（utf8）
*/
function mbStringLength(s) {
        var totalLength = 0;
        var i;
        var charCode;
        for (i = 0; i < s.length; i++) {
          charCode = s.charCodeAt(i);
          if (charCode < 0x007f) {
            totalLength = totalLength + 1;
          } else if ((0x0080 <= charCode) && (charCode <= 0x07ff)) {
            totalLength += 2;
          } else if ((0x0800 <= charCode) && (charCode <= 0xffff)) {
            totalLength += 3;
          }
        }
        //alert(totalLength);
        return totalLength;
      } 
/*
功能：判断obj是否超过n个字节utf8
参数：obj'标签的id名称    n'数字
*/
function CheckStrLen(obj,n)
{ 
 if(mbStringLength(document.getElementById(obj).value)>n)
 {alert('已经超过限定的字节数，请减少字符！');
  document.getElementById(obj).focus(); 
  return   1;
 }
 return 0;
} 
/*
功能：检查obj删除左右空格后是否超n个符
参数：obj'标签的id名称    n'数字
*/
function CheckStrLen2(obj,n)
{ 
 if(document.getElementById(obj).value.replace( /^\s*/, "").replace( /\s*$/, "").length>n)
 {
 document.getElementById(obj).value=document.getElementById(obj).value.replace( /^\s*/, "").replace( /\s*$/, "");
  alert("本输入框最多只能输入"+n+"个字符，请删除"+(document.getElementById(obj).value.replace( /^\s*/, "").replace( /\s*$/, "").length-n)+"字符！");
  document.getElementById(obj).focus(); 
  return   1;
 }
 return 0;
}
/*
功能：判断obj删除左右空格后是否为空
参数：obj'标签的id名称 
*/
function kongzhijiancha(obj)//空值检查
{
 if(!(document.getElementById(obj).value.replace( /^\s*/, "")))
   {
   alert('本输入框不能为空！');
   document.getElementById(obj).value='';
   document.getElementById(obj).focus();
   return   1;
   }
 return 0;
}
/*
功能：检查id里是否有tempArray字符
参数：id'标签的id名称  tempArray'需要查找的字符数组  num tempArray中字符个数 
*/
function checkstr(id,tempArray,num)//检查是否含有非法字符
{
var str=document.getElementById(id).value;
for(k=0;k<num;k++)
   { 
     if(str.indexOf(tempArray[k])<0)//表示没有找到
     {
      continue;
	 
     }
	 else//找到了
	 {
	 //break;
	 alert('找到非法字符【'+tempArray[k]+"】,请删除！");
	 document.getElementById(id).focus();
     return 0;
	 break;
	 }
   }
return 1;
}
/*
chat:反馈给前台的提示
*/
function checkstrtishi(id,tempArray,num,chat)//检查是否含有非法字符
{
var str=document.getElementById(id).value;
for(k=0;k<num;k++)
   { 
     if(str.indexOf(tempArray[k])<0)//表示没有找到
     {
      continue;
	 
     }
	 else//找到了
	 {
	 //break;
	 if(!confirm('在“'+chat+'”中发现字符   '+tempArray[k]+'   ,而本文本框仅接受<font><a>这两个标签,其它的使用   '+tempArray[k]+'   的标签会被删除！您确定吗？'))
	     {document.getElementById(id).focus();
         return 0;
		 }
	 break;
	 }
   }
return 1;
}/*载入flash动画*/
function LoadFlash(url,wmode,width,Height)
{ 
document.write(
   '<embed src="' + url + '" wmode=' + wmode +
   ' quality="high" pluginspage=http://www.macromedia.com/go/getflashplayer type="application/x-shockwave-flash" width="' + width + 
   '" height="' + Height + '"></embed>');  
}
/*
无间断滚动，作者齐照林
speed,direct,demo,demo2,demo1,stoptime,xiangsu,tag 速度，方向，大容器ID，主容器ID,附加器ID，暂停时间为0时不暂停，一次滚动暂停的像素前项为0时无意义,设置为不同的字符可实现一个页面多个滚动窗口
demo:
<DIV style="WIDTH: 300px; BACKGROUND: #9C9; border:#000 solid 1px; HEIGHT:55px;   COLOR: #ffffff; OVERFLOW: hidden" id='demo' align="center">
<div id='demo1'>
     <div>
       <div style="width:200px; padding:5px 0px 5px 0px; background-color:#f30;">1式发发额度的看</div>
       <div style="width:200px; padding:5px 0px 5px 0px; background-color:#0d0;">2放十分地方撒的</div>
       <div style="width:200px; padding:5px 0px 5px 0px; background-color:#330;">3方式发发额度的</div>
       <div style="width:200px; padding:5px 0px 5px 0px; background-color:#13f;">4反而威尔额为饿</div>
     </div>
</div>
<div id='demo2' vAlign=top></div>
 </DIV> 
exframe_marquee(1,'up','demo','demo1','demo2',3000,37,'sss');
*/
function exframe_marquee(speed,direct,demo,demo1,demo2,stoptime,xiangsu,tag)
{
document.getElementById(demo2).innerHTML=document.getElementById(demo1).innerHTML;
function Marquee_up(){if(stoptime&&document.getElementById(demo).scrollTop%xiangsu==0) stopone();if(document.getElementById(demo2).offsetHeight-document.getElementById(demo).scrollTop<=0)document.getElementById(demo).scrollTop-=document.getElementById(demo1).offsetHeight;else{document.getElementById(demo).scrollTop++};}
function Marquee_down(){if(stoptime&&document.getElementById(demo).scrollTop%xiangsu==0) stopone();if(document.getElementById(demo).scrollTop<=0)document.getElementById(demo).scrollTop+=document.getElementById(demo1).offsetHeight;else{document.getElementById(demo).scrollTop--};}
function Marquee_left(){if(stoptime&&demo.scrollLeft%xiangsu==0) stopone();if(demo2.offsetWidth-demo.scrollLeft<=0)demo.scrollLeft-=demo1.offsetWidth;else{demo.scrollLeft++};}
function Marquee_right(){if(stoptime&&demo.scrollLeft%xiangsu==0) stopone();if(demo.scrollLeft<=0)demo.scrollLeft+=demo1.offsetWidth;else{demo.scrollLeft--};} 
function stopone(){eval("clearInterval(MyMar"+tag+")");eval("MyStart"+tag+"=setInterval(startone,stoptime)");}//暂停
function startone(){eval("MyMar"+tag+"=setInterval(Marquee_"+direct+",speed)");eval("clearInterval(MyStart"+tag+")");}//启动
eval("MyMar"+tag+"=setInterval(Marquee_"+direct+",speed)");
document.getElementById(demo).onmouseover=function() {eval("clearInterval(MyMar"+tag+")");eval("clearInterval(MyStart"+tag+")");};
document.getElementById(demo).onmouseout=function() {eval("MyMar"+tag+"=setInterval(Marquee_"+direct+",speed)");}
}
