
function setupPrettyPhoto(){$(".tmbItemBox a[rel^='prettyPhoto']").prettyPhoto({theme:'light_rounded',allowresize: true, counter_separator_label: '-', showTitle: true});};

	
/***************************************
    	 	BLOCKQUOTE SCRIPT
****************************************/
(function($){
 $.fn.jquote = function(options) 
 {
	 var defaults = {
		 bquoteclass: "jquote",
		 srcclass: "source"
		 };
   
  var options = $.extend(defaults, options);
    
  return this.each(function() {
        //the magic. Remember access options by using options.optionname!
        //jQuote - originally written by Jack Franklin December 2008.
        //Rewritten to correct small bugs and better, cleaner code Feb 2009. 2 months late!
        //RELEASED TO THE WORLD = 14th Feb 2009.
        //Visit jackfranklin.co.uk/jquote for help.
        //Follow @jQuote on Twitter - twitter.com/jquote.
        var opentag = "<blockquote class=\"" + options.bquoteclass + "\">";
        var thequote = $("span.quote").text();
        var end = "</blockquote>";
        var source1 = "<span class=\"" + options.srcclass + "\">";
        var source2 = "</span>";
        var person = $("span.quote").attr("title");
        $("span.quote").after(opentag+thequote+source1+person+source2+end);           
  });
 };
})(jQuery);

$("p").jquote(
{
	bquoteclass: "jquote", //The class of the blockquote element.
	srcclass: "source" //The class of the span element containing the source.
});
// end of function



/***************************************
		   ALL IMAGE LOADER
****************************************/
function setupAllImgLoad()
{
     $(".imgLoad").each(function () {
        var loader = $(this);
		var imageFilePath = loader.attr('title');
        var img = new Image();
        $(img).css("opacity", "0.0").load(
                function() 
                {
                    loader.append(this);
                    $(this).css("margin", "0px").css("opacity", "0.0").animate({opacity: 1.0}, 800,
                        function()
                        {
                            loader.removeAttr('title').css("background-image", "none");                 
                        });
                }
            ).attr('src', imageFilePath);  
    });
	}
	
	

/***************************************
		   GALLERY IMAGE LOADER
****************************************/
function setupGalleryLoad()
{
     $(".tmbItem").each(function () {
        var loader = $(this);
		var imageFilePath = loader.attr('title');
        var img = new Image();
        $(img).css("opacity", "0.0").load(
                function() 
                {
                    loader.append(this);
                    $(this).css("margin", "0px").css("opacity", "0.0").animate({opacity: 1.0}, 800,
                        function()
                        {
                            loader.removeAttr('title').css("background-image", "none");                 
                        });
                }
            ).attr('src', imageFilePath);  
    });
	}



/***************************************
    ADDITIONAL CUFON FONT REPLACEMENT
****************************************/
function setupCufonFont()
{
	Cufon.replace('h1', { fontFamily: 'Advent'});
	Cufon.replace('h2', { fontFamily: 'Rockwell',   textShadow: '#333 1px 1px'});
	Cufon.replace('h3', { fontFamily: 'Advent'});		
	Cufon.replace('h4', { fontFamily: 'Advent'});	
	Cufon.replace('h5', { fontFamily: 'Advent'});	
	Cufon.replace('h6', { fontFamily: 'Advent'});
	Cufon.replace('.static-desc h1', { fontFamily: 'Myriad Pro', color:'-linear-gradient(#EEEEEE, #CCCCCC)', textShadow: '#000 2px 2px'
});
	//Cufon.replace('.the-head h3', { fontFamily: 'Rockwell', color:'#333333'});
}  
   

/***************************************
  			HORIZONTAL SLIDE
****************************************/
function visibleScript(){
	jQuery(".jview").css({visibility:"visible"});
	
	if(jQuery(".next").length > 1){
		jQuery(".next").css({visibility:"visible"});
		}
	}
	
function hrz_slide(){
	windowIE = 1;
	
	var animation_stopped = true;
	var viewport = ($(window).width() * 2);	
	$(".hrz-container:not(.hrz1)").each(function(i){
	var currentPos_container = $(this).position();
	var newpos_container = (currentPos_container.left + viewport) * windowIE;
	$(this).css({left:newpos_container}).removeClass("notactive");
	});
	
	$(".btn .next").each(function(i){
	$(this).bind("click",function(){
	if(animation_stopped){
	animation_stopped = false;
	viewport = ($(window).width() * 2);	
	var number = i +1;
	var next = i + 2;
	if($(".hrz-container").length < next){
	next = 1;
	}
						
	$('.hrz'+ number).animate({left:-viewport},600,"easeInBack",function(){
	var css_set = viewport * windowIE;																	 
	$('.hrz'+ number).css({left:css_set});															
	$('.hrz'+ next).animate({left:0},600,"easeOutCirc");
	animation_stopped = true;
	});
	
	$('.hrz'+ number+ '.partSlide').each(function(i){
	var speed = 450;
	var this_css_left = $(this).css("left");
	var pos_left = parseInt(this_css_left.replace(/px/g, ""));
	var adjust_left = pos_left + ((i+1) * 35);
	$(this).animate({left:adjust_left},speed,"linear").animate({left:pos_left},300);;
	});
	}
	return false;
	});
	});
	}
	

/***************************************
    		AJAX CONTACT FORM
****************************************/
function ajaxContact(){
	var options={target:'#alert'};
	$('#cm_form').ajaxForm(options);
	
$.fn.clearForm=function(){
	return this.each(function(){
		var type=this.type,tag=this.tagName.toLowerCase();
		if(tag=='form')return $(':input',this).clearForm();
		if (type=='text'||type=='password'||tag=='textarea')this.value='';
		else if (type=='checkbox'||type=='radio')this.checked=false;else if (tag=='select')this.selectedIndex=-1;
		});
	};
}
/***************************************
    			MAIN LOAD
****************************************/
$(document).ready(function()
    {               
		setupPrettyPhoto();
		setupCufonFont();
		setupGalleryLoad();
		setupAllImgLoad();
		visibleScript();
		hrz_slide();
		ajaxContact();
    }
);
