/** jquery.color.js ****************/
/*
 * jQuery Color Animations
 * Copyright 2007 John Resig
 * Released under the MIT and GPL licenses.
 */
 setInterval ("runfuncation()",5000);
 
 function runfuncation()
  {
	 setTemp();
	 setAdvisory();
	 
  }
  
 function setTemp()
  {
	 // alert("Test");
	 if(jQuery("#temp_top").css("display")=='none')
	 {
		 jQuery("#rh_top").slideUp(1000);
		 jQuery("#temp_top").slideDown(1000);
		 
	 }else if(jQuery("#rh_top").css("display")=='none'){
		 jQuery("#rh_top").slideDown(1000);
		 jQuery("#temp_top").slideUp(1000);
		 
	 }
	 
  }
 
 
  function setAdvisory()
  {
	 // alert("Test");
	 var k = 0
	 for(var i=0;i<8;i++)
	 {
		 //alert("i ---> "+i+" Bool--> "+jQuery("#AdvisoryItem"+i).css("display")); 
	     if(i==7)
		 {
			if(jQuery("#AdvisoryItem"+i).css("display")=='block')
			{
			   jQuery("#AdvisoryItem0").slideDown(800);
			   jQuery("#AdvisoryItem"+i).slideUp(800);
			   /*
			   jQuery("#AdvisoryItem"+i).css("display","none");
			   jQuery("#AdvisoryItem0").css("display","inline");
			   */ 
			   break;
		    }
		 }else{
			if(jQuery("#AdvisoryItem"+i).css("display")=='block')
			{
			   k = i+1;	 
			   jQuery("#AdvisoryItem"+i).slideUp(800);
			   jQuery("#AdvisoryItem"+k).slideDown(800);
			   /*
			   jQuery("#AdvisoryItem"+i).css("display","none");
			   jQuery("#AdvisoryItem"+k).css("display","inline");
			   */
			   k=0;
			   break;
		    }
		 }
		 
	 }
  }
  function getSearch(urlPath)
    {
		 var dist,block;
		 dist=$('#DistrictList').val();
		 block=$('#blocklist').val();
		 if(dist=="")
		 {
		   alert("Please Select District.")
		   return false;
		 }else{
		   var url = urlPath+"/search/districtId/"+dist+"/blockId/"+block;
		   window.location=url;
		   return false;
		 }
    }
  function getBlockWeather(urlPath,blockId)
    {
		 var year1,year2,crop,month;
		 year1  = $('#year1').val();
		 year2  = $('#year2').val();
		 month  = $('#month').val();

		 if(year1=="")
		 {
		   alert("Please Select Year 1.")
		   return false;
		 }
		 else if(year2=="")
		 {
		   alert("Please Select Year 2.")
		   return false;
		 }
		 else if(month=="")
		 {
		   alert("Please Select Month.")
		   return false;
		 }else{
		   var url = urlPath+"/blockweather/year1/"+year1+"/year2/"+year2+"/month/"+month+"/id/"+blockId;
		   window.location=url;
		   return false;
		 }
    }

  function getAdvanceSearch(urlPath)
    {
		 var year,month;
		 year     = $('#year').val();
		 month    = $('#month').val();
         disrtict = $('#DistrictList').val();
		 block    = $('#blocklist').val();
        
		
		if(disrtict=="0")
		 {
		   alert("Please Select District.")
		   return false;
		 }else if(block=="0")
		 {
		   alert("Please Select Block.")
		   return false;
		 }else if(year=="")
		 {
		   alert("Please Select Year")
		   return false;
		 }
		 else if(month=="")
		 {
		   alert("Please Select Month.")
		   return false;
		 }else{
		   var url = urlPath+"/disrtict/"+disrtict+"/block/"+block+"/year/"+year+"/month/"+month;
		   window.location=url;
		   return false;
		 }
    }
	 
	 function marketSearch(urlPath)
    {
		 var year,month,crop,price;
		 year     = $('#year').val();
		 month    = $('#month').val();
         disrtict = $('#DistrictList').val();
		 block    = $('#blocklist').val();
		 crop    = $('#crop').val();
		 price    = $('#price').val();
        
		
		if(disrtict=="0")
		 {
		   alert("Please Select District.")
		   return false;
		 }else if(block=="0")
		 {
		   alert("Please Select Block.")
		   return false;
		 }else if(year=="")
		 {
		   alert("Please Select Year")
		   return false;
		 }
		 else if(month=="")
		 {
		   alert("Please Select Month.")
		   return false;
		 }
		 else if(crop=="")
		 {
		   alert("Please Select Crop.")
		   return false;
		 }
		 else{
		   var url = urlPath+"/disrtict/"+disrtict+"/block/"+block+"/year/"+year+"/month/"+month+"/crop/"+crop+"/price/"+price;
		   window.location=url;
		   return false;
		 }
    }



  function getBlockWeatherData(urlPath,blockId,page)
    {
		 var year,month;
		 year   = $('#year').val();
		 month  = $('#month').val();

		 if(year=="")
		 {
		   alert("Please Select Year.")
		   return false;
		 }
		 else if(month=="")
		 {
		   alert("Please Select Month.")
		   return false;
		 }else{
		   var url = urlPath+"/"+page+"/year/"+year+"/month/"+month+"/id/"+blockId;
		   window.location=url;
		   return false;
		 }
    }


 function ajaxGetdata(mode,selectId,appendoptionId,urlPath)
   {
        var request;
	    var getdata;
		var selectOption; 
		if(selectId==0)
		 {
			 return false;
		 }
		if(mode=='district')
		{
		  request      = "mode/district/id/"+selectId;
		  selectOption = "--Select District--";
			
		}else if(mode=='block')
		{
		  request      = "mode=block&id="+selectId;
		  selectOption =  "--Select Block--";
		}
		
		jQuery.ajax({
		   type: "POST",
		   url: urlPath,
		   data: request,
		   success: function(data){
		    //////// Select Mode Start //////
				 if(data==0)
				 {
				   jQuery('#'+appendoptionId).find('option').remove().end().append('<option value="">'+selectOption+'</option>').val('');
				   jQuery('#'+appendoptionId).find('option').remove().end().append('<option value="All">--Select ALL--</option>').val('');
				 }else{
				   getdata = data.split("||");
				   jQuery('#'+appendoptionId).find('option').remove().end().append('<option value="">'+selectOption+'</option>').val('');
				   jQuery('#'+appendoptionId).find('option').remove().end().append('<option value="All">--Select ALL--</option>').val('');

				   for(var i=0;i<getdata.length;i++)
					{
					  var col_array  = getdata[i].split("|");
					  jQuery('#'+appendoptionId).append(jQuery("<option></option>").attr("value",col_array[0]).text(col_array[1]));
	                  /*
					  if(col_array[1]==selectedId)
					  {
						jQuery('#'+appendoptionId).append(jQuery("<option selected='selected' ></option>").attr("value",col_array[1]).text(col_array[0]));
					  }else{
						jQuery('#'+appendoptionId).append(jQuery("<option></option>").attr("value",col_array[1]).text(col_array[0]));       
					  }                                
					  */
					}
				 }
		   ///////// Select Mode End /////// 		 
		   }
		 });
	

}
	

