﻿
// JScript File
var global=0;
var imageGallery2 = new Array(0);
imageGallery2[0]= new Array(11);

var Dateyr

function getNewsQuickSearch(selID)
{  
    var pageID=selID;
    var temp = (pageID*pageLength)+pageLength;  
    if(temp>imageGallery.length)
    {
       temp=imageGallery.length;
    }
    document.getElementById("newsContainer").innerHTML="";    
	count=0;
	count=Math.ceil(imageGallery.length/pageLength);
	
	stroutput='';
	strPreNext='';		
   stroutput +="<h3>News Archives</h3>";
    
    for(i=(pageID*pageLength);i<temp;i++)
	{
	
	
	var typecheck= imageGallery[i][11];
	typecheck = fRemoveSquarebrace(typecheck); 
		 
	if(i<((pageID*pageLength)+2))
	{
	
        stroutput +="<div>";
        stroutput +="<p>";
        
        
        if(imageGallery[i][8]!="")
        {
            stroutput +="<img height='68' alt='' src='"+imageGallery[i][8]+"' width='68'>";
        }
        else
        {
            stroutput +="<img height='68' alt='' src='/files/img_blankBlue.gif' width='68'>";
        }
        stroutput +="<span class='newshdr_1'><b>"+imageGallery[i][5]+"/"+imageGallery[i][4]+"/"+imageGallery[i][6]+"" +":";
        stroutput +=""+"&nbsp;"+imageGallery[i][2]+"</b></span>";
        stroutput +="<br/>";      
        stroutput +=""+imageGallery[i][7]+"....."+ "";
        stroutput +="<br/>";             
        stroutput +="&nbsp;";      
        if(imageGallery[i][10]!="")
        {      
                
          stroutput +="<a target='_blank' href='"+imageGallery[i][10]+"'>Find out more</a>";
        }     
        else
        {
            if(imageGallery[i][0]!="")
            { 
                stroutput +="<a href='/output/page"+imageGallery[i][0]+".asp'>Find out more</a>";
            }
        }
        
        stroutput +="</p>";       
        
        stroutput +="<div class='clear'/>"
        stroutput +="</div>";         
        
       
       
    }      
    else
    {
        
        if(i==((pageID*pageLength)+2))
        {
            stroutput +="<div>";
            stroutput +="<ul>";
        }        
        stroutput +="<li>";
        stroutput +="<span class='newshdr_1'><b>"+imageGallery[i][5]+"/"+imageGallery[i][4]+"/"+imageGallery[i][6]+"" +":";         
        stroutput +=""+"&nbsp;"+imageGallery[i][2]+"</b></span>";
        stroutput +="<br class='clear'/>";      
        stroutput +=""+imageGallery[i][7]+"....."+ "";
        stroutput +="<br class='clear'/>";             
        stroutput +="&nbsp;";      
        if(imageGallery[i][10]!="")
        {      
                
          stroutput +="<a target='_blank' href='"+imageGallery[i][10]+"'>Find out more</a>";
        }     
        else
        {
            if(imageGallery[i][0]!="")
            { 
                stroutput +="<a href='/output/page"+imageGallery[i][0]+".asp'>Find out more</a>";
            }
        }
        
        stroutput +="</li>";
        if(i==(temp-1))
        {
            stroutput +="</ul>";
            stroutput +="</div>";
        }        
       
    }
        
   }
   // for end
   
       
          document.getElementById("newsContainer").innerHTML=stroutput 
          document.getElementById("prevNext").innerHTML="";  
          
          strPreNext="";
  
          if(pageID == 0)
           { 
            strPreNext +='<img alt="First" src="/files/images/btn-prev.gif" />';
             
           }
           else 
           {
   	         prevpageid=pageID-1;
	         strPreNext +='<input type="image" onclick="getNewsQuickSearch('+0+')" alt="First" src="/files/images/btn-prev.gif" />';	 
        	 
           }  
          //for start 
          
            startlimit=0
            endlimit=count
            
            if(count <= 5)
            {
                startlimit=0;
                endlimit=count;
            }
	        else if(pageID < (count-2))
            {	        
		        if(pageID >= 2)
		        {
		            startlimit=pageID-2;
                    endlimit=pageID+3;
                }
		        else
		        {
			        startlimit=0;
                    endlimit=5; 
                }
            }
            else
            {
	            startlimit=count-5;
                endlimit=count;
            }                
	        
           
          for(i=startlimit;i<endlimit;i++)
	        {    	 
	              if(i == pageID )
	              {
	                strPreNext +="<a style='text-decoration: none;' class='Pagination_a'  >"+ ( i + 1 )  +"</a>";	     
    	          }
    	          else
    	          {
    	            strPreNext +="<a style='text-decoration: underline;'  href='#' onclick='getNewsQuickSearch("+i+")' >"+ ( i + 1 )  +"</a>";	     
    	          }
                  if(i < endlimit -1 )
                  {
                 
                    strPreNext +='<span>|</span>';
                   
                  }          
            }	
	        // for end

         if(pageID == count -1 )
         {
           strPreNext +=' <img src="/files/images/btn-next.gif" alt="Last" />';
           
         }
         else
         {  
          nextpageid=count -1;
           
          strPreNext +='<input type="image" onclick="getNewsQuickSearch('+nextpageid+')" alt="Last" src="/files/images/btn-next.gif" />';      
         }
      
         
        strPreNext +='<br class="clear"/>';
//        strPreNext +="<div class='clear'>";
//        strPreNext +="</div>";      
       
         document.getElementById("prevNext").innerHTML =strPreNext; 
//end of function	
}


function getSearched(selID)
{

       
       var ddlMonth = document.getElementById("searchMonth");  
       var monthValue = ddlMonth.options[ddlMonth.selectedIndex].value;
       var monthtext = ddlMonth.options[ddlMonth.selectedIndex].text;
              
       var ddlYear = document.getElementById("searchYear");  
       yearValue = ddlYear.options[ddlYear.selectedIndex].value;
       
       var ddlSearchCategory= document.getElementById("searchCategory");  
       var categoryValue = ddlSearchCategory.options[ddlSearchCategory.selectedIndex].value; 
       categoryValue = fRemoveSquarebrace(categoryValue);
       
       Dateyr = (monthtext +"-"+yearValue)
         
       
       var strText = document.getElementById("searchText").value;            

       strText=trim11(strText);
       imageGallery2=new Array() ;
       var pageID=selID;
       var temp = (pageID*pageLength)+pageLength;  
      if(temp>imageGallery.length)
       {
         temp=imageGallery.length;         
       }       
        document.getElementById("newsContainer").innerHTML="";
        temp1=0;
	    
	    count=0;
	    count=Math.ceil(imageGallery.length/pageLength);
    	
	    stroutput='';
	    strPreNext='';	
        pageCount=0;
     
     
       var searchMonth=monthValue;
       var searchYear= Right(yearValue,2);
       var count=0;
       if(searchMonth != 10 && searchMonth != 11 && searchMonth !=12)
       {
          searchMonth = 0 + searchMonth;    
       }
     
      imageGallery2=new Array();      
      if(strText == "")
      {  
       
         if(imageGallery.length >0)
         {
         
           global=0;
              for(i=0;i<imageGallery.length;i++)
              {   
        		  
                        var strCheckMonth=  imageGallery[i][4];                                             
                        var strCheckType = imageGallery[i][11];
                        strCheckType =fRemoveSquarebrace(strCheckType);
                      
                        if(strCheckMonth != 10 && strCheckMonth != 11 && strCheckMonth !=12)
                        {  
                          strCheckMonth = 0 + strCheckMonth;  
                        }  
                           
                           if( ( strCheckMonth == searchMonth && imageGallery[i][6]== searchYear  &&  strCheckType == categoryValue))
                          //  if( ( strCheckMonth == searchMonth && imageGallery[i][6]== searchYear))
                           {
                               //start if            
                                 
                                         
                                     
                                     imageGallery2.push(new Array(imageGallery[i][0],imageGallery[i][1],imageGallery[i][2],imageGallery[i][3],imageGallery[i][4],imageGallery[i][5],imageGallery[i][6],imageGallery[i][7],imageGallery[i][8],imageGallery[i][9],imageGallery[i][10],imageGallery[i][11]));                                                          
                                      //,
                                
                                  global = global+1;
                                 //end if                             
                           }
                           
                }
                if(imageGallery2.length >0)
               {
               
                search2(0);
               }
                else
                {
                   stroutput +="<h3>"+Dateyr+"</h3>"; 
                   document.getElementById("prevNext").innerHTML='' 
                   
                   //stroutput +='<div class="t2EventsList">';
                   stroutput ='<p> No news Available</p>';
                   //stroutput +='</div>';      
                
                document.getElementById("newsContainer").innerHTML=stroutput
                }
        }
        else
        {
           stroutput +="<h3>"+Dateyr+"</h3>";
           document.getElementById("prevNext").innerHTML='' 
           
           stroutput +='<p> No news Available</p>';
           //stroutput +='</div>';              
           document.getElementById("newsContainer").innerHTML=stroutput
        }
  
      }
      else
      {       
         


     global=0;
     
      for(i=0;i<imageGallery.length;i++)
      {   
		  
                var strCheckMonth=  imageGallery[i][4];
                if(strCheckMonth != 10 && strCheckMonth != 11 && strCheckMonth !=12)
                {  
                  strCheckMonth = 0 + strCheckMonth;  
                }            
               
                              
                var str7 = imageGallery[i][7];
                str7 = str7.toUpperCase(); 
                var str1 = imageGallery[i][1];
                str1 = str1.toUpperCase();
                var str2 =imageGallery[i][2];
                str2 = str2.toUpperCase();
                
                var str11= imageGallery[i][11]
                str11 = fRemoveSquarebrace(str11);
                
                
                if( ( strCheckMonth == searchMonth && imageGallery[i][6]== searchYear && str11 == categoryValue) && ( str7.indexOf(strText.toUpperCase() ) !=-1 || str1.indexOf(strText.toUpperCase())!=-1 || str2.indexOf(strText.toUpperCase())!=-1))
                {
                 //start if            
                 
                         
                     
                     imageGallery2.push(new Array(imageGallery[i][0],imageGallery[i][1],imageGallery[i][2],imageGallery[i][3],imageGallery[i][4],imageGallery[i][5],imageGallery[i][6],imageGallery[i][7],imageGallery[i][8],imageGallery[i][9],imageGallery[i][10],imageGallery[i][11]));                                                          
                      //,
                
                  global = global+1;
                 //end if   
                }
                              
            
        }
        		
         if(imageGallery2.length >0)
         {
         
        search2(0);
        }
        else
        {
           stroutput +="<h3>"+Dateyr+"</h3>";
           document.getElementById("prevNext").innerHTML='' 
          
           stroutput +='<p> No news Available</p>';
           //stroutput +='</div>';      
        
        document.getElementById("newsContainer").innerHTML=stroutput
        }
     }
         
    
  
}



function Right(str, n)
{
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function search2(selID)
{
 
  var pageID=selID;
  var temp = (pageID*pageLength)+pageLength; 
   
 
  if(temp>imageGallery2.length)
   {
     temp=imageGallery2.length;
   }
 
    document.getElementById("newsContainer").innerHTML="";
    
	j=selID
	count=0;
	count=Math.ceil(imageGallery2.length/pageLength);
 
	stroutput='';
	strPreNext='';	
 stroutput +="<h3>"+Dateyr+ "</h3>"; 

  for(i=(pageID*pageLength);i<temp;i++)
	{
	
	
	var typecheck= imageGallery2[i][11];
	typecheck = fRemoveSquarebrace(typecheck); 
	 
	if(i<((pageID*pageLength)+2))
	{
	
        stroutput +="<div>";
        stroutput +="<p>";
        
        
        if(imageGallery2[i][8]!="")
        {
            stroutput +="<img height='68' alt='' src='"+imageGallery2[i][8]+"' width='68'>";
        }
        else
        {
            stroutput +="<img height='68' alt='' src='/files/img_blankBlue.gif' width='68'>";
        }
        
         var newarray=new String(imageGallery2[0]);
         
       
         newarray.split(",");
         
        stroutput +="<span class='newshdr_1'><b>"+imageGallery2[i][5]+"/"+imageGallery2[i][4]+"/"+imageGallery2[i][6]+"" +":";         
        stroutput +=""+"&nbsp;"+imageGallery2[i][2]+"</b></span>";
        stroutput +="<br/>";      
        stroutput +=""+imageGallery2[i][7]+"....."+ "";
        stroutput +="<br/>";             
        stroutput +="&nbsp;";      
        if(imageGallery2[i][10]!="")
        {      
                
          stroutput +="<a target='_blank' href='"+imageGallery2[i][10]+"'>Find out more</a>";
        }     
        else
        {
            if(imageGallery2[i][0]!="")
            { 
                stroutput +="<a href='/output/page"+imageGallery2[i][0]+".asp'>Find out more</a>";
            }
        }
        
        stroutput +="</p>";       
        
        stroutput +="<div class='clear'/>"
        stroutput +="</div>";         
        
       
       
    }      
    else
    {
        //stroutput +="<div class='clear'>"
        //stroutput +="<div>"; naeNewsA2  <div id="newsContainer">Karnantest</div>
        if(i==((pageID*pageLength)+2))
        {
            stroutput +="<div>";
            stroutput +="<ul>";
        }
        //stroutput +="<ul>";
        stroutput +="<li>";
        stroutput +="<span class='newshdr_1'><b>"+imageGallery2[i][5]+"/"+imageGallery2[i][4]+"/"+imageGallery2[i][6]+"" +":";         
        stroutput +=""+"&nbsp;"+imageGallery2[i][2]+"</b></span>";
        stroutput +="<br class='clear'/>";      
        stroutput +=""+imageGallery2[i][7]+"....."+ "";
        stroutput +="<br class='clear'/>";             
        stroutput +="&nbsp;";      
        if(imageGallery2[i][10]!="")
        {      
                
          stroutput +="<a target='_blank' href='"+imageGallery2[i][10]+"'>Find out more</a>";
        }     
        else
        {
            if(imageGallery2[i][0]!="")
            { 
                stroutput +="<a href='/output/page"+imageGallery2[i][0]+".asp'>Find out more</a>";
            }
        }
        //stroutput +="<div class='clear'>"
        stroutput +="</li>";
        if(i==(temp-1))
        {
            stroutput +="</ul>";
            stroutput +="</div>";
        }
        
       // stroutput +="</div>"; 
        //stroutput +="</div>"; 
    }
        
   }
//  stroutput +="<div class='clear'>";
//  stroutput +="</div>";
  document.getElementById("newsContainer").innerHTML=stroutput
  
 
  document.getElementById("prevNext").innerHTML="";
  
  //strPreNext +='<div class="t2EventListNo">'; 
  strPreNext="";
  
  if(pageID == 0)
   { 
    strPreNext +='<img alt="First" src="/files/images/btn-prev.gif" />';
     
   }
   else 
   {
   	 prevpageid=pageID-1;
	 strPreNext +='<input type="image" onclick="search2('+0+')" alt="First" src="/files/images/btn-prev.gif" />';	 
	 
   }  
  
            startlimit=0
            endlimit=count
                            
            if(count <= 5)
            {
                startlimit=0;
                endlimit=count;
            }
	        else if(pageID < (count-2))
            {	        
		        if(pageID >= 2)
		        {
		            startlimit=pageID-2;
                    endlimit=pageID+2;
                }
		        else
		        {
			        startlimit=0;
                    endlimit=5; 
                }
            }
            else
            {
	            startlimit=count-5;
                endlimit=count;
            }                
	        
           
    for(i=startlimit;i<endlimit;i++)
	{    	 
	      if(i == pageID )
	      {
	      strPreNext +="<a style='text-decoration: none;'  class='Pagination_a' >"+ ( i + 1 )  +"</a>";	     
    	  }
    	  else
    	  {
    	  strPreNext +="<a style='text-decoration: underline;'  href='#' onclick='search2("+i+")' >"+ ( i + 1 )  +"</a>";	     
    	  }
         if(i < endlimit -1 )
         {
         
           strPreNext +='<span>|</span>';
           
         } 
         
    }	
	
     if(pageID == count -1 )
     {
       strPreNext +=' <img src="/files/images/btn-next.gif" alt="Last" />';
       
     }
     else
     {  
      nextpageid=count-1;
       
      strPreNext +='<input type="image" onclick="search2('+nextpageid+')" alt="Last" src="/files/images/btn-next.gif" />';      
     }
      
     
     strPreNext +='<br class="clear"/>';
     
   
   
   document.getElementById("prevNext").innerHTML =strPreNext; 
}



 function trim11 (str) 
 {
	str = str.replace(/^\s+/, '');
	for (var i = str.length - 1; i >= 0; i--)
	 {
		if (/\S/.test(str.charAt(i))) 
		{
			str = str.substring(0, i + 1);
			break;
	    }
	 }
	return str;
}

function fRemoveSquarebrace(src)
{
    var dst = "";
    var c = "";
    var dst1 = "";
    var c1 = "";

    for (var i = 0; i < src.length; i++)
    {
        c = src.charAt(i);
        
        if (c != '{')
        {
            dst += c;
        }
       
    }
    for (var i = 0; i < dst.length; i++)
    {
        c1 = dst.charAt(i);
        
        if (c1 != '}')
        {
            dst1 += c1;
        }
       
    }    
    
   
    return dst1;
}
