function xtractFile(data){
var m = data.match(/(.*)\/([^\/\\]+)(\.\w+)$/);
if(m == null) { m = "null"; }
return {path: m[1], file: m[2], extension: m[3]}
}

jQuery(document).ready(function() {
	
	// =========================================== Apply the PNG fix for IE6
	//$(document).pngFix(); 

	// =========================================== logo fade in/out on hover
	jQuery(".header_logo, .footerFacebook").hover(
		function() { jQuery(this).fadeTo("fast", 0.6); },
		function() { jQuery(this).fadeTo("fast", 1.0); }
	);
	
	// =========================================== DROPDOWN MENU
	$("#mainnav li").hover(
		function()
		{ 
			$(this).addClass("liHover");
			$(this).find(".main").addClass("aHover");
			$(this).find(".sub_menu").show();
		},
		function()
		{ 
			$(this).removeClass("liHover");
			$(this).find(".main").removeClass("aHover"); 
			$(this).find(".sub_menu, img").hide();
		}
	);

	// =========================================== Assign alternative row colours to filter panels on homepage
	jQuery(".radioListItem:nth-child(even)").addClass("alt");
	jQuery(".checkboxList tr:nth-child(even)").addClass("alt");
	jQuery(".pricePlans tr:nth-child(even)").addClass("alt");
	jQuery(".contentTable tr:nth-child(even)").addClass("alt");
	jQuery("#innerMaincontent .shoppingCartItemsTitle").addClass("typeface-js");
	
	// =========================================== When page loads...
	// If there's a reference in the URL, then open that tab.
	
	$.fn.simpleTabs = function(){ 
		//Default Action
		$(this).find(".tab_content").hide(); //Hide all content
		$(this).find("ul.tabs li:first").addClass("active").show(); //Activate first tab
		$(this).find(".tab_content:first").show(); //Show first tab content
		
		//On Click Event
		$("ul.tabs li").click(function() {
			$(this).parent().parent().find("ul.tabs li").removeClass("active"); //Remove any "active" class
			$(this).addClass("active"); //Add "active" class to selected tab
			$(this).parent().parent().find(".tab_content").hide(); //Hide all tab content
			var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
			$(activeTab).show(); //Fade in the active content
			return false;
		});
	};//end function
	
	$("div[class^='simpleTabs']").simpleTabs(); //Run function on any div with class name of "Simple Tabs"
	
	

	// swap images on hover
	jQuery(".img-swap").hover(
		function(){this.src = this.src.replace("_off","_on");},
		function(){this.src = this.src.replace("_on","_off");
	});


	// =========================================== Tooltips for forms
	jQuery("span.hover").hover(
		function() 
		{ jQuery(this).children("span").fadeIn("fast"); },
		function() 
		{ jQuery(this).children("span").fadeOut("fast"); }
	);
	
	// =========================================== Image slider on phone details page
	jQuery("#slider").easySlider({
		auto: false, 
		continuous: true,
		numeric: true
	});
	
	// =========================================== Colorbox on phone details page
	//jQuery(".colorboxPopup").colorbox();
	$(".billpopup").colorbox({inline:true, href:"#billplans"});
	$(".cappedpopup").colorbox({inline:true, href:"#cappedplans"});
	//$(".modalPopup").colorbox({width:"20%", height: "auto", inline:true, href:"#modalpopupmessage"});
	//$("a[rel='modalPopup']").colorbox({width:"58%", height: "100%", inline:true, href:"#cappedplans"});
	
	
	// =========================================== Show / Hide radio buttons on step 2 of checkout
	
	// catch the click event for the first radio button and hide the text box
	$("#paymentchoice_0").bind('click', function(){
	$('#CreditCardPayment').hide();
	$('#DirectDebitPayment').show();
	});
	
	// catch the click event for the second radio button and hide the text box
	$("#paymentchoice_1").bind('click', function(){
	$('#DirectDebitPayment').hide();
	$('#CreditCardPayment').show();
	});
	
	// catch the click event for the second radio button and hide the text box
	$("#paymentchoice_2").bind('click', function(){
	$('#DirectDebitPayment').hide();
	$('#CreditCardPayment').hide();
	});

	
	// =========================================== Typeface for embedding fonts
	_typeface_js.initialize()
	
});


