/*通用加入收藏*/
function bookmark(){
var title=document.title
var url=document.location.href
if (window.sidebar) window.sidebar.addPanel(title, url,"");
else if( window.opera && window.print ){
var mbm = document.createElement('a');
mbm.setAttribute('rel','sidebar');
mbm.setAttribute('href',url);
mbm.setAttribute('title',title);
mbm.click();}
else if( document.all ) window.external.AddFavorite( url, title);
}

function SetHome(obj,url){
	try{
		obj.style.behavior='url(#default#homepage)';obj.setHomePage(url);
	}
	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',url);
		 }
	}
}

function getTimes(){
//	var date = new Date().toLocaleString();
//	date = date.substring(0,date.indexOf(' '))
	document.getElementById('time').innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());
}

function regInput(obj, reg, inputStr)
{
	var docSel	= document.selection.createRange()
	if (docSel.parentElement().tagName != "INPUT")	return false
	oSel = docSel.duplicate()
	oSel.text = ""
	var srcRange	= obj.createTextRange()
	oSel.setEndPoint("StartToStart", srcRange)
	var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
	return reg.test(str)
}

//checkbox的全选与撤消
function checkboxselect(itemname,btn) {
	if(!itemname) 
		return;
	if(document.getElementById(btn).value=="全选")
	{
	    if(!itemname.length) {
		    itemname.checked=1;
	    }
	    else
	    {
		    for(var i=0;i<itemname.length;i++)
		    {itemname[i].checked=1;}
	    }
	    document.getElementById(btn).value="撤销";
	}
	else
	{
	    if(!itemname.length) {
		    itemname.checked=0;
	    }
	    else
	    {
		    for(var i=0;i<itemname.length;i++)
		    {itemname[i].checked=0;}
	    }
	    document.getElementById(btn).value="全选"
	}
}




function innerTip(obj_id,msg){
	if (msg==null){
		$(obj_id).innerHTML='';
	}else {
		$(obj_id).innerHTML=msg;
	}
}

function isEmpty(str){return(str==null)||(str.length==0);}

function LTrim(s){
  for(var i=0;i<s.length;i++)
  if(s.charAt(i)!=' ')
    return s.substring(i,s.length);
  return "";
}

function RTrim(s){
   for(var i=s.length-1;i>=0;i--)
    if(s.charAt(i)!=' ')
    return s.substring(0,i+1);
    return "";
}

function Trim(s){
  return RTrim(LTrim(s));
}

// 函数名: IsURL
// 功  能: 检查Url字段合法性 ( http://字头的检查)
// 参  数: strUrl, Url字符串
// **************************************************************************************************
function IsURL(urlString)
{
		regExp = /(http[s]?|ftp):\/\/[^\/\.]+?\..+\w$/i;
		if (urlString.match(regExp))return true;
		else return false;        
}

function isEmail(str){
		if(isEmpty(Trim(str)))return false;
		var re=/^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i;
		return re.test(str);
}

function reg_check(form){
	var flag = true;
	if (!isEmail(Trim(form.user_count.value))){
		innerTip('error','用户名称不能为空或格式错误.');
		form.user_count.focus();
		flag = false;
	}
	
	if(flag){
		if (isEmpty(Trim(form.user_name.value))){
			innerTip('error','真实姓名不能为空.');
			form.user_name.focus();
			flag = false;
		}
	}
	if(flag){
		if (form.user_pswd.value.length<6){
			innerTip('error','密码长度不得小于6.');
			form.user_pswd.focus();
			flag = false;
		}
	}	
	if(flag){
		if (form.user_pswd.value != form.user_repswd.value){
			innerTip('error','两次输入的密码不一致.');
			form.user_pswd.focus();
			flag = false;
		}
	}	
	if(flag){
		if (isEmpty(Trim(form.user_question.value))){
			innerTip('error','密码问题不能为空.');
			form.user_question.focus();
			flag = false;
		}
	}	
	if(flag){
		if (isEmpty(Trim(form.user_answer.value))){
			innerTip('error','问题答案不能为空.');
			form.user_answer.focus();
			flag = false;
		}
	}	
	if(flag){
		if (isEmpty(Trim(form.user_contact.value))){
			innerTip('error','联系方式不能为空.');
			form.user_contact.focus();
			flag = false;
		}
	}
	return flag;	
}


function fla(url,width,height){
        document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'"> ');
        document.write('<param name="movie" value="' + url + '">');
        document.write('<param name="quality" value="high"> ');
        document.write('<param name="wmode" value="transparent"> ');
        document.write('<param name="menu" value="false"> ');
        document.write('<embed src="' + url + '" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" ></embed> ');
        document.write('</object> ');
}

function flv(url,width,height,autoStart){
	document.write("<OBJECT id=MediaPlayer1 codeBase=http:\/\/activex.microsoft.com\/activex\/controls\/mplayer\/en\/nsmp2inf.cab#Version=5,1,52,701standby=Loading type=application\/x-oleobject height=\""+ height +"\" width=\""+ width +"\" classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 VIEWASTEXT=\"\"><PARAM NAME=\"URL\" VALUE=\""+ url +"\">");
	document.write("<PARAM NAME=\"rate\" VALUE=\"1\">");
	document.write("<PARAM NAME=\"balance\" VALUE=\"0\">");
	document.write("<PARAM NAME=\"currentPosition\" VALUE=\"0\">");
	document.write("<PARAM NAME=\"defaultFrame\" VALUE=\"\">");
	document.write("<PARAM NAME=\"playCount\" VALUE=\"1\">");
	document.write("<PARAM NAME=\"autoStart\" VALUE=\""+ autoStart +"\">");
	document.write("<PARAM NAME=\"currentMarker\" VALUE=\"0\">");
	document.write("<PARAM NAME=\"invokeURLs\" VALUE=\"-1\">");
	document.write("<PARAM NAME=\"baseURL\" VALUE=\"\">");
	document.write("<PARAM NAME=\"volume\" VALUE=\"70\">");
	document.write("<PARAM NAME=\"mute\" VALUE=\"0\">");
	document.write("<PARAM NAME=\"uiMode\" VALUE=\"full\">");
	document.write("<PARAM NAME=\"stretchToFit\" VALUE=\"1\">");
	document.write("<PARAM NAME=\"windowlessVideo\" VALUE=\"0\">");
	document.write("<PARAM NAME=\"enabled\" VALUE=\"-1\">");
	document.write("<PARAM NAME=\"enableContextMenu\" VALUE=\"-1\">");
	document.write("<PARAM NAME=\"fullScreen\" VALUE=\"0\">");
	document.write("<PARAM NAME=\"SAMIStyle\" VALUE=\"\">");
	document.write("<PARAM NAME=\"SAMILang\" VALUE=\"\">");
	document.write("<PARAM NAME=\"SAMIFilename\" VALUE=\"\">");
	document.write("<PARAM NAME=\"captioningID\" VALUE=\"\">");
	document.write("<PARAM NAME=\"enableErrorDialogs\" VALUE=\"0\">");
	document.write("<PARAM NAME=\"_cx\" VALUE=\"6376\">");
	document.write("<PARAM NAME=\"_cy\" VALUE=\"6509\">");
	document.write("<\/OBJECT>")	
}

//新闻图片横向滚动
function ScrollImgLeft(s_begin,s_end,s_div){
	var speed1=20
	var scroll_begin = document.getElementById(s_begin);
	var scroll_end = document.getElementById(s_end);
	var scroll_div = document.getElementById(s_div);
	scroll_end.innerHTML=scroll_begin.innerHTML
	function Marquee1(){
		if(scroll_end.offsetWidth-scroll_div.scrollLeft<=0)
			scroll_div.scrollLeft-=scroll_begin.offsetWidth
		else
			scroll_div.scrollLeft++
	}
	var MyMar1=setInterval(Marquee1,speed1)
	scroll_div.onmouseover=function() {clearInterval(MyMar1)}
	scroll_div.onmouseout=function() {MyMar1=setInterval(Marquee1,speed1)}
}


//设置左右div高度相等
function left_right(obj_left,obj_right){
	var obj_l = document.getElementById(obj_left);
	var obj_r = document.getElementById(obj_right);
	if((obj_l.clientHeight<500) && (obj_r.clientHeight<400)){
		obj_l.style.height=500+"px";
		obj_r.style.height=500+"px";
	}else{
		if(obj_l.clientHeight<obj_r.clientHeight){   
  		obj_l.style.height=obj_r.clientHeight+"px";   
		}else{   
			obj_r.style.height=obj_l.clientHeight+"px";   
		}
	}
}

//设置iframe高度
function resize_iframe(i_height){
	var obj_f = document.getElementById("childFrame");
  if(obj_f.clientHeight<i_height){ 
  	obj_f.style.height=i_height+"px";   
  } 
}



function openWin(url){	
  var width="500", height="400";
  var left = (screen.width/2) - width/2;
  var top = (screen.height/2) - height/2;
  var styleStr = 'toolbar=no,location=no,status=no,resizable=no,scrollbars=no,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;	  
  window.open(url,"NewWin",styleStr);	
}

function menuFix() { 
	getTimes();
	var sfEls = document.getElementById("nav").getElementsByTagName("li"); 
	for (var i=0; i<sfEls.length; i++) { 
		sfEls[i].onmouseover=function() { 
			this.className+=(this.className.length>0? " ": "") + "sfhover"; 
		} 
		sfEls[i].onMouseDown=function() { 
			this.className+=(this.className.length>0? " ": "") + "sfhover"; 
		} 
		sfEls[i].onMouseUp=function() { 
			this.className+=(this.className.length>0? " ": "") + "sfhover"; 
		} 
		sfEls[i].onmouseout=function() { 
			this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"),""); 
		} 
	} 
} 
//window.onload=menuFix;


function DrawImage(ImgD,i_width,i_height){
	var flag=false;
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		flag=true;
		if(image.width/image.height>= 1){
			if(image.width>i_width){ 
				ImgD.width=i_width;
				ImgD.height=(image.height*i_width)/image.width;
			}else{
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}
			}
		else{
			if(image.height>i_height){ 
				ImgD.height=i_height;
				ImgD.width=(image.width*i_height)/image.height; 
			}else{
				ImgD.width=image.width; 
				ImgD.height=image.height;
		}
		}
	}
}


function checkform(form)
{
  var reg=/^[0-9a-zA-Z-_]{5,15}$/;
  if(!reg.exec(Trim($('strCode').value))){
    alert('查询单号格式不正确。');
		$('strCode').focus();
		return false;
  }
	return true;
}

//获取页面ID为objString的对象
function $(objString){
	return document.getElementById(objString);
}