// JavaScript Document

function $(id){
 if(typeof(id)=="string"){
   return document.getElementById(id)
 }
 return id;
}


function k(id){
 if($(id) == null){return false;}
 else {return true;}
}


// 求两个数之间的随机数
function GetRandomNum(Min,Max){   
	var Range = Max - Min;   
	var Rand = Math.random();   
	return(Min + Math.round(Rand * Range));   
}


/*轮换显示(对象,数量,当前)*/
function xhxs(obj,num,now){
	for(var i=0;i<=num;i++) {
		if(k(obj + i)){
			$(obj + i).style.display = "none";
		}
	}
	if(k(obj + now)){
		$(obj + now).style.display = "block";
	}
}
			
			
//  function messengerInstalled() {
//      try {
//            new ActiveXObject("MSNMessenger.P4QuickLaunch");
//            return true;
//      }
//      catch (e) {
//            return false;
//      }
//  }
//  function qqInstalled() {
//      try {
//            new ActiveXObject("QQ.QQAPI");
//            return true;
//      }
//      catch (e) {
//            return false;
//      }
//  }
function SendMsg(sUrl)
{
	
	try   //支持
	{
		var xmlhttp=new ActiveXObject("TimwpDll.TimwpCheck");
		this.location.href=sUrl;        
	}
	catch(e) //不支持
	{
	    alert("亲爱的会员，您目前还没有下载安装TM，暂时无法执行这项操作！");
        javascript:win=window.open('/ystong/tm_down.html');
	}
	return false;
}

function SendMsg_qq(sUrl)
{
	try {
		new ActiveXObject("QQ.QQAPI");
		this.location.href=sUrl;
	}
	catch (e) {
		alert("亲爱的会员，您目前还没有下载安装QQ，暂时无法执行这项操作！");
		javascript:win=window.open('http://im.qq.com/');
	}
}


function DrawImage(ImgD,width_ls,height_ls){ 

	if (width_ls == ""){width_ls = 200}
	if (height_ls == ""){height_ls = 100}
	ImgD.style.display = "block";
	if ((ImgD.width > width_ls || ImgD.height > height_ls) && ImgD.width > 0 && ImgD.height > 0){ 
		if(ImgD.width/ImgD.height>= width_ls/height_ls){ 
			if(ImgD.width > width_ls){
				ImgD.width=width_ls; 
				ImgD.height = (ImgD.height * width_ls) / ImgD.width; 
				ImgD.style.display = 'block'
			}else{ 
				ImgD.height = ImgD.height; 
				ImgD.width = ImgD.width; 
				ImgD.style.display = 'block'
			} 
		/*ImgD.alt="bigpic"  */
		}else{ 
			if(ImgD.height>height_ls){
				ImgD.height = height_ls; 
				ImgD.width = (ImgD.width * height_ls) / ImgD.height; 
				ImgD.style.display = 'block'
			}else{ 
				ImgD.width=ImgD.width;
				ImgD.height=ImgD.height; 
				ImgD.style.display = 'block'
			} 
		/*ImgD.alt="bigpic"  */ 
		} 
	}	
}

//显示·隐藏层
function showDiv(id){
	var div = $(id);
	if(div.style.display=='block') div.style.display='none';
	else div.style.display='block';
}			


//弹出窗口(运行模式，字符串，跳转地址)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//1：提示文字
//2：提示文字，回到上一页
//3：提示文字，跳转到指定页面
//4：无提示，跳转到指定页面


function tc(type_ls,str,dizhi){
	if (str == ""){str = "尚未设置提示文字！";}
	
	if (type_ls == 1){	alert(str);}
	if (type_ls == 2){	alert(str);history.back();}
	if (type_ls == 3){	alert(str);location.href=dizhi;}
	if (type_ls == 4){	history.back();}
}


//下拉框的赋初值(下拉框对象，下拉框所要赋予的初值)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
function fuzhi(obj,zhi)     
{
	if ($(obj) != null)
	{
		for(i=0;i<$(obj).length-1;i++)
		{
			if ($(obj).options[i].value == zhi){$(obj).value = zhi;}
		}
	}
}

//弹出窗口(地址，宽，高)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
function openwin(url,w,h) {
	window.open (url, "gonggao", "height="+ h +", width="+ w +", toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no") ;
}


/* 显示隐藏组合 */
function qiehuan(obj,now){
	
	for (i=1;i<=6;i++){
		if(k(obj + i) && (i != now)){$(obj + i).style.display = 'none';}
	}
	if(k(obj + now)){$(obj + now).style.display = 'block';}

}

/* 样式切换组合 */
function qiehuan_class(yangshi,obj,now){
	
	for (i=1;i<=10;i++){
		if(k(obj + i) && (i != now)){$(obj + i).className = yangshi + '1';}
	}
	if(k(obj + now)){$(obj + now).className = yangshi + '2';}

}

/* 悬浮样式切换 */




















/* 各个页面的个性函数 */
function qiehuan_gexing(obj,type){
	if ($("bt_bottom_on").className != "bt_bottom21_2") {
		if (type == "over"){obj.className = "bt_bottom_0";}
		else {obj.className = "bt_bottom";}
	}
}

function qiehuan_gexing_1(obj,obj_1){
	
	if ($("bt_bottom_on").className != "bt_bottom21_2"){
		$("bt_bottom_on").className = "bt_bottom21_2";
		$("other_web").style.display = "block";
	}
	else{
		$("bt_bottom_on").className = "bt_bottom21_0";
		$("other_web").style.display = "none";
	}	
}


/* 展会地区分类点击更多 */
function gd_on(){
	var o = $("gd_con");
	var o_an = $("gd_on");
	if (o.style.display == "none"){o.style.display = "";o_an.style.display = "none";}
	else {o.style.display = "none";o_an.style.display = "";}
}


/* 注册时候的好东西，处理空格 */
function trim(inputString) {
	
	if (typeof inputString != "string") { return inputString; }
	var retValue = inputString;
	var ch = retValue.substring(0, 1);
	while (ch == " ") { 
		//检查字符串开始部分的空格
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	ch = retValue.substring(retValue.length-1, retValue.length);
	while (ch == " ") {
		//检查字符串结束部分的空格
		retValue = retValue.substring(0, retValue.length-1);
		ch = retValue.substring(retValue.length-1, retValue.length);
	}
	while (retValue.indexOf("  ") != -1) { 
		//将文字中间多个相连的空格变为一个空格
		retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
	}
	return retValue;
} 