// JavaScript Document

function rand(a,b){
    return Math.floor(Math.random()*(b-a+1)+a);

}



$(document).ready(function() {

	

	// Set CSS settings for aniamtion and effects =======================
	$('.page_container').css({
		'display': 'none',
		'opacity': '0'
	});

	$('.hdr-frst-bg').css({

		'display' : 'block'

	});

			

	$('.main_col').css({

		'top' : '-525px'

	});	

	

	$('.left_col').css( leftCol.situation , '205px' );

	$('.left_col').css( 'opacity' , '0' );

	

	$('.main-wrppr-lft-btm').css({

		'opacity' : '1',

		'visibility' : 'visible'

	});

	

	$('.footer_wrppr').css({

		'bottom' : '100px',

		'opacity' : '0',

		'z-index' : '70'

	});

	

	$(".header_container, .logo_holder, .languages_holder, .search_holder, .menu, .menu_shadow, .line1_menus").css({
		'opacity' : '0'
	});

	

	$(" .new_content,\
		.rad_content,\
		.faq_content,\
		.down_content\
	  ").css({

		'display' : 'none'

	});

	

	

	

	// Start aniamtion and effects ====================================
	var _firstDelay = 1500;
	// E ==================
	$('.preloader').delay(_firstDelay + 500).animate({
		'opacity' : '0'
	}, 750, function() {
		$('.preloader').css({
			'display' : 'none',
			'visibility' : 'hidden'
		});
	});
	$('.page_container').delay(_firstDelay).css({
		'display': 'block'
	});
	$('.page_container').delay(_firstDelay).animate({
		'opacity' : '1'
	}, 10, function() {
		$(' .header_container,\
			.logo_holder,\
			.languages_holder,\
			.search_holder,\
			.line1_menus,\
		  ').delay(250).animate({
	
			'opacity' : '1'
	
		}, 850,
	
		function() {
	
			dt = 0;
	
			$('.top_menu .menu').each(function() {
	
				$(this).delay(dt).animate({
	
					'opacity' : '1'
	
				}, 350);
	
				dt += 100;
	
			});
	
			
	
			$('.hdr-frst-bg').css({
	
				'display' : 'none'
	
			});
	
		});	
	
		
	
		// E ==================
	
		$('.main_col').delay(450).animate({
	
			'top' : '0px'
	
		}, 1000, 'easeOutCubic', function() {
	
			
	
			$('.main-wrppr-lft').animate({
	
				'opacity' : '0'
	
			}, 800);
	
			
	
			$('.main-wrppr-lft-btm').animate({
	
				'opacity' : '0'
	
			}, 800);
	
			
	
			$('.left_col').animate({
	
				'opacity' : '1'
	
			}, 550);
	
			$('.left_col').animate(
	
				leftCol.animation()
	
			, 550, 'easeOutCubic', function() {
	
				
	
				$('.footer_wrppr').delay(450).animate({
	
					'opacity' : '1',
	
					'bottom' : '0px'
	
				}, 400, 'easeOutBounce', function() {
	
					
	
					$('.main-wrppr-lft-btm').css({
	
						'visibility' : 'hidden'
	
					});
	
					
	
				});
	
				
	
			});
	
		});


	

		// E ==================
	
		shadow_dt = 0;
	
		$('.menu_shadow').delay(1750).each(function() {
	
			$(this).delay(shadow_dt).animate({
	
				'opacity' : '0.6'
	
			}, 400);
	
			shadow_dt += 150;
	
		});

	});





	// Menus effects ========================================================================================

	$('ul.top_menu .line2_menus > li').each(function() {

		

		var _thisId = '#' + this.id + '_tip';

		

		$(this).hover(function() {

			

			$('.menu_shadow', this).stop().animate({

				'opacity' : '0.25'

			}, 70);

			

			$('.menu', this).stop().animate({

				'top' : '-2px',

				'height' : '18px',

				'opacity' : '0.75'

			}, 100);

			

			$( _thisId ).stop().delay(100).css({'display' : 'block'}).animate({

				'bottom' : '36px',

				'opacity' : '1'

			}, 200);

			

		}, function() {

			

			$('.menu_shadow', this).stop().delay(70).animate({

				'opacity' : '1'

			}, 75);

			

			$('.menu', this).stop().animate({

				'top' : '0px',

				'height' : '16px',

				'opacity' : '1'

			}, 75);

			

			$( _thisId ).stop().animate({

				'bottom' : '0px',

				'opacity' : '0'

			}, 150, function() {

				$(this).css({'display' : 'none'});

			});

			

		});

		

	});

	

	

	// E ==================

		$('#products').hover(function() {

			$('.products_sub_menu', this).css({

				'display' : 'block',

				'opacity' : '0'

			});

			$('.products_sub_menu', this).stop().animate({

				'opacity' : '0.9'

			}, 500);

			$('.products_sub_menu li', this).hover(function() {

				$(this).css({

					'background' : '#000'

				});

			}, function() {

				$(this).css({

					'background' : '#8C0000'

				});

			});

		}, function() {

			$('.products_sub_menu', this).stop().animate({

				'opacity' : '0'

			}, 500, function() {

				$(this).css({

					'display' : 'none'

				});

			});

		});





	

	// Home slider ===============================================================

    var sliders = $('.slider .home_slide_img');

    sliders.hover(function() {

        sliders.stop().animate({'width' : '49px'}, 600);

        $(this).stop().animate({'width' : '181px'}, 600);        

    }, function() {

        sliders.stop().animate({'width' : '60px'}, 600);

    });

	

	

	

	// toggle effect =============================================================

	$( '.new_box, .rad_box, .faq_box, .down_box' ).click(function() {

		$('.new_content, .rad_content, .faq_content, .down_content', this).toggle( 250 );

	});

	

	

	

	// end effect ================================================================

	$('a').click(function(){

		if($(this).attr('target')!='') return true;



		url=$(this).attr('href');

		if(url=='#' || $(this).attr('rel')=='group' || $(this).attr('id').indexOf('fancybox')!= -1) return false;

		if($(this).attr('class') == 'download_link') return;

		

		$('body div div div div div').each(function(){

			$(this).delay(rand(100,800)).animate({

				'opacity':0

			},rand(500,800));

		})

		$('.header_container, .left_col, .main_col, .footer_container, ._1devs').each(function(){

			$(this).delay(rand(1000,1600)).animate({

				'opacity':0

			},rand(250,500));

		});

		$('body div').delay(1800).animate({

			'opacity':0

		},300);

		setTimeout(function(){

			window.location.href=url;

		},2000);

		return false;

	});

	

	

	

	// products page effects ======================================================	

	$('.album .a').hover(function() {
		$('.m', this).stop().animate({
			'height': 35
		}, 200);
	}, function() {
		$('.m', this).stop().animate({
			'height': 0
		}, 200);
	});

			

	$("a[rel=group]").each(function(){

		$(this).fancybox({

			'overlayShow':true,

			'transitionIn':'elastic',

			'transitionOut':'elastic',

			'titlePosition':'over',

			'titleFormat':function(desc, currentArray, currentIndex, currentOpts) {

				return '<span id="fancybox-title-over">' + (desc.length ? '&nbsp;' + desc : '') + '</span>';

			}

		});

	});

	

	

}); //Document ready close
