/***************************/
//@website: www.ZwebbieZ.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
	// hide youtube
	$(".youtube").hide();
	$(".youtube").css({
			"opacity": "0.7"
		});
	$("#waterwheel-carousel-horizon").css({
			"opacity": "0.7"
		});
		
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		
		$("#backgroundPopup").fadeIn("slow");
		$("#popupContact").fadeIn("slow");
		
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
		$(".youtube").fadeIn("slow");
		$("#waterwheel-carousel-horizon").fadeIn("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	scrollTo( 0, 0);
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact").height();
	var popupWidth = $("#popupContact").width();
	
	//var documentHeight = $(document).height();

	//centering
	$("#popupContact").css({
		"position": "absolute",
		//"top": documentHeight - windowHeight + (windowHeight/2-popupHeight/2),
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$(".button").click(function(){
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});
				
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose").click(function(){
		disablePopup();
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});
	
});

// CHECK LOGIN 
function check_login(){
	  var username = $('#username').val();	
	  var password = $('#password').val();
	  if(trim(username) == ''){
		alert('Please Enter the username !'); 
		return false; 
	  }
	  if(trim(password) == ''){
		alert('Please Enter the password !');
		return false;  
	  }
	  
	  $.ajax({
		'url' 		: 'index.php?module=user&action=ajax_user_login',
		'type'		: 'GET',
		'data'		: 'username='+username+'&password='+password,
		'async'		: false,
		'success' 	: function(data){
						if(data == 1){
						document.location = 'index.php?action=product&module=user';
						}else{
						alert('Please check your username / password!')
						var text=document.getElementById('username');
						text.value="";
						var text1=document.getElementById('password');
						text1.value="";
						}
					  }
		})
	return data;
	  
}

// IMAGE SCROLLER

$(document).ready(function () {
	    
		$('.moving_img').mouseover(function(){
			
			});
		
		$('.moving_img').betterTooltip({speed: 150, delay: 300});
				
        $("#waterwheel-carousel-default").waterwheelCarousel();
        $("#waterwheel-carousel-higharch").waterwheelCarousel({
            startingWaveSeparation: -90,
            waveSeparationFactor: .7,
            centerOffset: 10,
            startingItemSeparation: 120,
            itemSeparationFactor: .9,
            itemDecreaseFactor: .75
        });
        
        $("#waterwheel-carousel-horizon").waterwheelCarousel({
            startingWaveSeparation: 0,
            centerOffset: 30,
            startingItemSeparation: 150,
            itemSeparationFactor: .7,
            itemDecreaseFactor: .75,
            opacityDecreaseFactor: 1,
            autoPlay: 0
        });
        
        $("#waterwheel-carousel-flat").waterwheelCarousel({
            itemSeparationFactor: 1,
            itemDecreaseFactor: 1,
            waveSeparationFactor: 1,
            startingWaveSeparation: 0,
            startingItemSeparation: 280,
            centerOffset: 10,
            opacityDecreaseFactor: .3,
            autoPlay: 3000,
            edgeReaction: 'reverse'
        });
        
        $("#waterwheel-carousel-vertical").waterwheelCarousel({
            orientation: 'vertical',
            startingItemSeparation: 100,
            startingWaveSeparation: 40,
            autoPlay: 2000
        });

      });
	  
	  

	  

