	
	function checkForm( obj, callback )
	{
		var error = false;
		
		// Check required fields
		jQuery(obj).find('.required').each(function(index,obj){			
			if( !obj.value || obj.value == obj.title )
			{  			
				error = true;
				
				alert('All fields are required!');
								
				jQuery(obj).focus();
				
				return false;
			}
		});
		
		if( !error && callback ){ callback(); return false; }
		
		return error ? false : true;
	} 
		
	function InputTextToggle( e )
	{				
		var el = jQuery(e.currentTarget);		
		var txt = el.attr('title');		
		if(e.type == 'focus' && el.val() == txt){ el.val(''); }
		if(e.type == 'blur' && !el.val() ){  el.val(txt); }
	}
	
	function Carousel( dom_id, step )
	{			
		this.id = dom_id;		
		this.step = step;
		this.index = 1;
		this.container = jQuery(this.id+' .slider-inner');		
		this.count = this.container.find('.item').length;			
		
		this.Next = function()
		{								
			if( this.index != this.count ) 
			{							
				this.container.animate({
					marginLeft: '-='+this.step
				}, 500 );
				this.index++;
			}
		};
		
		this.Prev = function()
		{
			if( this.index > 1 )
			{				
				this.container.animate({
					marginLeft: '+='+this.step
				}, 500 );
				this.index--;
			}			
		};
	}
	
	function loadImage( tab_nr, img_nr )
	{
		window.clearInterval(window.tabTimer);
		
		jQuery('#tab-'+tab_nr+' .images img').hide();
		jQuery('#tab-'+tab_nr+' .images img:eq('+img_nr+')').show();
		
		jQuery('#tab-'+tab_nr+' .thumbs a').removeClass('active');
		jQuery('#tab-'+tab_nr+' .thumbs a:eq('+img_nr+')').addClass('active');
	}
	
	window.activeTab = 1;
	window.tabTimer = null;
	
	function changeTab(nr,obj,clear)
	{
		if(clear){ window.clearInterval(window.tabTimer); }
		jQuery('.tabs-container .links a').removeClass('active');
		jQuery(obj).addClass('active');
		jQuery('.tabs-container .tab').hide();
		jQuery('#tab-'+nr).show();
	}
	
	var tnSlider = {
		
		index : 1,
		count : 0,
		width : 0,
		padd: 0, 
		timer : null,
		
		init : function( width, padd )
		{			
			tnSlider.width = width+1;
			tnSlider.padd = padd;
			tnSlider.count = jQuery('.image-slider .slider-inner .item').length;
			//imgRotator.timer = setInterval( 'imgRotator.Next()', 2000 );	
		},
		
		Next : function()
		{
			if( tnSlider.index+tnSlider.padd < tnSlider.count )
			{			
				jQuery('.image-slider .slider-inner').animate({
					marginLeft: '-='+tnSlider.width
				}, 500 );
				tnSlider.index++;
			}
		},
		
		Prev : function()
		{
			if( tnSlider.index > 1 )
			{
				jQuery('.image-slider .slider-inner').animate({
					marginLeft: '+='+tnSlider.width
				}, 500 );
				tnSlider.index--;
			}			
		}
		
	}

	
	var geocoder;
 	var map;

	function GMap_Load() 
	{
		geocoder = new google.maps.Geocoder();
		var latlng = new google.maps.LatLng(-34.397, 150.644);
		var myOptions = {
		  zoom: 16,
		  center: latlng,
		  mapTypeId: google.maps.MapTypeId.ROADMAP
		}
		map = new google.maps.Map(document.getElementById("map"), myOptions);
	}

  	function GMap_CodeAddress( address )
	{    	
    	geocoder.geocode({ 'address': address }, function(results, status){
      		if (status == google.maps.GeocoderStatus.OK) {
        		map.setCenter(results[0].geometry.location);
        		var marker = new google.maps.Marker({
            		map: map,
            		position: results[0].geometry.location
        		});
      		} 
			else {
        		alert("Geocode was not successful for the following reason: " + status);
      		}
    	});
  	}
	
	function showImage( id )
	{
		$('.featured-image a').hide();
		$('#img-'+id).show();
	}	
		
	jQuery(document).ready(function(){		
				
		jQuery('input,textarea').focus(InputTextToggle);			
		jQuery('input,textarea').blur(InputTextToggle);
		
		window.tabTimer = window.setInterval(function(){	
			window.activeTab++;
			if(window.activeTab > window.tabCount){ window.activeTab=1; }
			//changeTab(window.activeTab,);
			jQuery('.tabs-container .links a').removeClass('active');
			jQuery('.tabs-container .links a:eq('+(window.activeTab-1)+')').addClass('active');
			jQuery('.tabs-container .tab').hide();
			jQuery('#tab-'+window.activeTab).show();
		},4000);	
		
	});
		

