
function xtractFile(data){
var m = data.match(/(.*)\/([^\/\\]+)(\.\w+)$/);
if(m == null) { m = "null"; }
return {path: m[1], file: m[2], extension: m[3]}
}

var jq = jQuery.noConflict();

jq.fn.vAlign = function() {
	return this.each(function(i){
		var ah = jq(this).height();
		var ph = jq(this).parent().height();
		var mh = (ph - ah) / 2;
		jq(this).css('top', mh);
	});
};


/* google map function */
function initGmap() {    
	var latlng = new google.maps.LatLng(53.357996, -6.235262);    
	var myOptions = {      zoom: 15,      
						   center: latlng,      
						   mapTypeId: google.maps.MapTypeId.ROADMAP 
					};    
	var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	
	var contentString = 'Collen.com,<br /> River House,<br />  East Wall Road,<br /> Dublin 3,<br /> Ireland.';
	//create info window
	var infowindow = new google.maps.InfoWindow({    
		content: contentString,
        maxWidth: 1
	});
	
	var marker = new google.maps.Marker({      
		position: latlng,      
		map: map     
		//title:"Hello World!"  //this shows up as a tooltip
	});
	
	google.maps.event.addListener(marker, 'click', function() {  
		infowindow.open(map,marker);
	});
}
/**/

jq(document).ready(function(){

	/*	
		Dynamically Adjust the width of each <LI> within the Primary Nav - 
		WORKS BASED ON SITEFINITY's MENU MARKUP
	*/
	var totWidth = 0;
	var rem = 0;
	var margin = 0;
	jq(".nav li span").not(".rmSlide li span").each(function(){ totWidth += jq(this).width(); });
	rem = jq(".nav").width() - totWidth;
	margin = Math.floor(rem/jq(".nav li").not(".rmSlide li").length);
	//alert("totalwidth: " + totWidth + ", remainder: " + rem + ", margin: " + margin);

	jq(".nav li span").each(function(){
		jq(this).parent().css({ "width" : (jq(this).width() + margin)+"px"});
	});
	jq(".nav li").css({ "visibility" : "visible" });
	
	jq(".nav .RadMenu li").hover(
		function(){ jq(this).children(".rmSlide").show(); },
		function(){ jq(this).children(".rmSlide").hide(); }
	);
	

	
	//"Our Locations" Map
	jq("area").hover(
		function(e) { 
			jq(".locMapHover").css({ "top" : (e.pageY + 5), "left" : (e.pageX + 5) });
			jq(".locMapHover").text(jq(this).attr("alt")).show(); 
		} ,
		function() { jq(".locMapHover").hide(); }
	);
	
	if(document.location.href.indexOf("cmspagemode") < 0)
	{
		jq(".subnav ul").length == 0 ? jq(".subnav").hide() : null;

		jq("a").each(function(){
			if(jq(this).attr("href"))
			{
				jq(this).attr("href").indexOf("http://") > -1 ? jq(this).attr("target", "_blank") : null;
			}	
		});
	}	
	
		
	//add class to first td in every row for product details table
	var i = 0;
	jq(".proj_facts table td").each( function(i){
		//alert('test');									  	
		i % 2 == 0 ? jq(this).addClass("table_header") : jq(this).addClass("table_cell");
		i++;
	});
	
	//call google map function 
	if(jq("#map_canvas").length > 0) {
		initGmap();
	}

});
