jQuery(document).ready(function(){
	jQuery("a", "#storedirectory ul").click(function(){
		// load modal box with ajax information
		return false;
	});
	
	jQuery("a", "#atoz").click(function(){
		
		jQuery("a", "#atoz").not(this).removeClass("active");
		
		jQuery(this).addClass('active');
		jQuery("#profile").html('');
		jQuery("#results").html('<img src="/wp-content/uploads/ajax-loader.gif" alt="Loading" height="16" width="16" />');	
		var id = jQuery(this).attr("id");
		jQuery.get("/wp-content/themes/merseyway/ajax/a_to_z.php", {letter: id}, function(data){
   			jQuery("#results").html(data);
 		});
		return false;
	});
	
	
	jQuery("a[rel*=external]").click(function(){
		var href = jQuery(this).attr("href");
		window.open(href);
		return false;
	});
	
	jQuery("a[rel*=external]").live('click', function(){
		var href = jQuery(this).attr("href");
		window.open(href);
		return false;
	});
	
	
	
	jQuery(".render", "#results").live('click',function(){
		jQuery(".render", "#results").removeClass('active');
		jQuery(this).addClass('active');
		var get = jQuery(this).attr("title");
		
		jQuery.get("/wp-content/themes/merseyway/ajax/loadProfile.php", {store: get}, function(data){
   			jQuery("#profile").show().html(data);
 		});
		
		return false;
	});
	
	
	jQuery("a", "#text-10").click(function(){
		
		var text = jQuery(this).html();
		jQuery.get("/wp-content/themes/merseyway/ajax/offer.php", {type: text}, function(data){
			jQuery("#offers").html(data);
		});
		
		return false;
	});
	
	if(jQuery("#post-35").length > 0){
		jQuery(".children").show();
	}
	else{
		jQuery(".children").hide();
	}
	
	
	jQuery("a", ".children").click(function(){		
		jQuery("li",".children").removeClass('current_page_item');		
		var category = jQuery('div[title=' + jQuery(this).attr("title") + ']');
		var html = '<div id="storedirectory"><div id="' + category.attr('id') + '" class="category" title="' + category.attr("title") + '">' + category.html() + '</div></div>';
		jQuery(".category").fadeTo('fast', 0.2);
		jQuery("#result").css('opacity', 1);
		jQuery("#result").html(html).slideDown('slow');
		return false;
	});
	
	
	
	jQuery("a", "#tabs").click(function(){
		jQuery("a", "#tabs").not(this).removeClass("selected");
		jQuery(this).addClass("selected").not(this).removeClass("selected");
		var job_class = '.type_' +  jQuery(this).attr("title");
		jQuery(".job").hide();
		jQuery(job_class).show();		
		return false;
	});

		
	jQuery(".wpcf7-form", "#wpcf7-f5-p1118-o1").submit(function(){
        var tc = jQuery(".tc", "#wpcf7-f5-p1118-o1");
        
        
        
        if(tc.is(":checked")){
        }
        else{
            if(confirm("Have you read and understood the terms and conditions?")){
                tc.attr("checked", "checked");
                //console.log(tc);
            }
            return false;
        }
    });
    
    
    jQuery(".savedata", "#wpcf7-f5-p1118-o1").click(function(){
    	if(jQuery(this).is(":checked")){
    		jQuery("#save_data").val('yes');
    	}
    	else{
    		jQuery("#save_data").val('no');
    	}
    });
	
	
});
