﻿// JavaScript Document
function cvTab2(num,obj){
	//alert(num);
	var mli=document.getElementById("cv2_nav").getElementsByTagName("li");
	obj.style.cssText="background:url(images/img_titlebg.png) -56px 0px no-repeat; width:56px; height:25px; margin-right:4px; text-align:center; line-height:32px;";
	document.getElementById("cv2c0"+num).style.cssText="display:block; width:981px; height:227px; border:none; border-left:1px solid #c2e6fe; border-right:1px solid #c2e6fe;";
	for(i=1;i<=mli.length;i++){
	  if(i!=num){
		document.getElementById("cv2li_0"+i).style.cssText="background:url(images/img_titlebg.png) no-repeat; width:56px; height:25px; margin-right:4px; text-align:center; line-height:32px;";
	    document.getElementById("cv2c0"+i).style.cssText="display:none; width:981px; height:227px; border:none; border-left:1px solid #c2e6fe; border-right:1px solid #c2e6fe;";
	  }
	}
}

function cvTab3(num,obj){
	//alert(num);
	var mli=document.getElementById("cv3_nav").getElementsByTagName("li");
	obj.style.cssText="background:url(images/img_titlebg.png) -56px 0px no-repeat; width:56px; height:25px; margin-right:4px; text-align:center; line-height:32px;";
	document.getElementById("cv3c0"+num).style.cssText="display:block; width:981px; height:227px; border:none; border-left:1px solid #c2e6fe; border-right:1px solid #c2e6fe;";
	for(i=1;i<=mli.length;i++){
	  if(i!=num){
		document.getElementById("cv3li_0"+i).style.cssText="background:url(images/img_titlebg.png) no-repeat; width:56px; height:25px; margin-right:4px; text-align:center; line-height:32px;";
	    document.getElementById("cv3c0"+i).style.cssText="display:none; width:981px; height:227px; border:none; border-left:1px solid #c2e6fe; border-right:1px solid #c2e6fe;";
	  }
	}
}
function cvTab4(num,obj){
	//alert(num);
	var mli=document.getElementById("cv4_nav").getElementsByTagName("li");
	obj.style.cssText="background:url(images/img_titlebg.png) -56px 0px no-repeat; width:56px; height:25px; margin-right:4px; text-align:center; line-height:32px;";
	document.getElementById("cv4c0"+num).style.cssText="display:block; width:981px; height:227px; border:none; border-left:1px solid #c2e6fe; border-right:1px solid #c2e6fe;";
	for(i=1;i<=mli.length;i++){
	  if(i!=num){
		document.getElementById("cv4li_0"+i).style.cssText="background:url(images/img_titlebg.png) no-repeat; width:56px; height:25px; margin-right:4px; text-align:center; line-height:32px;";
	    document.getElementById("cv4c0"+i).style.cssText="display:none; width:981px; height:227px; border:none; border-left:1px solid #c2e6fe; border-right:1px solid #c2e6fe;";
	  }
	}
}

function AddFavorite(sURL, sTitle)
{
    try{ window.external.addFavorite(sURL, sTitle);}
    catch (e)
    {  try { window.sidebar.addPanel(sTitle, sURL, "");}
       catch (e){   alert("加入收藏失败，请使用Ctrl+D进行添加");}
    }
}
function SetHome(obj,vrl)
{
    try{ obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);}
    catch(e){if(window.netscape) {try {netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } 
	catch (e) {alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); }
	var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);prefs.setCharPref('browser.startup.homepage',vrl);}}
}

function highlightWord(node, word) {
    // Iterate into this nodes childNodes 
    if (node.hasChildNodes) {
       var hi_cn;
       for (hi_cn = 0; hi_cn < node.childNodes.length; hi_cn++) {  highlightWord(node.childNodes[hi_cn], word);}
    }
    // And do this node itself 
    if (node.nodeType == 3) { // text node 
            tempNodeVal = node.nodeValue.toLowerCase();
            tempWordVal = word.toLowerCase();
            if (tempNodeVal.indexOf(tempWordVal) != -1) {
                    pn = node.parentNode;
                    if (pn.className != "highlight") {
                            // word has not already been highlighted! 
                            nv = node.nodeValue;
                            ni = tempNodeVal.indexOf(tempWordVal);
                            // Create a load of replacement nodes 
                            before = document.createTextNode(nv.substr(0, ni));
                            docWordVal = nv.substr(ni, word.length);
                            after = document.createTextNode(nv.substr(ni + word.length));
                            hiwordtext = document.createTextNode(docWordVal);
                            hiword = document.createElement("span");
                            hiword.className = "highlight";
                            hiword.appendChild(hiwordtext);
                            pn.insertBefore(before, node);
                            pn.insertBefore(hiword, node);
                            pn.insertBefore(after, node);
                            pn.removeChild(node);
                    }
            }
    }
}


//根据Tag名高亮关键字
function SearchHighlightTag(node, key) {
    if (!document.createElement) return;
    if (key.length === 0) return false;
    var array = new Array();
    array = key.split(" ");
    var element = document.getElementsByTagName(node);
    for (var i = 0; i < array.length; i++) {
            for (var j = 0; j < element.length; j++) {
                    highlightWord(element[j], array[i]);
            }
    }
}
//根据ID高亮关键字
function SearchHighlightID(node, key) {
    if (!document.createElement) return;
    if (key.length === 0) return false;
    var array = new Array();
    array = key.split(" ");
    var element = document.getElementById(node);
    for (var i = 0; i < array.length; i++) {
            for (var j = 0; j < element.length; j++) {
                    highlightWord(element, array[i]);
            }
    }
}

var GetTextAreaPostion=function(obj) /*记住光标*/
{     
    if(document.selection)
    {
        obj.focus();
        ContentCurrentPostion=document.selection.createRange(); 
    }
    else if(obj.selectionStart||obj.selectionStart=='0'){
        var startPos=obj.selectionStart;
        var endPos=obj.selectionEnd;
        ContentCurrentPostion=new Object();
        ContentCurrentPostion.startPos=startPos;
        ContentCurrentPostion.endPos=endPos;
    }
    else
    {
        ContentCurrentPostion=null;
    }    
}
var setBiaoqing=function(value,id)/*设置表情*/
{
   var str="[m00"+value+"]";
   if(ContentCurrentPostion!=null)
   { 
        $(id).focus(); 
        if(document.selection)
        {           
          ContentCurrentPostion.text=str;         }
        else
        {
            var startPos=ContentCurrentPostion.startPos;
            var endPos=ContentCurrentPostion.endPos;                      
            $(id).value=$(id).value.substring(0,startPos)+str+$(id).value.substring(endPos,$(id).value.length);
        }
    }
    else
    {
         $(id).value+=str;
    }    
}


function CheckEmail(str){  //邮件格式判断
	var sReg = /[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/;
	//var emailRegexp = "^([a-zA-Z0-9_]+[\\.a-zA-Z0-9_-]*){1,}@([a-zA-Z0-9-]+\\.){1,}(com|org|net|edu|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|az|ax|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gsslands|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mkc of|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$";
	if ( ! sReg.test(str) )
	{
		return false;
	}

	return true;
}

function checkMobile(obj){ //检查手机号码
	var reg0 = /^0?1((3|8)[0-9]|5[0-35-9]|4[57])\d{8}$/;   //130--139。180--189。150-159(154除外)
	var my=false;
	if(reg0.test(obj))
	{
	  my=true;
	}
	return my;
	
}


//校验身份证号码
var powers=new Array("7","9","10","5","8","4","2","1","6","3","7","9","10","5","8","4","2");       
var parityBit=new Array("1","0","X","9","8","7","6","5","4","3","2");       
var sex="1";       
//校验身份证号码的主调用      
function validId(obj){       
    var _id=obj.value;       
    if(_id=="")return;       
    var _valid=false;       
    if(_id.length==15){       
        _valid=validId15(_id);       
    }else if(_id.length==18){       
        _valid=validId18(_id);       
    }       
    if(!_valid){       
        obj.focus();       
        return false;       
    } else{
    	return true;
    }      
    //设置性别      
    var sexSel=document.getElementById("sex");       
    var options=sexSel.options;       
    for(var i=0;i<options.length;i++){       
        if(options[i].value==sex){       
            options[i].selected=true;       
            break;       
        }       
    }       
}          
//校验18位的身份证号码      
  
function validId18(_id){       
    _id=_id+"";       
    var _num=_id.substr(0,17);       
    var _parityBit=_id.substr(17);       
    var _power=0;       
    for(var i=0;i< 17;i++){       
        //校验每一位的合法性      
  
        if(_num.charAt(i)<'0'||_num.charAt(i)>'9'){       
            return false;       
            break;       
        }else{       
            //加权      
  
            _power+=parseInt(_num.charAt(i))*parseInt(powers[i]);       
            //设置性别      
  
            if(i==16&&parseInt(_num.charAt(i))%2==0){       
                sex="2";       
            }else{       
                sex="1";       
            }       
        }       
    }       
    //取模      
  
    var mod=parseInt(_power)%11;       
    if(parityBit[mod]==_parityBit){       
        return true;       
    }       
    return false;       
}       
//校验15位的身份证号码      
  
function validId15(_id){       
    _id=_id+"";       
    for(var i=0;i<_id.length;i++){       
        //校验每一位的合法性      
  
        if(_id.charAt(i)<'0'||_id.charAt(i)>'9'){       
            return false;       
            break;       
        }       
    }       
    var year=_id.substr(6,2);       
    var month=_id.substr(8,2);       
    var day=_id.substr(10,2);       
    var sexBit=_id.substr(14);       
    //校验年份位      
  
    if(year<'01'||year >'90')return false;       
    //校验月份      
  
    if(month<'01'||month >'12')return false;       
    //校验日      
  
    if(day<'01'||day >'31')return false;       
    //设置性别      
  
    if(sexBit%2==0){       
        sex="2";       
    }else{       
        sex="1";       
    }       
    return true;       
}       

//购车的显示与隐藏
function showMyCar(){
	  document.getElementById("car").style.display="block";
	  
}

function hiddenMyCar(){
	  document.getElementById("car").style.display="none";
	}

function stop(){return false; } 
function stop2(){} 
function stop1(){if(event.button==2){} } 
function stop3(){if (event.ctrlKey){ } } 
document.onkeydown=stop3; 
document.onselectstart=stop2; 
document.onmousedown=stop1;
document.oncontextmenu=stop;
