
// simulate hover state in ie6
$(document).ready(function(){
					
prepareHighlightSection(); // commented by anl - causing problems on big search results		
ieHoverSimulation();       // commented by anl - causing problems on big search results	
	$('.date-picker').datePicker();
	$('.date-picker-past-selectable').datePicker({startDate:'01/01/1996'}); //allow past dates selectable

	prepareExpandList();
	prepareInputToButton();
	exportToExcel();
	ShowPDF();
	ShowPDF2();
	ShowPDF3();
	ShowPDF4();
	ShowPDF5();
	ShowPDF6();
	ShowPDF7();
	ShowPDF8();
	ShowPDF9();
	ShowPDF10();
	ShowPDF11();
	ShowPDF12();
	ShowPDF13();
	ShowPDF14();
	ShowPDF15();
	
	
	
	exportToExcel2();
	exportToExcel3();
	exportToExcel4();
	exportToExcel5();
	exportToExcel6();
	exportToExcel7();
	exportToExcel8();
	exportToExcel9();
	exportToExcel10();
	exportToExcel11();
	exportToExcel12();
	exportToExcel13();
	exportToExcel14();
	exportToExcel15();
	
 });

function exportToExcel() {
	
	$(".export-excel").click(function(){
		$(".excel-button").trigger("click");					 
									 
    });
}


//anl adapted from exportToExcel 17/2/2008
function ShowPDF() {
	
	$(".show-pdf").click(function(){
		$(".pdf-button").trigger("click");					 
									 
    });
}





 //Reports screen - don't know how to pass param , no time to figure out. al 23/1/2009
//anl adapted from exportToExcel 17/2/2008



function ShowPDF2() {
	
	$(".show-pdf2").click(function(){
		$(".pdf-button2").trigger("click");					 
									 
    });
}

function exportToExcel2() {
	
	$(".export-excel2").click(function(){
		$(".excel-button2").trigger("click");					 
									 
    });
}

function ShowPDF3() {
	
	$(".show-pdf3").click(function(){
		$(".pdf-button3").trigger("click");					 
									 
    });
}

function exportToExcel3() {
	
	$(".export-excel3").click(function(){
		$(".excel-button3").trigger("click");					 
									 
    });
}
function ShowPDF4() {
	
	$(".show-pdf4").click(function(){
		$(".pdf-button4").trigger("click");					 
									 
    });
}

function exportToExcel4() {
	
	$(".export-excel4").click(function(){
		$(".excel-button4").trigger("click");					 
									 
    });
}
function ShowPDF5() {
	
	$(".show-pdf5").click(function(){
		$(".pdf-button5").trigger("click");					 
									 
    });
}

function exportToExcel5() {
	
	$(".export-excel5").click(function(){
		$(".excel-button5").trigger("click");					 
									 
    });
}

function ShowPDF6() {

    $(".show-pdf6").click(function() {
        $(".pdf-button6").trigger("click");

    });
}


function exportToExcel6() {

    $(".export-excel6").click(function() {
        $(".excel-button6").trigger("click");

    });
}

function ShowPDF7() {

    $(".show-pdf7").click(function() {
        $(".pdf-button7").trigger("click");

    });
}


function exportToExcel7() {

    $(".export-excel7").click(function() {
        $(".excel-button7").trigger("click");

    });
}


function ShowPDF8() {

    $(".show-pdf8").click(function() {
        $(".pdf-button8").trigger("click");

    });
}


function exportToExcel8() {

    $(".export-excel8").click(function() {
        $(".excel-button8").trigger("click");

    });
}

function ShowPDF9() {

    $(".show-pdf9").click(function() {
        $(".pdf-button9").trigger("click");

    });
}


function exportToExcel9() {

    $(".export-excel9").click(function() {
        $(".excel-button9").trigger("click");

    });
}

function ShowPDF10() {

    $(".show-pdf10").click(function() {
        $(".pdf-button10").trigger("click");

    });
}


function exportToExcel10() {

    $(".export-excel10").click(function() {
        $(".excel-button10").trigger("click");

    });
}


function ShowPDF11() {

    $(".show-pdf11").click(function() {
        $(".pdf-button11").trigger("click");

    });
}


function exportToExcel11() {

    $(".export-excel11").click(function() {
        $(".excel-button11").trigger("click");

    });
}

function ShowPDF12() {

    $(".show-pdf12").click(function() {
        $(".pdf-button12").trigger("click");

    });
}


function exportToExcel12() {

    $(".export-excel12").click(function() {
        $(".excel-button12").trigger("click");

    });
}


function ShowPDF13() {

    $(".show-pdf13").click(function() {
        $(".pdf-button13").trigger("click");

    });
}


function exportToExcel13() {

    $(".export-excel13").click(function() {
        $(".excel-button13").trigger("click");

    });
}


function ShowPDF14() {

    $(".show-pdf14").click(function() {
        $(".pdf-button14").trigger("click");

    });
}


function exportToExcel14() {

    $(".export-excel14").click(function() {
        $(".excel-button14").trigger("click");

    });
}


function ShowPDF15() {

    $(".show-pdf15").click(function() {
        $(".pdf-button15").trigger("click");

    });
}


function exportToExcel15() {

    $(".export-excel15").click(function() {
        $(".excel-button15").trigger("click");

    });
}





 //END OF REPORTS







function ieHoverSimulation() {
 // only run this script if client browser is ie6
 if ($.browser.msie && $.browser.version == 6.0) {
	$("li").mouseover(function(){$(this).addClass("hover"); });
	$("li").mouseout(function(){$(this).removeClass("hover"); })
	$("h4").mouseover(function(){$(this).addClass("hover"); });
	$("h4").mouseout(function(){$(this).removeClass("hover"); })
  }

}

function prepareHighlightSection() {
	 // only run this script if in new booking section
	$("#collectionDeliverySection").find(".section").mousedown(function() {
		$("#collectionDeliverySection").find(".section").removeClass("focused");
		$(this).addClass("focused")	;
	});	
	
}

function prepareInputToButton() {
	$("input[type=button]").each(function(i){
	//23/12/209 removed the @ - seems to need this to work with jquery 1.3.2 - was previously 1.1.3
	//$("input[@type=button]").each(function(i){
		// store all attributes
		label = $(this).attr("value");
		click_event = $(this).attr("onclick") +'';
		classes = $(this).attr("class");
		
		
		// remove bad script processing from ie onclick event 
		if($("html").attr("class").match("ie6")) { 
				
				var replace1 = click_event.replace('function', '');
				var replace2 = replace1.replace('anonymous()', '');
				var replace3 = replace2.replace('{', '');
				var replace4 = replace3.replace('}', '');
				click_event = replace4;
		}
		
		var new_button = '<button type="button" class="'+classes+'" onclick="'+click_event+'"><span></span> '+label+'</button>';
		// insert nice new button
		$(this).after(new_button);
		// remove awkward input button
		$(this).remove();
});
}


function prepareExpandList(){
$("ul.expand-list/li/h4").toggle(function(){
  	
  	$(this).siblings("div").hide("fast");
   $(this).siblings(".options").hide("fast");

  	$(this).parent().addClass("collapsed");
	
   }, function(){
   
   $(this).siblings("div").show("fast");
   $(this).siblings(".options").show("fast");
   $(this).parent().removeClass("collapsed");
  
});

$(".view-all").toggle(function() {
	$(this).parent().siblings("div.filter").addClass("all");
	$(this).parent().siblings("div.filter").animate({height: 92}, "fast");
	
	$(this).siblings('.info').hide();
	$(this).empty();
	$(this).append("Show first 2");
	
		}, function(){
		$(this).parent().siblings("div.filter").animate({height: 38}, "fast");
	$(this).parent().siblings("div.filter").removeClass("all");
$(this).siblings('.info').show();
	$(this).empty();
	$(this).append("View more");});

}


