//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(){

	/* form focus */
	if (jQuery.fn.inputfocus)
	{
		if ($('#header-outer-wrapper .col-2 .form-search .input').length > 0 ){ // check if element is on page
			//apply form field effect
			$('#header-outer-wrapper .col-2 .form-search .input').inputfocus({
				bgColourFocus:'#000000',
				bgColour:'none',
				animate:true
			});
		}
		
		/*if ($('#search-outer-wrapper #search #div-form-search .input-2').length > 0 ){ // check if element is on page
			//apply form field effect
			$('#search-outer-wrapper #search #div-form-search .input-2').inputfocus({
				bgColourFocus:'#ffffff',
				bgColour:'#ffffff',
				animate:false
			});
		}*/		
	}


	/* -------------------------------------------------------------------------------------------- */
	/* JQUERY - NYROMODAL */		
	if ($('#header-outer-wrapper .col-1 .menu-top li#register a').length > 0){ // check if element is on page
		$('#header-outer-wrapper .col-1 .menu-top li#register a').nyroModal({
			width: 680,
			height: 450
		});		
	}//check	
	
	if ($('#header-outer-wrapper .col-1 .menu-top li#login a').length > 0){ // check if element is on page
		$('#header-outer-wrapper .col-1 .menu-top li#login a').nyroModal({
			width: 460,
			height: 450
		});		
	}//check
	
	if ($('#form-customer-login .link a').length > 0){ // check if element is on page
		$('#form-customer-login .link a').nyroModal({
			width: 460,
			height: 400
		});		
	}//check	

	if ($('#main-outer-wrapper #main #main-right-panel .col-1 .video a').length > 0){ // check if element is on page
		$('#main-outer-wrapper #main #main-right-panel .col-1 .video a').nyroModal({
			width: 912,
			height: 516
		});		
	}//check	

	if ($('#main-outer-wrapper #main #menu-captiv8-panel li .video a').length > 0){ // check if element is on page
		$('#main-outer-wrapper #main #menu-captiv8-panel li .video a').nyroModal({
			width: 912,
			height: 516
		});		
	}//check	

	if ($('#main-outer-wrapper #main #boxes-2 .roundbox-one-content .cell-1 .video a').length > 0){ // check if element is on page
		$('#main-outer-wrapper #main #boxes-2 .roundbox-one-content .cell-1 .video a').nyroModal({
			width: 912,
			height: 516
		});		
	}//check	

	
	/* JQUERY - NYROMODAL */		
	/* -------------------------------------------------------------------------------------------- */			

	// Check if number of banners is greater than 1 then use cycle
	if ($('#slideshow .gallery > li').length > 1)
	{
		$('.gallery').cycle({ 
			fx:     'scrollHorz', 
			speed:  2000,
			timeout: 10000
		});
	}

	// Check if news container
	if ($('#news-item-container > div').length > 1)
	{
		$('#news-item-container').cycle({ 
			fx:     'scrollUp', 
			speed:  2000,
			timeout: 10000
		});
	}

	// Check if testimonial container
	if ($('#testimonial-item-container > div').length > 1)
	{
		$('#testimonial-item-container').cycle({ 
			fx:     'fade', 
			speed:  1000,
			timeout: 5000
		});
	}
});

