/**
 *	stina.co.uk
 *	JavaScript
 *
 *	@library		jQuery 1.3.2
 *	@since			22/01/2010
 *	@author			philthompson.co.uk
 *	@copyright		philthompson.co.uk
 *
 */
 
jQuery.noConflict();
 
jQuery(document).ready(function(){

	prepBlogImagesPopup();
	
	initColorbox();
	
});


/**
 *	prepBlogImagesPopup
 *	Add/remove relevant class so colorbox will popup links
 */
function prepBlogImagesPopup(){

	var extensions = new Array();
	extensions[0] = '.png';
	extensions[1] = '.gif';
	extensions[2] = '.jpg';

	jQuery('body.post .entry a').each(function(){
		var linkHref = jQuery(this).attr('href');
		if(linkHref.indexOf(extensions[0]) > 0 || linkHref.indexOf(extensions[1]) > 0 || linkHref.indexOf(extensions[2]) > 0){
			jQuery(this).addClass('popup').attr('rel', 'gallery');
		}
	});
	
	jQuery('body.post .sociable a').each(function(){
		jQuery(this).removeClass('popup').attr('rel', '');
	});
	
}

/**
 *	initColorbox()
 *	Add hooks to certain links so colorbox works
 *	Warning: lightboxes fall over in mobile browsers 
 */
function initColorbox(){
	
	// don't run if it's a mobile browser
	var agent = navigator.userAgent.toLowerCase();
	if (agent.indexOf('mobile') == -1) {

		jQuery('a.popup').colorbox({
			maxWidth: 1020,
			maxHeight: 700,
			scalePhotos: false
		});
	}
}

/**
 *	showThanks()
 */
function showThanks(){
	jQuery('#ContactForm form').hide();
	jQuery('#ContactThanks').show();
}


