function insertFlash(elm, url, b , w, h) {
if (!document.getElementById(elm)) return;
var str = '';
str += '<object width="'+ w +'" height="'+ h +'" border="' + b + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0">';
str += '<param name="movie" value="'+ url +'">';
str += '<param name="quality" value="autohigh">';
str += '<embed width="'+ w +'" height="'+ h +'" src="'+ url +'" quality="autohigh" type="application/x-shockwave-flash" plugspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>';
str += '</object>';
document.getElementById(elm).innerHTML = str;
}

function ch_authcode(elm,no){
	if(no=="" || no=="-"){
		if(document.getElementById('authcode_no_val')){
		no=document.getElementById('authcode_no_val').innerHTML;
		document.forms[0].input_auth_time.value=no;
		}
	}
//	alert(no);
	if(no!="" && no!="-"){
	v=Math.random()*100+1
	document.getElementById(elm).src = "/authcode.php?mode=change&no_id=" + no + "&v=" + v;
	}
}

function get_authcode(elm,no){
	if(no=="" || no=="-"){
		if(document.getElementById('authcode_no_val')){
		no=document.getElementById('authcode_no_val').innerHTML;
		document.forms[0].input_auth_time.value=no;

		}
	}
//	alert(no);
	if(no!="" && no!="-"){
	document.getElementById(elm).src = "/authcode.php?mode=get&no_id=" + no;
	}
}

function disp_authcode(theForm)
{
	imgid="authcode_news";
    code=theForm.input_auth_code.value;
    no=theForm.input_auth_time.value;
	if(no=="" || no=="-"){
		if(document.getElementById('authcode_no_val')){
		no=document.getElementById('authcode_no_val').innerHTML;
		}
		theForm.input_auth_time.value=no;
	}
//alert(theForm.input_auth_time.value);
	imgsrc=document.getElementById(imgid).src;
	if(code.length==0 && imgsrc.indexOf("authcode_click.gif")!='-1'){
		get_authcode(imgid,no);
	}

}


function insertAd(elm, msg) {
if (!document.getElementById(elm)) return;
var str = msg;
document.getElementById(elm).innerHTML = str;
}

function insertArea(elm, alm) {
	
if (!document.getElementById(elm)) return;
if (!document.getElementById(alm)) return;

var str = document.getElementById(alm).innerHTML;
document.getElementById(elm).innerHTML = str;
document.getElementById(alm).innerHTML = "";
}

function show_sec(){
//window.status=' LubPower.Net  润滑油行业第一站　Powered By E3.NET 2007';
var t2 = new Date().getTime();
var str =(t2-t1)/1000;
document.getElementById("web_page_runtime").innerHTML = str;
today = new Date();
var day;
var date;
if(today.getDay()==0) day = "星期日"
if(today.getDay()==1) day = "星期一"
if(today.getDay()==2) day = "星期二"
if(today.getDay()==3) day = "星期三"
if(today.getDay()==4) day = "星期四"
if(today.getDay()==5) day = "星期五"
if(today.getDay()==6) day = "星期六"
if(today.getYear()!=""){
	date = today.getYear() + "年" +(today.getMonth() + 1 ) + "月" + today.getDate() + "日";
}else{
	date = "汽配汽车用品导购";
}
document.getElementById("web_page_today").innerHTML = date;

if(document.getElementById("web_page_member")){
var msg='';
var user = GetCookie('user_id');
if(user==null){
}else{
	msg="欢迎您! " + user + "　<a href=/member/>会员中心</a>　<a href=exit.php>退出</a>";
	document.getElementById("web_page_member").innerHTML = msg;
}
}
}

function add_img(theform){
name=theform.name;

//att_html=document.getElementById("form_att").innerHTML;
att_html="<input type=\"file\" name=\"picfile[]\" class=\"s\" size=\"40\" onchange=\"add_img(" + name + ")\"><br><DIV id=form_img></DIV>";
document.getElementById("form_img").outerHTML = att_html;
}

function reg_check(theform,show_id){
switch(show_id)
{
case 'reg_user_check':
username=theform.user.value;
auth_no=theform.input_auth_time.value;
if(username==null || username==""){
	alert("请输入"+theform.user.title);
}else{
	if(username.length<2 || username.length>15){
	alert(theform.user.title+"长度必须4-15位");
	}else{
	att_html="<iframe frameborder=0 width=150 height=16 src='/check.php?no_id="+auth_no+ "&user="+username+"'scrolling='no'></iframe>";
	document.getElementById(show_id).innerHTML = att_html;
	}
}
break;
case 'reg_unit_check':
unit=theform.unit.value;
auth_no=theform.input_auth_time.value;
if(unit==null || unit==""){
	alert("请输入"+theform.unit.title);
}else{
	att_html="<iframe frameborder=1 width=500 height=100 src='/check.php?no_id="+auth_no+ "&unit="+unit+"'scrolling='yes'></iframe><DIV>通过选择企业，您可加入成为该企业的成员，经过企业创建人或管理员通过验证后，您可以<br>维护企业信息，展示产品、发布商机、动态。</DIV>";
	document.getElementById(show_id).innerHTML = att_html;
}
break;
default:
}

}


// JavaScript Document

function check_submit(theForm)
{
	 loop=theForm.elements.length;
	 for(i=0;i<loop;i++){
		 if((theForm.elements[i].value=="" || theForm.elements[i].value=="-" || theForm.elements[i].value=="-1") && theForm.elements[i].title!="" ){
			 alert("请输入"+theForm.elements[i].title);
			 theForm.elements[i].focus();
			 return false;
		 }
	 }
	 if(theForm.elements['button_ok']){
		 theForm.elements['button_ok'].disabled=true;
	 }
  return (true);
}

function google_search(theForm)
{
	 if(check_submit(theForm)){
	key_q=theForm.q.value;
	document.location='http://www.google.cn/custom?domains=www.qpc168.com&q=' + key_q + '&sitesearch=www.qpc168.com&client=pub-4670864494117977&forid=1&ie=GB2312&oe=GB2312&safe=active&cof=GALT%3A%23008000%3BGL%3A1%3BDIV%3A%23336699%3BVLC%3A663399%3BAH%3Acenter%3BBGC%3AFFFFFF%3BLBGC%3AFFFFFF%3BALC%3A0000FF%3BLC%3A0000FF%3BT%3A000000%3BGFNT%3A0000FF%3BGIMP%3A0000FF%3BLH%3A50%3BLW%3A150%3BL%3Ahttp%3A%2F%2Fwww.qpc168.com%2Fimages%2Flogo.gif%3BS%3Ahttp%3A%2F%2Fwww.qpc168.com%3BFORID%3A1&hl=zh-CN';
	}

}
function go_search(theForm,val)
{
	q_val="key_wd_"+val;
	key_q=theForm.elements[q_val].value;

	document.location='/search/start.php?way='+ val +'&key_wd=' + key_q;
}


function site_search(theForm)
{
	 if(check_submit(theForm)){
	 if(theForm.sort.value=="-"){
		 theForm.sitesearch.value="";
		 theForm.action='http://www.google.com/custom';
		 theForm.submit();
	 }else{
		 if(theForm.sort.value=="0"){
			 theForm.sitesearch.value="www.qpc168.com";
			 theForm.action='http://www.google.com/custom';
			 theForm.submit();
		 }else{
		  return (true);
		 }
	 }
	 }
}


function setTab0dSyn(i,classnamebef,idbef,idall,tabtabbef)
{
	var waitInterval;
	
	var MouseDelayTime=150;//鼠标感应延迟300毫秒
//
	
					_gObj(idbef+i).onmouseout=function(aEvent)
					{					
					      
						  clearTimeout(waitInterval);
				    }
			    	clearTimeout(waitInterval);
					
					var str="setTab0dSyn1("+i+",'"+classnamebef+"','"+idbef+"',"+idall+",'"+tabtabbef+"')";
					
					waitInterval=setTimeout(str,MouseDelayTime);
	
}
function aa(i)
{
	alert("aa is run"+i);
}
//----------------------------------------------------------------------------------
function setTab0dSyn1(i,classnamebef,idbef,idall,tabtabbef)
{
//alert(i);
changDivClass(idbef,idall,i,classnamebef)
selectTab0dSyn(tabtabbef,idall,i);
}

function selectTab0dSyn(div_id,allnum,now){
for(var i= 1; i<= allnum;i++)
{
	if(i==now)
	{
		_gObj(div_id+i).style.display="block";
	}else
	{
		_gObj(div_id+i).style.display="none";
	}
}

//	document.getElementById("tabtabd1").style.display="block";
//	document.getElementById("tabtabd2").style.display="none";

}	


function _gObj(id)
{
return document.getElementById(id);
}

function changDivClass(div_id,all,now,classnamebef)
{
for(var i= 1; i<= all;i++)
{
if(i==now)
{
_gObj(div_id+i).className = classnamebef+"_0a";
}else
{
//_gObj(div_id+i).className = "dj4_"+i;
_gObj(div_id+i).className = classnamebef+"_a";
}
}
}


function GetCookieVal(str,offset)
//获得Cookie解码后的值
{
var endstr = str.indexOf (";", offset);
if (endstr == -1)
endstr = str.length;
return unescape(str.substring(offset, endstr));
}

function SetCookie(name, value)
//设定Cookie值
{
var expdate = new Date();
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))
+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
+((secure == true) ? "; secure" : "");
}
function DelCookie(name)
//删除Cookie
{
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}
function GetCookie(name)
//获得Cookie的原始值
{
var arg = name + "=";
var alen = 0;
var str="";
var cook=document.cookie;
var cook_varlist;
var cook_var;
var start;
var clen;

alen = arg.length;
if(cook.charAt(";")){
	cook_varlist=split(";",cook);
start=cook_varlist.length-1;
cook_var=cook_varlist[start];
clen = cook_var.length;
}else{
cook_var=cook;
clen = cook_var.length;
}
var i = 0;

while (i < clen){
var j = i + alen;
if (cook_var.substring(i, j) == arg){
	str = GetCookieVal (cook_var,j);
	return str; 
}
i = i + 1;
}
return null;
}

function powerpoint(focus_file,focus_width,focus_heigh,text_height,pics,links,texts){
 document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
 document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="'+focus_file+'"><param name="quality" value="high"><param name="bgcolor" value="#FFFFFFF">');
 document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
 document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
 document.write('<embed src="'+focus_file+'" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#F0F0F0" quality="high" width="'+ focus_width +'" height="'+ focus_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');  
 document.write('</object>');
}

function fontZoom(size)
{
 document.getElementById('fontzoom').style.fontSize=size+'px';
}

function ch_page(url,no){
	if(no==""){
		alert("请输入要转到的页码");
	}else{
		if(checknumber(no)){
		 window.location=url + no;
		}else{
		 alert("页码输入不正确");
		}
	}
}

function checknumber(String) 
{ 
var Letters = "1234567890-+"; 
var i; 
var c; 
for( i = 0; i < String.length; i ++ ) 
{ 
c = String.charAt( i ); 
if (Letters.indexOf( c ) ==-1) 
{ 
return false; 
} 
} 
return true; 
} 

function split(chr,String) 
{ 
var slide=new Array();
var i; 
var loop=0;
var tmp="";
var c; 
for( i = 0; i < String.length; i ++ ) { 
c = String.charAt( i ); 
if (c == chr) {
	slide[loop] = tmp;
//	alert( slide[loop]);
	loop++;
	tmp="";
}else{
	tmp=tmp+c;
}
} 
if(tmp.length>0){
	slide[loop] = tmp;
//	alert( slide[loop]);
}
return slide; 
} 
