/*<![CDATA[*/
		   
/*****************************************************************************
//-> START General Functions
*****************************************************************************/
// --> Start label2value
this.label2value = function(){
	// function
	$("label.quick").each(function(){
		obj = document.getElementById($(this).attr("for"));
		if(($(obj).attr("type") == "text") || (obj.tagName.toLowerCase() == "textarea")){
			//$(obj).addClass(inactive);
			var text = $(this).text();
			$(this).css("display","none");
			$(obj).val(text);
			$(obj).focus(function(){
				//$(this).addClass(focused);
				//$(this).removeClass(inactive);
				//$(this).removeClass(active);
				if($(this).val() == text) $(this).val("");
			});
			$(obj).blur(function(){
				//$(this).removeClass(focused);
				if($(this).val() == "") {
					$(this).val(text);
					//$(this).addClass(inactive);
				} else {
					//$(this).addClass(active);
				};
			});
		};
	});
};

/*****************************************************************************
//-> END General Functions
*****************************************************************************/

/*****************************************************************************
//-> START Window Load
*****************************************************************************/

$(window).load(function () {

// --> Start Cycle
	// Add 'scrollVert' functionality for scroll boxe
	(function($) {

		$.fn.cycle.transitions.scrollVert = function($cont, $slides, opts) {
		    $cont.css('overflow','hidden');
		    opts.before.push(function(curr, next, opts, fwd) {
		        $(this).show();
		        var currH = curr.offsetHeight, nextH = next.offsetHeight;
		        opts.cssBefore = fwd ? { top: -nextH } : { top: nextH };
		        opts.animIn.top = 0;
		        opts.animOut.top = fwd ? currH : -currH;
		        $slides.not(curr).css(opts.cssBefore);
		    });
		    opts.cssFirst = { top: 0 };
		    opts.cssAfter = { display: 'none' }
		};

	})(jQuery);
	
// --> Init Image cycle
	$("#slide").cycle({ 
		fx		:   'fade', 
		speed	:  	2000, 
		timeout	: 	5000, 
		sync	:	1
	});	
// --> Init Image cycle
	$("#image-slider").cycle({ 
		fx		:   'fade', 
		speed	:  	500, 
		timeout	: 	6000, 
		sync	:	1,
		prev	:	'#prev',
        next	:	'#next'
	});	
	// Init scroll
	$('#title').cycle({ 
	    fx: 'scrollVert',
		speed: 500,
		rev: true,
		next:   '#next', 
	    prev:   '#prev',
		sync	:	1,
		timeout: 6000
	});

	/*
	$('div.image img').not('.regular').hover(function() {
		$(this).fadeTo("slow", 1);
	}, function() {
		$(this).fadeTo("slow", 0.8);
	});
	$('div.image img').not('.regular').css({opacity:0.8});
	*/
// --> Start Project slider
	$('div.images div.image').nivoSlider({
		effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
		slices:15,
		animSpeed:800,
		pauseTime:6000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:true, //Next & Prev
		directionNavHide:true, //Only show on hover
		controlNav:true, //1,2,3...
		controlNavThumbs:false, //Use thumbnails for Control Nav
		controlNavThumbsFromRel:false, //Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
		keyboardNav:false, //Use left & right arrows
		pauseOnHover:false, //Stop animation while hovering
		manualAdvance:true, //Force manual transitions
		captionOpacity:0.8, //Universal caption opacity
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){} //Triggers after all slides have been shown
	});
	// --> Init FancyBox
	
		$("a[rel*='image']").fancybox({
			titleShow		:true,
			titlePosition	:'inside',
			transitionIn	:'elastic',
			transitionOut	:'elastic',
			easingIn		:'easeOutBack',
			easingOut		:'easeInBack',
			overlayColor	:'#000',
			cyclic			: true,
			overlayOpacity	:0.6
		});
	
// --> Start removing margin from each 4th element
		//$("div.category-images div.item:nth-child(4n+4), div.category-video div.item:nth-child(4n+4)").css({"margin-right":"0", "margin-left":"0"});

// --> Start Disable '#' links from being clicked
	$("a[href^='#']").click(function() {
		return false;
	});
	
// --> Init External Links
	$("a[rel*='external']").attr("target","_blank");
	
// --> Stripping a tags with: class="remove"
	$("a[class*='strip']").each(function(){
		$(this).replaceWith($(this).html()); 
	});
	
// --> Init SPAM Email links
	$("a[href^='mailto:']").each(function(){
		var mail = $(this).attr("href").replace("mailto:","");
		var replaced = mail.replace("/at/","@");
		$(this).attr("href","mailto:"+replaced);
		if($(this).text() == mail){ 
			$(this).text(replaced);
		}
	});

// --> Init Label2Value
	label2value();
});

/*****************************************************************************
//-> END Window Load
*****************************************************************************/

/*]]>*/
