﻿function fnCategoryClick(num)
{
    if(eval("document.Form1.CheckCategory" + num).value==0)
    {
      for(nIndex=1 ; nIndex < document.Form1.txCategoryNum.value	; nIndex++)
      {
	    if(eval("document.Form1.CheckCategory" + nIndex).checked  == true)
	    {
	        eval("document.Form1.CheckCategory" + nIndex).checked  = false
	    }
      }
    }
    else
    {
		if(eval("document.Form1.CheckCategory" + document.Form1.txCategoryNum.value).checked  == true)
		{
		    eval("document.Form1.CheckCategory" + document.Form1.txCategoryNum.value).checked  = false
		}
	}
}
function fnClickArticleType(num)
{
    if(eval("document.Form1.CheckArticleType" + num).value==0)
    {
	    for(nIndex=1 ; nIndex < document.Form1.txArticleType.value	; nIndex++)
	    {
		    if(eval("document.Form1.CheckArticleType" + nIndex).checked  == true)
		    {
		        eval("document.Form1.CheckArticleType" + nIndex).checked  = false
		    }
	    }
	}
	else
	{
        if(eval("document.Form1.CheckArticleType" + document.Form1.txArticleType.value).checked  == true)
		{
		    eval("document.Form1.CheckArticleType" + document.Form1.txArticleType.value).checked  = false
		}
	}
}		

function fnClickTextDomain(num)
{
           if(eval("document.Form1.CheckTextDomain" + num).value==0)
            {
			  for(nIndex=1 ; nIndex < document.Form1.txDomain.value	; nIndex++)
			  {
				if(eval("document.Form1.CheckTextDomain" + nIndex).checked  == true)
				{
				    eval("document.Form1.CheckTextDomain" + nIndex).checked  = false
				}
			  }
			}
			else
			{
				if(eval("document.Form1.CheckTextDomain" + document.Form1.txDomain.value).checked  == true)
				{
				    eval("document.Form1.CheckTextDomain" + document.Form1.txDomain.value).checked  = false
				}
			}
}		

function Search()
{
	//if(document.Form1.txSearchStr.value==""  )
	//{
		//alert("لطفا عبارت جستجو را وارد کنيد")	
		//return false
	//}
    //if(document.Form1.txSearchStr.value.length==1)
	//{
		//alert("طول کلمه بايد بيشتر از يک باشد")
		//return false
	//}
	
    if(fnGetAllChecked())
    {
      return true;
    } 
    return false;

}
function fnCA(ArticleId,index)
	{
	strorder=""
//	for(nIndex=0 ; nIndex <= 2	; nIndex++)
//	{
//		if(eval("document.Form1.RadioButtonList1[" + nIndex+"]").checked  == true)
//		{
//			strorder = nIndex
//		}
//	}
	strorder = 0;
//     window.location = "/view/Search/ViewResult.aspx?Mode=0&ArticleId="+ArticleId+"&ArticleRec="+index+"&txAllCheck="+document.Form1.txAllCheck.value+"&txMagazineChecked="+document.Form1.txMagazineChecked.value+"&TypeOrder="+strorder+"&txSearchStr="+document.Form1.txSearchStr.value+"&txArticleMaxRec="+document.Form1.txArticleMaxRec.value
     window.location = "/view/Search/ViewResult.aspx?Mode=0&ArticleId="+ArticleId+"&txSearchStr="+document.Form1.txSearchStr.value;
	
//				alert(ArticleId)
//				alert(index)
	}

function fnAnavinChecked()
{
		strCategory=""
		for(nIndex=1 ; nIndex <= document.Form1.txCategoryNum.value	; nIndex++)
		{
			if(eval("document.Form1.CheckCategory" + nIndex).checked  == true)
			{
				//strCategory += nIndex + ","
				strCategory +=eval("document.Form1.CheckCategory" + nIndex).value + ","
			}
		}
		
		//کتابي انتخاب نشده
		if(strCategory == "")
		{
			alert("لطفا يکي از گزينه هاي دامنه موضوعي را انتخاب کنيد")	
			return null
		}
		else
		{
		strAllId = ""
		strArticleType =""
		strTextDomain=""
		for(nIndex=1 ; nIndex <= document.Form1.txDomain.value ; nIndex++)
		{
			if(eval("document.Form1.CheckTextDomain" + nIndex).checked  == true)
			{
				strTextDomain += eval("document.Form1.CheckTextDomain" + nIndex).value + ","							
			}
		}
		for(nIndex=1 ; nIndex <= document.Form1.txArticleType.value ; nIndex++)
		{
			if(eval("document.Form1.CheckArticleType" + nIndex).checked  == true)
			{
                  strArticleType += eval("document.Form1.CheckArticleType" + nIndex).value + ","
				
			}
		}
		
		strAllId+=strCategory+"-"+strTextDomain+"-"+strArticleType+"-"
		//alert(strAllId)		
		document.Form1.txAllCheck.value=strAllId
		//alert(strCategory)		
		document.Form1.txMagezine.value=strCategory
		document.Form1.TextMode.value = 3
		document.Form1.txIsMagazineClick.value = "1" 
		//document.all.anavin.style.display = "none";	
		document.Form1.submit()
		}

}			
//---------------------------------------		
function fnGetAllChecked()
{
		strAllId = ""
		strArticleType =""
		strCategory=""
		strTextDomain=""
		for(nIndex=1 ; nIndex <= document.Form1.txCategoryNum.value	; nIndex++)
		{
			if(eval("document.Form1.CheckCategory" + nIndex).checked  == true)
			{
				//strCategory += nIndex + ","
				strCategory +=eval("document.Form1.CheckCategory" + nIndex).value + ","
			}
		}
		for(nIndex=1 ; nIndex <= document.Form1.txDomain.value ; nIndex++)
		{
			if(eval("document.Form1.CheckTextDomain" + nIndex).checked  == true)
			{
				//strTextDomain += nIndex + ","
				strTextDomain += eval("document.Form1.CheckTextDomain" + nIndex).value + ","							
			}
		}
		for(nIndex=1 ; nIndex <= document.Form1.txArticleType.value ; nIndex++)
		{
			if(eval("document.Form1.CheckArticleType" + nIndex).checked  == true)
			{
				//strArticleType += nIndex + ","
                  strArticleType += eval("document.Form1.CheckArticleType" + nIndex).value + ","
				
			}
		}
		
		//کتابي انتخاب نشده
		if(strCategory == "")
		{
			alert("لطفا يکي از گزينه هاي دامنه موضوعي را انتخاب کنيد")	
			return false;
		}
		else
		{
		    strAllId+=strCategory+"-"
		}
		if(strTextDomain == "")
		{
			alert("لطفا يکي از گزينه هاي جايگاه هرمطلب را انتخاب کنيد ")	
			return false;
		}
		else
		{
		    strAllId+=strTextDomain+"-"
		}
		if(strArticleType == "")
		{
			alert("لطفا يکي از گزينه هاي نوع مطلب را انتخاب کنيد")		
			return false;
		}
		else
		{
		    strAllId+=strArticleType+"-";
		}
		document.Form1.txAllCheck.value=strAllId
		return true;
}

function switchAdv(flag)
{
    if(flag)
    {
        document.getElementById("panelSearch").style.display="block";
        document.getElementById("showAdv").style.display="none";
        document.getElementById("hideAdv").style.display="inline";
    }
    else
    {
        document.getElementById("panelSearch").style.display="none";
        document.getElementById("showAdv").style.display="inline";
        document.getElementById("hideAdv").style.display="none";
    }
    SetSize();
    return false;
}