/* Sligo.ie JS for setting up the rotating new images

*/
var $defImageCoCo = 0;
var $defImageBoro = 0;
$(document).ready(function() {
		// Sligo Co Co News Images
		jQuery.each($(".newsCoCoimage"), function(){
			temp = this.id.split("i-");
			if($defImageCoCo == 0){
				$defImageCoCo = parseInt(temp[1]);
				$('#i-'+$defImageCoCo).fadeIn('fast');
				return false;
			}
		});
		$('.newsCoCotext').hover(function() {
			var currentId = $(this).attr('id');
			var splitId = $(this).attr('id').split('-');
				jQuery.each($(".newsCoCoimage"), function(){
					temp = this.id.split("i-");
					//console.log(parseInt(temp[1]));
					$('#i-'+parseInt(temp[1])).css('display', 'none');
				});
			//$('#i-'+$defImage).css('display', 'none');
			$('#i-'+parseInt(splitId[1])).fadeIn('fast');
		},
		function(){  
			var currentId = $(this).attr('id');
			var splitId = $(this).attr('id').split('-');
				jQuery.each($(".newsCoCoimage"), function(){
					temp = this.id.split("i-");
					//console.log(parseInt(temp[1]));
					$('#i-'+parseInt(temp[1])).css('display', 'none');
				});
			$('#i-'+$defImageCoCo).fadeIn('fast');
        });
		
		// Sligo Boro News Images
		jQuery.each($(".newsBoroimage"), function(){
			temp = this.id.split("i-");
			if($defImageBoro == 0){
				$defImageBoro = parseInt(temp[1]);
				$('#i-'+$defImageBoro).fadeIn('fast');
				return false;
			}
		});
		$('.newsBorotext').hover(function() {
			var currentId = $(this).attr('id');
			var splitId = $(this).attr('id').split('-');
			jQuery.each($(".newsBoroimage"), function(){
					temp = this.id.split("i-");
					//console.log(parseInt(temp[1]));
					$('#i-'+parseInt(temp[1])).css('display', 'none');
				});
			//$('#i-'+$defImage).css('display', 'none');
			$('#i-'+parseInt(splitId[1])).fadeIn('fast');
		},
		function(){  
			var currentId = $(this).attr('id');
			var splitId = $(this).attr('id').split('-');
				jQuery.each($(".newsBoroimage"), function(){
					temp = this.id.split("i-");
					//console.log(parseInt(temp[1]));
					$('#i-'+parseInt(temp[1])).css('display', 'none');
				});
			$('#i-'+$defImageBoro).fadeIn('fast');
        });
		
		if ($('#both').is(':checked')){
			//console.log('Both Loaded');
			$("#col1").val('county');
			//console.log($("#col1").val('county'));
			$("#col2").val('borough');
			//console.log($("#col2").val('borough'));
		}
	
		$("#both").click(function() 
		{ 
		if($('#both').is(':checked')){
			//console.log('Both Clicked');
			$("#col1").val('county');
			//console.log($("#col1").val('county'));
			$("#col2").val('borough');
			//console.log($("#col2").val('borough'));
			}
		});
		
		$("#coco").click(function() 
		{ 
		if($('#coco').is(':checked')){
			//console.log('Search County');
			$("#col1").val('county');
			//console.log($("#col1").val('county'));
		    $("#col2").val('');
			//console.log($("#col2").val(''));
			}
		});
	
		$("#boro").click(function() 
		{ 
		if($('#boro').is(':checked')){
			//console.log('Search Borough');
			$("#col1").val('borough');
			//console.log($("#col1").val('borough'));
		    $("#col2").val('');
			//console.log($("#col2").val(''));
			}
		});
		
	});
