// Global jquery script
$(document).ready(function() {
						   
	// Site Background
	$(window).resize()
	
	$(window).resize(function(){
		//$('#colOne').animate( {height:$(window).height()}, 500);
		doFlashPos('#siteBackground');
		doFlashPos('#siteArea');
	});
	doFlashPos('#siteBackground');
	doFlashPos('#siteArea');
	
	$('.defuscate').defuscate();
	
	// Product Image
	if($('.productImage').length) $('.productImage').setProductImage();
	
	/*{
		var image_lrg = $('.productImage').attr('src');
		var image_sml = image_lrg.replace(/_sml.jpg/gi, "_lrg.jpg")
		$('.productImage').css('float', 'none');
		$('.productImage').css('margin', '0');
		$('.productImage').wrap("<div class=\"productImgCont\"><a class=\"productImgLink\" rel=\"prettyPhoto\" href=\""+image_sml+"\"></a></div>");
		$('.productImage').parent('a').after("<a class=\"productImgLink\" rel=\"prettyPhoto\" href=\""+image_sml+"\">Zoom</a>");
	}*/
	
	// Pretty Photo
	$("a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed: 'normal', /* fast/slow/normal */
		padding: 40, /* padding for each side of the picture */
		opacity: 0.35, /* Value betwee 0 and 1 */
		showTitle: true, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'dark_square', /* light_rounded / dark_rounded / light_square / dark_square */
		callback: function(){}
	});
	
	//$('#pageContent').height($(document).height()+'px');
	
});

(function ($) {
$.fn.setProductImage = function() {
	return this.each(function(i){
		var image_lrg = $(this).attr('src');
		var image_sml = image_lrg.replace(/_sml.jpg/gi, "_lrg.jpg");
		$(this).css('float', 'none');
		$(this).css('margin', '0');
		$(this).wrap("<div class=\"productImgCont\"><a class=\"productImgLink\" rel=\"prettyPhoto\" href=\""+image_sml+"\"></a></div>");
		$(this).parent('a').after("<a class=\"productImgLink\" rel=\"prettyPhoto\" href=\""+image_sml+"\">Zoom</a>");
	});
};
})(jQuery);

/* Email Defuscator */
(function($){
	jQuery.fn.defuscate = function( settings ) {
		settings = jQuery.extend({
			link: true,
			find: /\b([A-Z0-9._%-]+)\([^)]+\)((?:[A-Z0-9-]+\.)+[A-Z]{2,6})\b/gi,
			replace: '$1@$2'
		}, settings);
		return this.each(function() {
			if ( $(this).is('a[@href]') ) {
				$(this).attr('href', $(this).attr('href').replace(settings.find, settings.replace));
				var is_link = true;
			}
			$(this).html($(this).html().replace(settings.find, (settings.link && !is_link ? '<a href="mailto:' + settings.replace + '">' + settings.replace + '</a>' : settings.replace)));
		});
	};
})(jQuery);

function doFlashPos(targetDiv) {
	var screenWidth = $(window).width();
	var screenHeight = $(window).height();
	$(targetDiv).css('height',screenHeight+'px');
}

(function ($) {
$.fn.vAlign = function() {
	return this.each(function(i){
	var ah = $(this).height();
	var ph = $(this).parent().height();
	var mh = (ph - ah) / 2;
	$(this).css('margin-top', mh);
	});
};
})(jQuery);


