<!--
	var roll_delay = 12000
	var fade_delay = 4000
	var roll_speed = 1000
	var fade_speed = 3000;
	var errors
	
	var fade_category_speed = 1000
	var fade_item_speed = 300
	var fade_item_pause = 100
	
	var section = 1
	var image = 1

	var big_images = new Array()

	var KEYCODE_ESC = 27;
	var jw
	var default_contact

	function empty_newsletter_form()
	{
		$(".form input,.form textarea").each(function(){
														$(this).val($(this).attr("title"))
		})
		$(".drop").html(default_contact)
		$(".stuff.bold").removeClass("bold")
		
	}

	/**
	*	get errros in JS object
	**/
	function get_errors()
	{
		$.post(url_ajax, 
			   { 
			   		action		: "get_errors_messages"
				},
				function(data){
					
					errors = data

				},"json");	
		
	}


	/**
	*	Contact form
	**/
	function submit_newsletter()
	{
		var required = new Array("name","email","message","contact")
		var copy_me = $("#copy_me").attr("checked");
		var newsletter = $("#newsletter").attr("checked");

		var email 		= $("#email").val();
		var email_to 	= $("#email_to").val();
		var name 		= $("#name").val();
		var message 	= $("#message").val();
		var contact 	= $("#contact").val();						
		var copy_me		= $("#copy_me").attr("checked")
		var newsletter	= $("#newsletter").attr("checked")
	
			
		var error
		var field
		
		for (x in required)
		{
			var el = $("#"+required[x])
			
			if (!el.val() || el.val()==el.attr("title"))
			{
				field = required[x]
				error = errors.empty[field];
				break;
			}
			
		}
		
		if (!error && !checkmail(email))
		{
			error = errors.bad.email
			field = "email"
		}
		
		if (error)
		{
			//alert(field)
			if (field=="contact")
			{
				$(".dropdown").addClass("errors")
			}
			else
			{
				$("#"+field).addClass("errors")
			}

			$("#error_msg").html(error)
			$("#error").fadeIn();
		}
		else
		{

			$.post(url_ajax, 
				   { 
						action		: "subscribe",
						name		: name,
						email		: email,
						email_to	: email_to,
						contact		: contact,
						copy_me		: copy_me,
						newsletter	: newsletter,
						message		: message
					},
					function(data){
						
						empty_newsletter_form();
						$("#result").fadeIn();					
	
					},"json");	
			
		}
		
	}

	/**
	*	Close error popup
	**/
	function close_popup(selector)
	{
		$(selector).fadeOut()
	}

	/** 
	*	Contact binds
	**/
	function init_contact_binds()
	{
		default_contact = $(".drop").html()
		$("input,textarea, .dropdown").click(function(){ 
															$(this).removeClass("errors")
															
															$("#error_msg").html('')
															$("#error").fadeOut();
															
		});
		
		$(".stuff").click(function(){
										$(".stuff.bold").removeClass("bold")
										$(".drop").html($(this).html())
										$(this).addClass("bold")
										$("#contact").val($(this).html())
										$("#email_to").val($(this).attr("title"))
									})
		$(".dropdown").click(function() { 
											var status = $(".select_options").css("display")
											
											if (status=='none')
											{
                      							$(".select_options").slideDown("fast");
											}
											else
											{
												$(".select_options").slideUp("fast");
											}
                      					})
										
		
		$(".focus").focus(function(){ 
									  var value = get_value("#"+$(this).attr("id"))
									  var default_value = $(this).attr('title')
										  							if (value==default_value)
																	{
																		$(this).val('')
																	}
								  })								  
								  
		$(".focus").blur(function(){ 
									  var value = get_value("#"+$(this).attr("id"))
									  var default_value = $(this).attr('title')
										  							if (value=='')
																	{
																		$(this).val(default_value)
																	}
								  })								  
	}

	function get_value(selector)
	{
		return $(selector).val()
	}

	<!-- GMAP -->
	function initialize()
	{
	
		 var geocoder = new google.maps.Geocoder();
		 var myOptions = 
			 {
				zoom: 2,
				mapTypeId: google.maps.MapTypeId.ROADMAP,
				disableDefaultUI: false,
				panControl: true,
				zoomControl: true,
				scaleControl: true
			  }
		  var map = new google.maps.Map(document.getElementById("map"), myOptions);
			
		  // Prepares the marker object, creating a google.maps.Marker object for each
		  // location, place and country
	
		  var infowindow = new google.maps.InfoWindow();
		  var latlngbounds = new google.maps.LatLngBounds();
		  
		  $(".location").each(function(){
			  
										var address = $(this).attr("id")
										var lat_lng = address.split(":");
										var info_window = $(this).find(".info_window").html()
										var a = $(this).find("a")								
										var i = 0
										
										set_console(lat_lng[0]+":"+lat_lng[1])
										
										var myLatlng = new google.maps.LatLng(lat_lng[0],lat_lng[1]);
	
											var marker = new google.maps.Marker(
											{
												map: map, 
												position: myLatlng
											});
											
											latlngbounds.extend(myLatlng);
											map.fitBounds(latlngbounds);
											
											/** add listener to marker **/
											google.maps.event.addListener(marker, 'click', function() {
											  
											  infowindow.setContent(info_window);
											  infowindow.open(map,marker);
											  
											});		  
											
											/** add listener to name of place **/
											a.bind("click",function(){ 
																			  infowindow.setContent(info_window);
																			  infowindow.open(map,marker);
	
																		})
									
										
			});
		
	}

	/**
	*	Scroll panel
	**/
	function scroll_pane(index)
	{
		var pane = $('.scroll-pane-intern');
		var api = pane.data('jsp');
		api.scrollToElement("#category"+index,true,true);
	}

	/**
	*	Dropdown categories
	**/
	function init_binds_clients()
	{
		
		
		$(".select").click(function() { 
											var status = $(".select_options").css("display")
											
											if (status=='none')
											{
                      							$(".select_options").slideDown("fast");
											}
											else
											{
												$(".select_options").slideUp("fast");
											}
                      					}
					  );	
		
		$(".category").click(function(){
									  		// scroll to category

											scroll_pane($(this).index())

											$(".select_options").slideUp("fast");
											
									  })
		
	}

	/**
	*	play video
	*/
	function play_video(index)
	{
		$(".btn_play_video.clicked").removeClass("clicked")
		jwplayer().load('/video/video'+index+'.f4v').play()
		
		
		var eq = parseInt(index)-1
		$(".btn_play_video").eq(eq).addClass("clicked")
		
		if ($(".video_text:visible").length)
		{
			$(".video_text:visible").fadeOut(null,function(){ $(".video_text").eq(eq).fadeIn(); });
			
		}
		else
		{
			$(".video_text").eq(eq).fadeIn();
		}
	}

	/**
	*	init video
	**/
	function init_binds_video()
	{
		set_console($(".video_text").css("width"))
	}

	function set_console(text)
	{
		$(".console").append("<br>"+text)
	}

	/**
	*	get content of big popup
	**/
	function get_content(id)
	{
		return $(id).html()
	}

	/**
	*	movecarusel
	**/
	function move_carousel(direction)
	{
		var count_section  = $(".category").length
		var count_item = $("#category"+section+" .item").length
		
		image = parseInt(image)
		section = parseInt(section)
		
		$(".item a.clicked").removeClass("clicked")
		
		set_console("#category"+section+"_"+image);
		
		switch (direction)
		{
			case "left":
			
				if (image==0)
				{
					if (section==1)
					{
						section = $(".category").length
					}
					else
					{
						section--
					}
					
					image = $("#category"+section+" .item").length-1
					show_category_items(section,true,true,true)
					
				}
				else
				{
					image--
				}
				
				
				// MOVE TO RIGHT
				
				
				
				
			break;
			case "right":

				if ((image+1)==count_item)
				{
					if (section==count_section)
					{
						section = 1
					}
					else
					{
						section++
					}
					
					image = 0
					show_category_items(section,true,true,true)
					
				}
				else
				{
					image++
				}
				
				// MOVE TO LET
				
			break;
		}
		
		set_console($("#category"+section+"_"+image).html());
		
		$(".popup").html( get_content("#category"+section+"_"+image) )
		
		$("#category"+section+" .item a").eq(image).addClass("clicked")
		
	}

	/**
	*	cloe small popup
	**/
	function close_small_info(i,j)
	{
		var top = $(".popup .info_work").css("top")
		
		var base
		
		base = (i==3 && (j==23 || j==24))	?	"276px"
											:	"285px";
		
		if (top=="236px")
		{
			$(".popup .info_work").animate(
												{"top":base},
												600
											)
			$(".popup .info_work #close").fadeOut(300,function()
																	{
																		$(this).attr("src","/images/common/portfolio/btn_open_popup.gif").fadeIn(300)
																	}
																	);
													
			
		}
		else
		{
			$(".popup .info_work").animate(
												{"top":"236px"},
												600
										  )
			$(".popup .info_work #close").fadeOut(300,function()
																		{
																			$(this).attr("src","/images/common/portfolio/btn_close_popup.gif").fadeIn(300)
																		}
																		);
									  
												
		}
		//alert(top)
	}

	/**
	*	
	**/
	function close_open_popup(action)
	{
		switch (action)
		{
			case "open":
				/** show popup **/
				$(".popup_holder").show()
				$(".white_hover").show()
			break
			case "close":
				/** show popup **/
				$(".popup_holder").hide()
				$(".white_hover").hide()
			break
		}
		
	}

	/**
	*	bind action for each
	**/
	function init_binds_items()
	{
		
		/**
		*	Place elements of popup
		**/
		$(".element").eq(0).css({"left":"0px"});
		$(".element").eq(1).css({"left":"520px"});
		$(".element").eq(2).css({"left":"1040px"});
		
		/** ESCAPE KEY **/		
		$(document).keyup(function(e) {
		  if (e.keyCode == KEYCODE_ESC) { close_open_popup("close") } 
		});		
	
		$(".btn_close").click(function(){ close_open_popup('close') })
		
		//* PREV / NEXT buttons */
		$(".btn_prev").click(function(){ move_carousel('left');})
		$(".btn_next").click(function(){ move_carousel('right');})
		
		$(".item a").click(function(){ 
											$(".item .clicked").removeClass("clicked");
											$(this).addClass("clicked");
											
											var ssection = $(".button.clicked").index()+1
											var iimage   = $(this).attr("id")
											
											section = ssection
											image   = iimage
											
											// Put the html in center
											$(".popup").html(get_content("#category"+ssection+"_"+iimage))
											
											// get popup content
											close_open_popup("open")
											
										})
	}


	/**
	*	Show category items
	**/
	function show_category_items(i,fade_items,fade_out_category,not_close_popup)
	{

		// clear timeout for fade elements
		clearTimeout();

		// no action if is the same index
		var visible_index = $(".category:visible").index()+1
		if (visible_index==i)
		{
			return;
		}
		
		// hide open category
		hide_current_category(fade_out_category);
		
		if (!not_close_popup)
		{
			close_open_popup("close");
		}
		
		var eq  = i-1;
		var new_category = $("#category"+i)
		
		// add clicked class to category button
		$(".button").eq(eq).addClass("clicked")
		
		
		if (fade_items)
		{
			// fade in category items
			new_category.show();
			// fade items
			fade_all_items(i,0)
		}
		else
		{
			// simply show category items
			new_category.show();
			new_category.find(".item").removeClass("opacity_0")
		}
		
		
	}

	/**
	*	Hide category items and holder
	**/
	function hide_current_category(fade_out)
	{
		var visible_category = $(".category:visible")
		
		if (!visible_category.length) return;
		fade_out = false
		// remove clicked class to category button
		$(".button.clicked").removeClass("clicked")	
		visible_category.find("a").removeClass("clicked")
		if (fade_out)
		{
			// fadeout category holder
			visible_category.fadeOut(fade_category_speed,function(){ 
																			visible_category.find('.item').css("opacity",'0') 
																			clearTimeout();
																		  });
		}
		else
		{
			// hide category holder
			visible_category.hide();
			visible_category.find('.item').css("opacity",'0')
			clearTimeout();
		}
		
	}

	/**
	*	fade items
	**/
	function fade_all_items(i,eq)
	{
		
		var category = $("#category"+i)
		var total = category.find(".item").length
	
		// if is the last element return from functions
		if ((eq+1)>total) 
		{
			clearTimeout();
			return;
		}
		
		// fade item
		category.find(".item").eq(eq).animate({ 
												opacity: 1
											  }, fade_item_speed,null,function(){ $(this).removeClass("opacity_0") } );
		
		eq++;									  
		setTimeout("fade_all_items("+i+","+eq+")",fade_item_pause)										  
	}
	

	
	/**
	*	fade images
	**/
	function init_fade_image()
	{
		var count = parseInt($(".slideshow img").length);
		var width = $(".slideshow").width()+"px"
		$(".slideshow img").eq(0).animate({ 
												width: width,
												opacity: 0,
												left : 0
												}, 
												fade_speed,
												"swing",
												function()
												{
													//alert($(this).css("z-index"))
													var z = parseInt($(this).css("z-index"))
													var new_z = z - count
													$(this).remove().clone().appendTo(".slideshow").show().css("z-index",new_z).css("opacity",1).width("105%");
													setTimeout("init_fade_image()",fade_delay);
												})
	}

	/**
	*	slide testimonials
	**/
	function init_roll_testimonials(first)
	{
		
		if (first)
		{
			$(".testimonials .roll").eq(0).fadeIn(roll_speed);
			setTimeout("init_roll_testimonials()",roll_delay);
		}
		else
		{
			$(".testimonials .roll").eq(0).fadeOut(roll_speed,function(){
														$(this).next().fadeIn(roll_speed);
														$(this).remove().clone().appendTo(".testimonials");
														setTimeout("init_roll_testimonials()",roll_delay);
													})
		}
	}

	/**
	*	get errros in JS object
	**/
	function get_errors()
	{
		$.post(url_ajax, 
			   { 
			   		action		: "get_errors_messages"
				},
				function(data){
					
					errors = data

				},"json");	
		
	}

	/**
	*	Fancy init
	*/
	function init_fancy()
	{
		$(".fancy").fancybox({
							 	autoDimensions 	:	true,
								centerOnScroll	:	true,
								overlayOpacity	:	0.7,
								overlayColor	:	'#000',
								titleShow		:	false,
								scrolling		:	"no"
							 });
		
		$(".fancy_no_padd").fancybox({
							 	autoDimensions 	:	true,
								centerOnScroll	:	true,
								overlayOpacity	:	0.7,
								overlayColor	:	'#000',
								titleShow		:	false,
								scrolling		:	"no",
								padding			:	0,
								margin			:	0
							 });
		
	}
	
	/**
	*	Subsribe
	**/
	function subscribe()
	{
		var email = $("#email").val();
		var error = ''
		
		if (!email)
		{
			error = errors.empty.email
		}
		
		if (!error && !checkmail(email))
		{
			error = errors.bad.email
		}
		
		if (error)
		{
			$("#newsletter .error_message").html(error)
		}
		else{
			
			$.post(url_ajax, 
				   { 
						action		: "subscribe",
						email		: email
					},
					function(data){
						
						if (data.error)
						{
							$("#newsletter .error_message").html(data.error)
						}
						else
						{
							$("#newsletter .error_message").html('');
							$("#newsletter_form").slideUp("fast",function(){$("#reponse").slideDown("fast")})
						}
	
					},"json");	
		}
	}

	/**
	*	Scroll reinitilate
	**/
	function reinit_scrollpane()
	{
		$('.scroll-pane-black').jScrollPane({hideFocus:true});
	}

	/**
	*	Show 
	**/
	function show_tab_show(id_city)
	{
		var html = $("#show-tab-"+id_city).html()
		
		// Add some content to #pane2
		var pane2api = $('.scroll-pane-intern').data('jsp');
		pane2api.getContentPane().html(html);
	
		// Reinitialise the #pane2 scrollpane
		pane2api.reinitialise();
	}


-->
