$j = jQuery.noConflict();
// Custom Functions

// @desc  EXTERNAL LINKS - traps all links with rel="external" or class="external" or those that link to external sources
	function linksAndEmails()
	{
		// turn rel="external" attributes into new window popups
		$j('a[rel^="external"]').click( function() {
			window.open( $j(this).attr('href') );
			return false;
		});
		// turn "external" classes into new window popups
		$j('a.external').click( function() {
			window.open( $j(this).attr('href') );
			return false;
		});
		// find all external links on a site and make new window popups
		$j("a[href^='http://']").not("a[href^='hayandstrawcompany.co.nz']").not("a[href^='http://hayandstrawcompany.co.nz.lbus8.onlyfordemo.com']").not('a[rel^="external"]').click(function(){
			window.open(this.href,'external');
			return false;
		});
		
		// Email Converter
		$j('a.email').each(function(){
			e = this.title.replace('/','@');
			this.href=" ";
			this.href = 'mailto:' + e; $j(this).text(e);
		});
	};

// @desc DISABLE ELEMENT Add Class "noshow" to given element if pagename exists.
	function disableContainer (element,pageName) {
		 if ( $j(element).hasClass(pageName) ) {
			$j(element).addClass("noshow");
		 }
	
	}

// @desc CHECK EMAIL - Check if a valid email address is entered.
	function checkMail(email){
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$j/;
		if (filter.test(email)) {
			return true;
		}
		return false;
	}

// @desc GOOGLE MAP - Non Iframe Map Call up
// @Use HTML - <div id="GoogleMap"></div> [width:500px; height:400px;]
	function mapasGoogle() {
	  if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("mapaGoogle"));	
		map.setCenter(new GLatLng(42.8475, -2.6820), 15); //Define Location       	
		map.setMapType(G_HYBRID_TYPE); // Define map Type
		map.addControl(new GSmallMapControl()); // Active Map Controls
		map.addControl(new GMapTypeControl()); // Activate Type Controls
		map.openInfoWindowHtml(map.getCenter(),
		('<img src="images/logo.png" width="20" height="20" alt="" /><em>Title</em> <br /> Lorem ipsum dolor sit amet'));
	  }
	}

// @desc IMAGE PRELOADER
	function preloadImages() {
	   if (document.images) {
		  for (var i = 0; i < preloadImages.arguments.length; i++) {
			 (new Image()).src = preloadImages.arguments[i];
		  }
	   }
	}


