/* -------------------------------------------------------------------------------------------- */
//xhtml work around to open all links with re=new-window as new tab or window
$(function(){	
	//check all hrefs, if external, open in blank window
	$('a').filter(function(){
		pattern = /http|ftp(s)?/i;			//basic regex patterm case insensitive
		result = pattern.test($(this).attr('href'));	//rung using test method
				
		if(result == true){
			$(this).attr({
				target: "_blank", 
				title: "Opens in a new window"
			});
		}
	});
});
/* -------------------------------------------------------------------------------------------- */



$(document).ready(function(){
	
	/* -------------------------------------------------------------------------------------------- */
	/* JQUERY - FLASH */
	if ($('#animation-1').length > 0 ){ // check if element is on page
		 jQuery('#animation-1').flash(
			{
				src: '/css/skins/default/flash/sc_anim_loading.swf', //sc_anim_v1.swf
				width: 500,
				height: 500,
				wmode:'transparent'
			},
			{ 
				version: 8,
				update: false //don't automatically show flash installation message if flash not detected, degrades gracefully.
			}
		)
	}//check
	/* JQUERY - FLASH */	
	/* -------------------------------------------------------------------------------------------- */
	
	
	
	/* -------------------------------------------------------------------------------------------- */
	/* JQUERY - FACEBOX */
	$('a[rel*=facebox]').facebox({
		loading_image : 'loading.gif'
    })	
	
	$('#close-fb a').livequery('click', function(event) { 
        jQuery(document).trigger('close.facebox'); 
        return false; 
    }); 
	/* JQUERY - FACEBOX */
	/* -------------------------------------------------------------------------------------------- */
	
	
 
	/* -------------------------------------------------------------------------------------------- */
	/* CONTACT US - CONTACT FORM */
	if ($('#form-contact').length > 0 ){ // check if element is on page	
		//contact form
		$("#form-contact").livequery(function(){
			$(this).validate({
				rules: {
					txt_title: "required",
					txt_firstname: "required",
					txt_surname: "required",
					txa_address: "required",
					txt_postcode: "required",
					txt_tel: "required",
					txt_mobile: "required",
					txt_email: {
						required: true,
						email: true
					},
					txt_hearaboutscm: "required",
					txa_message: "required"
				},
				messages: {
					txt_title: "Please enter your title.",
					txt_firstname: "Please enter your firstname.",
					txt_surname: "Please enter your surname.",
					txa_address: "Please enter your address.",
					txt_postcode: "Please enter your postcode.",
					txt_tel: "Please enter your telephone number.",
					txt_mobile: "Please enter your mobile.",
					txt_email: "Please enter a valid email address.",
					txt_hearaboutscm: "Please enter where you heard about us.",
					txa_message: "Please enter your message."
				}
			});
		});
	 }//check
	/* CONTACT US - CONTACT FORM */
	/* -------------------------------------------------------------------------------------------- */
	
	
	/* -------------------------------------------------------------------------------------------- */
	/* EMBED MEDIA */
	if ($('a.media').length > 0 ){ // check if element is on page	
		$('a.media').media();
	}//check
	/* EMBED MEDIA */
	/* -------------------------------------------------------------------------------------------- */
	
	
	
	/* -------------------------------------------------------------------------------------------- */
	/* SLIDE BOX - LINKS DIV */
	if ($('#main-outer-wrapper #main #main-panel #main-panel-right .box-slide .box-slide-content').length > 0 ){ // check if element is on page	
		$('#main-outer-wrapper #main #main-panel #main-panel-right .box-slide .box-slide-content').hide();
		
		$(".box-slide .box-slide-link").click(function () {
		  $(".box-slide .box-slide-content").slideToggle("slow");
		});
	 }//check
	/* SLIDE BOX - LINKS DIV */
	/* -------------------------------------------------------------------------------------------- */

});
