var slideNumber = 4;
	$(document).ready(function(){
        
        if(document.getElementById("btn_pdf") != null){
            $('#btn_pdf').click(function() {
                $("#mail_error").hide();
                $("#mandatory_error").hide();
			    if(actions.getCookie("name_email_ipix") == null)
			    {
				    $.fancybox({'href': '#register', 'padding': '0', 'modal': false});
    				
				    $("#btnOk").unbind('click');
				    $("#btnOk").bind('click',(function(){
				        actions.PerformAction();
				    }));
				    $("#btnCancel").unbind('click');
				    $("#btnCancel").click(function(){$.fancybox.close();});
			    return false;
			    }
		    });
		}
        
        $('#slider1').bxSlider({
            displaySlideQty: slideNumber,
            moveSlideQty: 1,
            infiniteLoop: false,
			extendOnHover: true,
            hideControlOnEnd: true
        });
		
		$('#slider2').bxSlider({
            displaySlideQty: slideNumber,
            moveSlideQty: 1,
            infiniteLoop: false,
			extendOnHover: true,
            hideControlOnEnd: true
        });
		
		$('#tips').bxSlider({
			mode: 'vertical',
			controls: false,
			auto: true,
			infiniteLoop: true,
			pause: 6000
        });
		
		$('#tips1').bxSlider({
			mode: 'vertical',
			controls: false,
			auto: true,
			infiniteLoop: true,
			pause: 7000
        });

        $("#btn_demo").fancybox({
				'width'				: '85%',
				'height'			: '100%',
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
			});
$('#btn_demo').click(function() {
			if(document.getElementById("player") != null)
			{
				$f().pause();
			}
		});
		
		if(document.getElementById("player") != null)
		    flowplayer("player", {allowfullscreen: 'false', src: 'Documents/flowplayer-3.2.5.swf', wmode: 'transparent'}, {
	            canvas: {
					backgroundColor:'transparent',
					backgroundGradient: 'none'
				},
				
				/*clip: {
					autoPlay: true,
					autoBuffering: true
				},*/
				
				
				onMouseOver: function() {
					var content = this.getPlugin("myContent"); 
					content.show();
				},
	
				// when mouse is exited remove exposing
				onMouseOut: function() {
					var content = this.getPlugin("myContent"); 
					content.hide();
				},
				
				onLoad: function() {
					var content = this.getPlugin("myContent"); 
					content.hide();
				},
				
				play: {
					label: null,
					replayLabel: ""
				},

				// use a minimalistic controlbar
				plugins:  {
					controls:  {
						backgroundGradient: 'none',
						backgroundColor: 'transparent',
						all:false,
						mute: true,
						play: true,
						scrubber:true
					},
					myContent: {
						// location of the plugin
						url: 'Documents/flowplayer.content-3.2.0.swf',
						style: {
							'a': {
								color: '#0FFFFF',
								fontFamily: 'arial'
							},
							'a:hover': {
								color: '#000000',
								fontFamily: 'arial'
							}
						},
						// display properties
						top: 290,
						width: 150,
						height: 60,
						backgroundGradient: 'high',
						html: 'Vrei IPIX Sales Agent pentru website-ul tau? <a href="http://www.ipix.ro/imobiliare_ipix_sales_agent_web_actor.aspx">Click aici</a>'
					}
				}	
           });
		   
		   $(function() {
				$( "#player" ).draggable({
					stop: function() {
						$("#player").addClass("player");
					}
				}
			);
		});
	})
	
	var actions = {

		getCookie: function(c_name){
			var i,x,y,ARRcookies=document.cookie.split(";");
			for (i=0;i<ARRcookies.length;i++){
				x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
				y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
				x=x.replace(/^\s+|\s+$/g,"");
				if (x==c_name){
					return unescape(y);
				}
			}
		},
		
		setCookie: function(c_name,value,exdays){
			var exdate=new Date();
			exdate.setDate(exdate.getDate() + exdays);
			var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
			document.cookie=c_name + "=" + c_value;
		},
		
		goTo: function(href){
			window.open(href,"","","");
		},
		
		PerformAction: function(){
		    if ($("#login_name").val().length < 1 || $("#login_email").val().length < 1) {
	            $("#mandatory_error").show();
	            $("#mail_error").hide();
	            $.fancybox.resize();
	            return false;
	        }
	        
	        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
            var address = $("#login_email").val();
            if(reg.test(address) == false) {
                $("#mandatory_error").hide();
	            $("#mail_error").show();
	            $.fancybox.resize();
                return false;
            }
            
            $("#mandatory_error").hide();
	        $("#mail_error").hide();
		    var params = $("#login_name").val() + '|' + $("#login_email").val(); 
			callEmail.PerformCallback(params);  
		},
		
		onComplete: function(e){
		    actions.goTo($('#btn_pdf').attr('href'));
		    actions.setCookie("name_email_ipix","Ok", 30);
			$.fancybox.close();
			$.fancybox.cancel();
		}
	};

