﻿
function setPanelStatus(panelId,obj)
{
    panelId=document.getElementById(panelId);
	if(panelId.style.display == 'none')
	{
		panelId.style.display = 'block';
	
	    var parentTar=panelId.parentNode;
	    if(parentTar)
	    {
	        parentTar.style.width="600px";
	    }
		obj.src="/Images/menu_title_up.gif";
		
	}
	else 
	{
		panelId.style.display = 'none';
		obj.src="/Images/menu_title_down.gif";
		var parentTar=panelId.parentNode;
	    if(parentTar)
	    {
	        parentTar.style.width="140px";
	    }
	}
}


function getBrandJson(companyid,drpid,btn)
{
if(btn.value=='所有品牌')
 companyid='';
var url = '/ajax/BrandIt.ashx';
var pars = 'companyid=' + companyid;
var myAjax = new Ajax.Request(
url,
{
method: 'get',
parameters: pars,
onComplete: function setBrandJson(data)
{
 var oop=$(drpid).options;
 oop.length=0;
 if(btn.value=='所有品牌')
 {
    btn.value='相关品牌';
    oop.add(new Option('所有品牌列表','0'));
 }
 else
 {
    btn.value='所有品牌';
    oop.add(new Option('相关品牌列表','0'));
 }
 var returnobj = eval('(' + data.responseText + ')').BrandList;
  for (i = 0; i <returnobj.length; i++) {
     oop.add(new Option(returnobj[i].name,returnobj[i].id));
     } 
}
});
}

function cancelCompanyId(ctl1,ctl2)
{
	if(document.all.item(ctl1))
	{
		document.all.item(ctl1).value = "";
	}
	if(document.all.item(ctl2))
	{
		document.all.item(ctl2).value = "";
	}
}

function showSelectCompany(companyType)
{	
	window.open("/Management/CompanyView.aspx?Type="+companyType,"Select","height=400,width=800,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
}

function DefShowSelectCompany()
{
	window.open("/Management/CompanyView.aspx?Type=COM","Select","height=400,width=800,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
}

function openComments(id,type) 
{ 
 window.open("/Management/Comments.aspx?Id="+id+"&type="+type, "comments", "height=300, width=600, toolbar=no , menubar=no, scrollbars=no, resizable=no, location=no, status=no");
}


function selectCompany(id,text)
{
//    if(window.opener.document.all.item('ctlToolTip') )
//	{
//		window.opener.document.all.item('ctlToolTip').value = text;
//	}	
	
	if(window.opener.document.getElementById('ctlCompanyId') )
	{
		window.opener.document.getElementById('ctlCompanyId').value = id;
	}		
//	if(window.opener.document.all.item('ctlUrl') )
//	{
//		window.opener.document.all.item('ctlUrl').value = '/Common/CompanyPage.aspx?Type=index&CompanyID='+id+'&Id='+id;
//	}
	if(window.opener.document.getElementById('ctlCompanyName') )
	{
		window.opener.document.getElementById('ctlCompanyName').value = text;
	}		
	window.close();
}

	 function table_display(name)
	 {
	   if(document.getElementById(name).style.display=="none")
	      document.getElementById(name).style.display='';
		else
		  document.getElementById(name).style.display='none';
	 }

function loadHits(spanid,type,id)
{
  if($(spanid)!=null)
  {
        var myAjax=new Ajax.Request(
        '/ajax/stat.aspx',
       {
         method:'get',
         parameters: 'type='+type+'&id='+id,
         onComplete: function result(data)
          {
             $(spanid).innerHTML=data.responseText;
          }
       }); 
  }
}

function loadComments(spanid,type,id)
{
  if($(spanid)!=null)
  {
        var myAjax=new Ajax.Request(
        '/ajax/CommentStat.aspx',
       {
         method:'get',
         parameters: 'type='+type+'&id='+id,
         onComplete: function result(data)
          {
             $(spanid).innerHTML=data.responseText;
          }
       }); 
  }
}

function showSelectExpo()
{	
	window.open("/Exposition/ExpositionView.aspx","Select","height=400,width=800,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
}
function showSelectExpoAdmin()
{	
	window.open("/Management/ExpositionView.aspx","Select","height=400,width=800,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
}

function selectExpo(id,text)
{
	if(window.opener.document.all.item('ctlExpoId') )
	{
		window.opener.document.all.item('ctlExpoId').value = id;
	}		
	if(window.opener.document.all.item('ctlExpoName') )
	{
		window.opener.document.all.item('ctlExpoName').value = text;
	}	
	if(window.opener.document.all.item('ctl00_ContentPlaceHolder1_ctlExpoId') )
	{
		window.opener.document.all.item('ctl00_ContentPlaceHolder1_ctlExpoId').value = id;
	}		
	if(window.opener.document.all.item('ctl00_ContentPlaceHolder1_ctlExpoName') )
	{
		window.opener.document.all.item('ctl00_ContentPlaceHolder1_ctlExpoName').value = text;
	}			
	window.close();
}

function cancelCompanyId(ctl1,ctl2)
{
	if(document.all.item(ctl1))
	{
		document.all.item(ctl1).value = "";
	}
	if(document.all.item(ctl2))
	{
		document.all.item(ctl2).value = "";
	}
}


//获取URL参数值
function getParameter(strname)
  {
   var hrefstr,pos,parastr,para,tempstr;
   hrefstr = window.location.href;
   pos = hrefstr.indexOf("?")
   parastr = hrefstr.substring(pos+1);
   para = parastr.split("&");
   tempstr="";
   for(i=0;i<para.length;i++)
   {
    tempstr = para[i];
    pos = tempstr.indexOf("=");
    if(tempstr.substring(0,pos).toLowerCase() == strname.toLowerCase())
    {
     return tempstr.substring(pos+1);
     }
   }
   return "";
}


function ShowUploadPicWindow(folder,ctl)
{
	window.open("/Common/UploadFile.aspx?Folder=" + folder +"&ReturnCtl="+ctl,"Select","height=140,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
}