var viewportwidth;
var viewportheight;

//BROWSER HEIGHT (available height allowing for browser toolbars etc.)

function getBrowserSizes(){
	 
	 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	 
	 if (typeof window.innerWidth != 'undefined')
	 {
		  viewportwidth = window.innerWidth,
		  viewportheight = window.innerHeight
	 }
	 
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	
	 else if (typeof document.documentElement != 'undefined'
		 && typeof document.documentElement.clientWidth !=
		 'undefined' && document.documentElement.clientWidth != 0)
	 {
		   viewportwidth = document.documentElement.clientWidth,
		   viewportheight = document.documentElement.clientHeight
	 }
	 
	 // older versions of IE
	 
	 else
	 {
		   viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		   viewportheight = document.getElementsByTagName('body')[0].clientHeight
	 }
	
	//-->
	
}

// Image thumbnail select function
function select_thumb_image(title, large_path, xlarge_path) {
	
	element = document.getElementById('productImageLarge');
	if (!element) { return; }
	
	img_str = '<img src="'+large_path+'" alt="'+title+'" />';
	if (xlarge_path) { img_str += '<a href="'+xlarge_path+'" class="thickbox" title="'+title+'">+ Enlarge Image</a>'; }
	
	element.innerHTML = img_str;
	
	// refresh thickbox as the dom has changed
	if (xlarge_path) { tb_init('a.thickbox'); }
}



/*
	CAROUSEL CALLBACK
*/

function carousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });
 
    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
 
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};



/*
*
* externalLinks
*
*/

function externalLinks(){

	var domain = window.location.toString().split("//")[1].split("/")[0];
	domain	=	domain=='localhost'?'smallanimalshow.co.uk':domain;	
	jQuery("a[href^='http:']").not("[href*='"+domain+"']").attr('target','_blank');
}

/*
*
*	function setCufonStyles
*
*
*/

function setCufonStyles(){
	
	Cufon.replace('h1');
	Cufon.replace('#sectionImage h1');
	Cufon.replace('li h3');
	Cufon.replace('ul.section_cta li p');
	
	
	//Additional adjustments needed for cufon
	//$('h1').css({lineHeight: '1.8em'});	
}


/*	--------------------------------------------------------------------------  */
/*	--------------	JQUERY DOCUMENT READY RUNTIME PROCESSES  -----------------  */
/*	--------------------------------------------------------------------------  */


$(document).ready(function(){

	//CUFON
	setCufonStyles();
						
	//PARSE EXTERNAL LINKS
	externalLinks();
	
	//ANIMAL TABS
	if($("#animalTabs").length>0)
	{
		$('#animalTabs').tabs({ fxFade: true, fxSpeed: 'fast'});	
	}
	
});
