//图片播放
function flashshow(src,width,height,container)
{
	if (!document.getElementById) return;
	var swfstr='';
	swfstr += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + width + '" height="' + height + '" align="middle">';
	swfstr += '<param name="movie" value="' + src + '" />';
	swfstr += '<param name="menu" value="false" />';
	swfstr += '<param name="quality" value="high" />';
	swfstr += '<param name="wmode" value="transparent" />';
	swfstr += '<param name="bgcolor" value="#ffffff" />';
	swfstr += '<embed src="' + src + '" menu="false" quality="high" wmode="transparent" bgcolor="#ffffff" width="' + width + '" height="' + height + '" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	swfstr += '</object>';
	document.getElementById(container).innerHTML = swfstr;
}

function visit(){
	if (!document.getElementById) return;
	var website=document.getElementById("website");
	if (website.options[website.selectedIndex].value) window.open(website.options[website.selectedIndex].value);
}

//报告
var last_reportdir_id = 1;
function show_reportdir(id){
	
	if (last_reportdir_id != id)
	{
		document.getElementById("reportdir_li_" + last_reportdir_id ).className = "";
		document.getElementById("reportdir_" + last_reportdir_id ).className = "hide";
		
		document.getElementById("reportdir_li_" + id ).className = "choose";
		document.getElementById("reportdir_" + id ).className = "";
		
		last_reportdir_id = id ;
	}
}

///定位导航
function BindVocationNav(classid)
{
	if($("Class"+classid))
	{
	   //$("Class"+classid).className="top2";
	}
	
}

function ShowPosition(classid,channelid)
{
	if(typeof(classid)!="undefined")
	{
		document.write(GetClassUrl(classid));
		document.write(' <span class="txt_sign">&gt;</span> ');
		document.write(GetChannelUrl(channelid));
	}
}


function GetChannelUrl(cid)
{
	if(cid==415)
	{
		return "<a href=MoreNews.asp?cid=415>艾瑞观点</a> "
	}
	else
	{
		return "<a href=MoreNews.asp?cid=413>行业数据</a> "
	}	
}
function GetClassUrl(classid)
{
    for(var i=0;i<ClassArray.length;i++)
	{
	    if(classid==ClassArray[i][0])
		{
			return "<a href=/Consulting/"+ClassArray[i][2]+"/ >"+ClassArray[i][1]+"</a>";
		}
	}
}
function GetArticleUrl(classid,artid)
{
    for(var i=0;i<ClassArray.length;i++)
	{
	    if(classid==ClassArray[i][0])
		{
			return "/Consulting/"+ClassArray[i][2]+"/DetailNews.asp?id=" + artid;
		}
	}
}

function GetClassName()
{
	var classid=Common.GetParam("Classid");
    for(var i=0;i<ClassArray.length;i++)
	{
	    if(classid==ClassArray[i][0])
		{
			document.write(ClassArray[i][1]);
			return;
		}
	}
}

function DownReport()
{
	location.href="";
}

function TopSearch()
{
	var key=document.Search_form.Key.value;
	var type=document.Search_form.Type.value;
	if(key=="")
	{
		alert("请输入要搜索的关键字！");
		document.Search_form.Key.focus();
		return ;
	}
	else
	{
		top.location.href='/search/Search.asp?keyword='+key+'&type='+type;
	}
	/*
	if(document.Search_form.Type.value=="0")
	{
		top.location.href='/Search.asp?key='+key;
	}
	else if(document.Search_form.Type.value=="1")
	{
		top.location.href='/Consulting/MoreNews.asp?cid=415&key='+key;
	}
	else if(document.Search_form.Type.value=="5")
	{
		top.location.href='/Consulting/MoreNews.asp?cid=413&key='+key;
	}
	else if(document.Search_form.Type.value=="21")
	{
		top.location.href='/Data/iAdTracker/MoreNews.asp?i=5&key='+key;
	}
	else if(document.Search_form.Type.value=="22")
	{
		top.location.href='/Data/iUserTracker/MoreNews.asp?i=6&key='+key;
	}
	else if(document.Search_form.Type.value=="3")
	{
		top.location.href='/Report/Search.asp?f=1&key='+key;
	}
	else if(document.Search_form.Type.value=="4")
	{
		top.location.href='/Report/Search.asp?f=0&key='+key;
	}
	*/
}

var Common=new function()
{
     this.ArrayValue=function ( xmlobj ) {
		var arrobj = new Array();
		var i=0;
		var response=xmlobj.getElementsByTagName('Response')[0];
		var element = response.firstChild;
		arrobj[i] = element.firstChild.nodeValue;
	    while ( element.nextSibling != null )
	    {
		     element = element.nextSibling
			 i ++;
		     arrobj[i] = element.firstChild.nodeValue;
		}
	    return arrobj;
      }
	  this.GetStringLength=function(str)
	  {
           var i = 0;
           var cap = str.length*2;    
           var j=0;
           var runtime = (str.length>cap)?(cap+1):str.length;
           for (i = 0; i< runtime; i++) {     
               if (str.charCodeAt(i) > 127 || str.charCodeAt(i) == 94)
			   {
                 j=j+2;  
               } 
               else {
                 j=j+1
               }   
           }
		   return j;
	  }
	  this.GetParam=function(argName)
	  { 
			var args = location.search;
			var reg = new RegExp('[\?&]?' + argName + '=([^&]*)[&$]?', 'gi');
			var chk = args.match(reg);
			return  RegExp.$1;
	   }
	   
	   this.BuildDivTip=function()
	   {
			var disww=window.document.body.offsetWidth+28;
			var dishh=window.document.body.offsetHeight+60;
			document.write('<div id="DivTip" class="DivTip" style="width:' + disww +'px;height:' + (dishh+70) +'px!important;'+dishh+'px"></div>');
	   }
	   
	   this.ShowDialog=function(url,name,w,h)
	   {
	       var theDes = "status:no;center:yes;help:no;minimize:no;maximize:no;dialogWidth:"+w+"px;scroll:no;dialogHeight:"+h+"px;border:think";
           return self.showModalDialog(url,name,theDes);
	   }
       this.Substr=function (str,num1,num2)
	   {
			var bytes=0; 
			var retStr="";
			for(var i=0;i<str.length;i++){  
				if(str.charCodeAt(i)>127){
						 bytes=bytes+2;
				}
				else{
						bytes++;
				}
				if (bytes<(num2+1) && bytes>(num1-1)){
						retStr=retStr+str.charAt(i);
				}
			}
		  return retStr;
	    }
		this.GetPageCount=function(total,count)
		{
			if(total % count==0)
			{
				return parseInt(total / count);
			}
			else
			{
				return parseInt(total / count)+1;
			}
		}
		this.ShowLoading=function(tagid,msg)
		{
			if(typeof(msg) != "undefined" )
			{
			   $(tagid).innerHTML="&nbsp;&nbsp;<img src="+domain+"/Common/images/userloading.gif  align='top'>  "+msg+" ";
			}
			else
			{
				$(tagid).innerHTML="&nbsp;&nbsp;<img src="+domain+"/Common/images/userloading.gif  align='top'>";
			}
			   
		}
		this.Favorite=function(id)
		{
		    var url = location.href;
		    var title = document.title;
			switch(id){
				case 'yahoo':
					return window.open('http://myweb.cn.yahoo.com/popadd.html?url='+encodeURI(url)+'&title='+encodeURI(title));
					break;
				case 'baidu':
					return window.open('http://cang.baidu.com/do/add?it='+encodeURI(title)+'&iu='+encodeURI(url));
					break;
				case 'icio':
					return window.open('http://del.icio.us/post?url='+encodeURI(url)+'&title='+encodeURI(title));
					break;
				case 'mail':
					return window.open('mailto:?subject=您的朋友给您推荐来自艾瑞咨询集团的《' + title + '》&body=' +  title + '\n' + url);
					break;
				default :
					return window.open('http://bookmark.iresearch.cn/Favorite.aspx?title='+encodeURI(title)+'&url='+encodeURI(url)+'&excerpt=','Bookmark','scrollbars=no,width=600,height=450,left=80,top=80,status=no,resizable=yes');
			}
		}
        this.GetCheckBoxList=function(objName)
		{
			var result = "";
			var coll=document.all.item(objName)
			if(!coll) return result;
			if(coll.length){
				for(var i=0;i<coll.length;i++)
				{
					if(coll.item(i).checked)
					{
						result += (result == "")?coll.item(i).value:("," + coll.item(i).value);
					}
				}
			}else{
				if(document.all.item(objName).checked)
				{
					result = document.all.item(objName).value;
				}
			}
			return result;
		}
		this.GetRadioBox=function (objName)
		{
			var Coll = document.all.item(objName);
			if(!Coll) return null;
			if(Coll.length)
			{
				for(var i=0;i<Coll.length;i++)
				{
					if(Coll.item(i).checked)
					{
						return Coll.item(i).value;
					}
				}
				return null;
			}else{
				return Coll.checked?Coll.value:null;
			}
		}
		this.SelectAllCheckBox=function(objName,checked)
		{
			var coll=document.all.item(objName)
			if(!coll) return;
			if(coll.length){
				for(var i=0;i<coll.length;i++)
				{
					if(checked)
					{
					    coll.item(i).checked=true;
					}
					else
					{
						coll.item(i).checked=false;
					}
				}
			}else{
					if(checked)
					{
					    document.all.item(objName).checked=true;
					}
					else
					{
						document.all.item(objName).checked=false;
					}
			}
		}
		this.ReverseCheckBox=function(objName)
		{
			var coll=document.all.item(objName)
			if(!coll) return;
			if(coll.length){
				for(var i=0;i<coll.length;i++)
				{
					coll.item(i).checked=!coll.item(i).checked;
				}
			}else{
				document.all.item(objName).checked=!document.all.item(objName).checked;
			}
		}
}

function copyToClipBoard(title,url)
{
	var clipBoardContent = ''; 
	clipBoardContent += document.title;
	clipBoardContent += "\r\n" + location.href;
	window.clipboardData.setData("Text",clipBoardContent);
}

function fav(id,title)
{
	switch(id){
		case 1:
			url = 'http://myweb.cn.yahoo.com/popadd.html?url=' + location.href + '&title=' + title;
			break;
		case 2:
			url = 'http://cang.baidu.com/do/add?it=' + title + '&iu=' + location.href;
			break;
		case 3:
			url = 'http://del.icio.us/post?url=' + location.href + '&title=' + title;
			break;
		case 4:
			url = 'mailto:?subject=您的朋友给您推荐来自艾瑞咨询集团的《' + title + '》&body=' +  title + '：' + location.href;
			break;
	}
	window.open(url);
}

function chkFeedback(id){
	if(!document.research_form.name.value){
		alert("姓名不能为空！");
		document.research_form.name.focus();
		return;
	}
	if(!document.research_form.comp.value){
		alert("公司/机构名称不能为空！");
		document.research_form.comp.focus();
		return;
	}
	if(!document.research_form.tel.value){
		alert("联系电话不能为空！");
		document.research_form.tel.focus();
		return;
	}
	if(!document.research_form.email.value){
		alert("电子邮件不能为空！");
		document.research_form.email.focus();
		return;
	}else{
		 re = /^([\.\w-]){1,}@([\w-]){1,}(\.([\w]){2,4}){1,2}$/;
		 if (!re.test(document.research_form.email.value)){
			alert("EMail填写错误！");
			document.research_form.email.focus();
			return;
		}
	}
	document.research_form.cansubmit.value=1;
	document.research_form.action="mail.asp?id="+id;
	document.research_form.submit();
	return true;
}

//导航

function setChoose(id){
	if (!id){ id = 0}
	$('nav_' + id).className = 'choose';
	if ($('s_nav_' + id)) $('s_nav_' + id).className = 'pd_menu2';
}