/*

Common javascript functions

Author: Artem Timryakov
Copyright: 2011, Artem Timryakov. All rights resevered

-----------------------------------------------------------------------*/


jQuery(function(){

	var li = jQuery('.S-gallery').find('li');
	
	jQuery('.text-area, #S-menu, #wsite-content, #header, .mainNav, #content, .S-logo').css(
				{
				'z-index':'3',
				'position':'relative'
				});

	li.each(function(i){
		var t = jQuery(this),
			img = t.find('img'),
			src = img.attr('src'),
			width = li.width(),
			height = li.height();

		img.hide().after(jQuery('<div />').attr('id', 'holder'+i).addClass('S-holder'));

		var r = Raphael('holder'+i, width*2, height*2),
			rimg = r.image(src, width/2, height/2, width, height);

		rimg.hover(function(event) {
		    this.animate({
				scale: 2,
				rotation : 360
			}, 1200, 'elastic');
			jQuery('.text-area, #S-menu, #wsite-content, #header, .mainNav, #content, .S-logo').css(
				{
				'z-index':'1',
				'position':'relative'
				});
		}, function (event) {
		    this.animate({
				scale: 1,
				rotation : 0
			}, 1200, 'elastic');
			jQuery('.text-area, #S-menu, #wsite-content, #header, .mainNav, #content, .S-logo').css(
				{
				'z-index':'3',
				'position':'relative'
				});
		});

	});

	li.hover(function(){
		li.css({ 'z-index': 1 });
		jQuery(this).css({ 'z-index': 2 });
	});

});

