  $('document').ready(function(){
	  
// Summary Daily Reports 

	  $("#show_reports").click(function(event){
		  	fdata=$("#daily_form").serialize();
			
		  	$.post("reports/ajax_daily",{data:fdata},function(data){
				$("#summary_details").html(data);				
			});
			
			$("#show_reports").ajaxStart(function(){
				$("#summary_details").html('<br /><br /><img src="images/ajax-loader.gif" alt="Loading .."/><br /><br />');
			});
			
			event.preventDefault(); 						
	  });
	  
// Daily Details
	  $("#more_daily_details").click(function(){
			status = $(this).attr("value");
			if(status == 0 ){
				$("#daily_details").css({'display':'block'});
				$(this).attr("value",1);
				$(this).html("Less ..");
			}else{
				$("#daily_details").css({'display':'none'});
				$(this).attr("value",0);
				$(this).html("More ..");
			} 
	  });
	  
		 
// Date Picker 
	  $(function() {
			$("#datepicker").datepicker({
			  	dateFormat: 'dd-mm-yy',
			  	showOn: 'button', 
			  	buttonImage: "images/calendar.png", 
			  	buttonImageOnly: true,
			  	buttonText: 'Choose Date',
				changeMonth: true,
				changeYear: true,
				onSelect: function(dateText, inst) { $("#show_reports").click(); }

		  });
		  
		});

	  
// add monitor - ports
	$("#port").change(function(){
		if($(this).attr("value") == 0){
			$("#other_port").show();
		}else{  

			$("#other_port").hide();
			$("#other_port_field").attr("value",0);
		}
    });

// home plans
    $("#plans").accordion({
		autoHeight: false,
		icons: {
    			/*header: "ui-icon-circle-arrow-e",
   				headerSelected: "ui-icon-circle-arrow-s"
   				*/
   				header: "uptime-logo-icon-e",
   				headerSelected: "uptime-logo-icon-s"
			}


    });
    
// monitors control   
	$("#delete_all_monitors").click(function(event){
		counter=0;
		$("input[name=select[]]").each(function(){
			counter=(this.checked)?counter+1:counter;
		});	
		
		if(counter == 0 )
			alert("You have to Select One Monitor at least");
		else
			$("#monitors_form").submit();
		event.preventDefault();
	});
	
	$("#select_all").change(function(){
		val=$(this).attr("value");
		$("input[name=select[]]").each(function(){
					(this.checked == val)?this.click():null;
				});	
		$(this).attr("value",((val == 1)?0:1));
		
	});
    
// edit profile
    $("#change_password_status").click(function(event){
		event.preventDefault();
		$(this).attr("status",(($(this).attr("status") == 0)?1:0));
		chst=$(this).attr("status");
		
		if(chst == 1){
			$("#change_password").show();}
		else{
			$("#change_password").hide();}
    });
    
// Quick Check
    $("#quick_check").click(function(event){
			event.preventDefault();
			form_data=$("#quick_check_form").serialize();
			$.post("quick/check",{data:form_data}, function(data){
				$("#result").html(data);
			 },"html");		
	});	
	
// Contact Us
    $("#contact_send").click(function(event){
			event.preventDefault();
			form_data=$("#contact_form").serialize();
			$.post("contact/send",{data:form_data}, function(data){
				$("#result").html(data);
			 },"html");		
	});		

    
	$("#loading").ajaxStart(function(){
		$(this).show();
	});
	
	$("#loading").ajaxSuccess(function(){
		$(this).hide();
		
	});
	
    
    
  });
