jQuery.noConflict();

jQuery(function($) {  

$(document).ready(function() {
	$('.successMessage, .successMessage2').fadeOut(0); 
});

				// Supersized
				$.supersized({
				
					// Functionality
					slideshow               :   0,			// Slideshow on/off
					autoplay				:	1,			// Slideshow starts playing automatically
					start_slide             :   1,			// Start slide (0 is random)
					stop_loop				:	0,			// Pauses slideshow on last slide
					random					: 	0,			// Randomize slide order (Ignores start slide)
					slide_interval          :   8000,		// Length between transitions
					transition              :   1, 			// 0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
					transition_speed		:	1200,		// Speed of transition
					new_window				:	1,			// Image links open in new window/tab
					pause_hover             :   0,			// Pause slideshow on hover
					keyboard_nav            :   1,			// Keyboard navigation on/off
					performance				:	1,			// 0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)
					image_protect			:	1,			// Disables image dragging and right click with Javascript
															   
					// Size & Position						   
					min_width		        :   0,			// Min width allowed (in pixels)
					min_height		        :   0,			// Min height allowed (in pixels)
					vertical_center         :   1,			// Vertically center background
					horizontal_center       :   1,			// Horizontally center background
					fit_always				:	0,			// Image will never exceed browser width or height (Ignores min. dimensions)
					fit_portrait         	:   1,			// Portrait images will not exceed browser height
					fit_landscape			:   1,			// Landscape images will not exceed browser width
															   
					// Components							
					slide_links				:	'blank',	// Individual links for each slide (Options: false, 'number', 'name', 'blank')
					thumb_links				:	0,			// Individual thumb links for each slide
					thumbnail_navigation    :   0,			// Thumbnail navigation
					slides: [ 
					
					// ***************************** ADD YOUR BACKGROUND IMAGES BELLOW *****************************
         {
            image: 'images/supersized/bga.jpg',
            title: 'Try using your keyboard arrows'
        }, {
            image: 'images/supersized/2.jpg',
            title: 'This is image title example!'
        }, {
            image: 'images/supersized/3.jpg',
            title: 'Lorem ipsum dolor sit amet'
        },{
            image: 'images/supersized/4.jpg',
            title: 'Lorem ipsum dolor sit amet'
        
			        }],
												
					// Theme Options			   
					progress_bar			:	0,			// Timer for each slide							
					mouse_scrub				:	0
					
				}); // end Supersized
				
				// countdown timer
				$(document).ready(function () {
				$("body").kkCountDown({
				addClass: 'shadow'
				});
				}); // end Countdown timer
				
				// Audio Player
				$("#jquery_jplayer_1").jPlayer({
					ready: function () {
						$(this).jPlayer("setMedia", { // Links to your songs
							m4a: "audio/stop(blueMix).m4a",
							oga: "audio/stop(blueMix).ogg"
						}).jPlayer("play");
					},
					ended: function (event) {
						$(this).jPlayer("play");
					},
					swfPath: "../js",
					supplied: "m4a, oga"
				});

				
				
				// Infield Text (Input)
				$('.text').click(
			
				function () {
					if (this.value == this.defaultValue) {
						this.value = '';
					}
				});
				$('.text').blur(
			
				function () {
					if (this.value == '') {
						this.value = this.defaultValue;
					}
				});
				
				
				// Animate main content 
				effects = {queue:true, duration:1500, easing: 'easeInOutExpo'};
				$('#mainContent').delay(400).animate({ // start animation after 0.4s
    			left: 0}, effects);
				
				
				// Center the content in the middle of the screen
				
				// Fix the main content wrap	
				var wdth = $('.container_inner').width();
				$('.container_inner').width(wdth-20);
				
				// Center the main content in the middle of the screen
				var dheight = $(document).height();
				var cheight = $('#mainContent').height();
				
				var psition = (dheight-cheight)/2;
				
				$('#mainContent').css("top",psition);
				$('#prevslide').css("top", (dheight-60)/2);
				$('#nextslide').css("top", (dheight-60)/2);
				
				// on resize center the main content
				$(window).resize(function(){
					var dheight = $(document).height();
					var cheight = $('#mainContent').height();	
					var psition = (dheight-cheight)/2;		
					$('#mainContent').css("top",psition);
					$('#prevslide').css("top", (dheight-60)/2);
					$('#nextslide').css("top", (dheight-60)/2);
				});			
				
				
				// Progress Bar (Pie)
				var timer;
				var timerCurrent;
				var timerFinish;
				var timerSeconds;
				function drawTimer(percent){
				$('div.timer').html('<div class="percent"></div><div id="slice"'+(percent > 50?' class="gt50"':'')+'><div class="pie"></div>'+(percent > 50?'<div class="pie fill"></div>':'')+'</div>');
				var deg = 360/100*percent;
				$('#slice .pie').css({
					'-moz-transform':'rotate('+deg+'deg)',
					'-webkit-transform':'rotate('+deg+'deg)',
					'-o-transform':'rotate('+deg+'deg)',
					'transform':'rotate('+deg+'deg)'
				});
				$('.percent').html(Math.round(percent)+'%');
				}
				function stopWatch(){
				var seconds = (timerFinish-(new Date().getTime()))/1000;
				if(seconds <= 0){
					drawTimer(100);
					clearInterval(timer);
					$('input[type=button]#watch').val('Start');
					alert('Finished! Callback... ');
				}else{
					var percent = 100-((seconds/timerSeconds)*100);
					drawTimer(percent);
				}
				}
				$(document).ready(function(){
				$('input[type=button]#percent').click(function(e){
					e.preventDefault();
					drawTimer($('input[type=text]#percent').val());
				});
				$('input[type=button]#size').click(function(e){
					e.preventDefault();
					$('.timer').css('font-size',$('input[type=text]#size').val()+'px');
				});
				$('input[type=button]#watch').click(function(e){
					e.preventDefault();
					if($('input[type=button]#watch').val() == 'Start'){
						$('input[type=button]#watch').val('Stop');
						timerSeconds = $('input[type=text]#watch').val();
						timerCurrent = 0;
						timerFinish = new Date().getTime()+(timerSeconds*1000);
						timer = setInterval('stopWatch()',50);
					}else{
						$('input[type=button]#watch').val('Start');
						clearInterval(timer);
					}
				});
				$('input[type=button]#watch').click();
			});
			
				//center the pie progress bar
				var cwidth = $('.custom').width();
				var pieWidth = $('.timer').width();
				var potion = (cwidth-pieWidth)/2;
				
				$('.timer').css("left", potion-15);
			
				
				// center the percent holder
				var holderHeight = $('.percentHolder').height();
				var placeMe = (cheight-holderHeight)/2;
				
				$('.percentHolder').css("top", placeMe-10);
			
				var holderWidth = $('.percentHoder').width();
				var placeWidth = (cwidth-holderWidth)/4;
				
				$('.percentHolder').css("left", placeWidth-3);
				
				// draw timer
				$(document).ready(function(){
					drawTimer($('input[type=text]#percent').val());
					});
				
				// Ajax load page -->
				$('#contactPage,#index').live('click',function(){
					if($(this).attr('id')!='contactPage') {location.reload();} 
					
					else{
					var path = $(this).attr('id')+'.html';
					}
					$('#mainContent').animate({
    				left: 4000}, {queue:true, duration:1500, easing: 'easeInOutExpo', complete: function(){
						$('#pageReserved').load(''+path, function(){
							$('.successMessage, .successMessage2').fadeOut(0); 
							$('#mainContent').animate({left:'0px'}, effects);
							
							/*  Contact Form Processing */  
							  $('#submit1').click(function() {
									var email = $('#email').val();	
									var name   = $('#name').val();
									var message = $('#message').val();
									
									var dataString = '&name=' + name + '&message=' + message + '&email=' + email;									
									
										$.ajax({
										type: "POST",
										url: "contactform.php",
										data: dataString,
										success: function() {
										var hght = $(window).height();
										var wdth = $(window).width();
										var msg1h = $('.successMessage').height();
										var msg1w = $('.successMessage').width();
										
										var hghtR1 = (hght-msg1h)/2;
										var wdthR1 = (wdth-msg1w)/2;
										
										$('.successMessage').css('top',hghtR1-25+'px');
										$('.successMessage').css('left', wdthR1+'px');
										
										$('.successMessage').fadeIn().delay(3000).fadeOut('slow');
										
										 $('#email').val("Email address...");
										 $('#name').val("Enter your name...");
										 $('#message').val("Message text...");
										}
									});
							  
							  return false;
									
							
							  });
							})
						
						} // end of callback function
					}) // Animate End
				}); // Ajax load end
				
				
  /*  Newsletter Processing */  
  $('#submit2').click(function(){
		var news   = $('#news').val();
		
	
	var dataString = '&news=' + news;  
	
	$.ajax({
    type: "POST",
    url: "newsletter.php",
    data: dataString,
    success: function() {
	var hght = $(window).height();
	var wdth = $(window).width();
	var msg1h = $('.successMessage2').height();
	var msg1w = $('.successMessage2').width();
	var msg2w = $('.successMessage2').width();
	
	var hghtR1 = (hght-msg1h)/2;
	var wdthR1 = (wdth-msg1w)/2;
	
	
	$('.successMessage2').css('top',hghtR1-25+'px');
	$('.successMessage2').css('left', wdthR1+'px');
	$('.successMessage2').fadeIn().delay(3000).fadeOut('slow');
	
	$('#news').val("mail@mail.com");
    }
  });
  
  return false;
		
  });	
		
				
				// THIS IS FOR DEMO PURPOSE ONLY, DELETE THIS IN YOUR LAUNCH VERSION!
				$(document).ready(function () {
				$("div.panelButton").click(function () {
					$("div#panel").animate({
						left: "0px"
					}, 500);
					$(".panelButton").animate({
						left: "353px"
					}, 500);
					$("div.panelButton").toggle();
				});
				$("div.hide_button").click(function () {
					$("div#panel").animate({
						left: "-353px"
					}, 500);
					$(".panelButton").animate({
						left: "0px"
					}, 500);
				});
			
			
				// -----------
				$('#patternSelect img').click(function () {
					var put = 'url('+$(this).attr('src')+')';
					$("#patternOverlay").css("background-image",put);
				})
				
				$('#percentProgress').change(function () {
					
				var procenat = $(this).val();
				if(procenat<=100){ 
				
				drawTimer(procenat);
				}
				else {
					drawTimer(0);
					}
				});
				
				$("#firstColor").focusout(function() {
				  var color = $('#firstColor').val();
				  $('.custom,.custom2').css('background-color', color);
				});
				
				$("#secondColor").focusout(function() {
				  var color = $('#secondColor').val();
				  $('#mainContentInner').css('background-color', color);
				});
				// END DEMO
			
			
			}); // end document ready function
			
 
						

}); // end jQuery
