
$(document).ready(function() {
	autoTab();
});
function numbersOnly(el){el.value = el.value.replace(/[^0-9]/g, "");}
function nav(){
   var w = document.qsearch.xfer.selectedIndex;
   var url_add = document.qsearch.xfer.options[w].value;
   window.location.href = url_add;}
function propertyIdRedirect() {
  new_url = "http://prop.servercast.org.ua/listing/details/";
  new_url += document.getElementById('property_id').value;
  location.href=new_url;
  return false;
}
function nextTab() {
	
	$current_t = $('#ctabs li.current');
	$next_t = $('#ctabs li.current').next();
	
	$current_sel_t = $('#tabs li.current');
	$next_sel_t = $('#tabs li.current').next();
	
	
	if($next_t.children('ul').attr('class') == undefined) {
		$next_t = $("#ctabs li:first");
		$next_sel_t = $('#tabs li:first');
	} else {
		//Do nothing. The $next element exists
	}
	
	$next_t.addClass('next').css({ opacity: 0 }).stop().animate({ opacity: 1 }, 300, function() {
																							
		$next_t.addClass('current').removeClass('next');
		$current_t.removeClass('current');
																							
	});
	
	$current_sel_t.removeClass('current');
	$next_sel_t.addClass('current');
	
}

function autoTab() {
	
	$('#tabs li:first').addClass('current');
	$('#ctabs li:first').addClass('current');
	
	$i = 1;
	$('#tabs li').each(function() {
								
		$(this).attr('id', 'tab_'+$i);
		
		$i++;
								
	});
	
	$i = 1;
	$('#ctabs li:not(ul.ctabs_sid li)').each(function() {
								
		$(this).attr('id', 'ctab_'+$i);
		
		$i++;
								
	});
	
	$('#tabs li').click(function() {
								 
		if($(this).attr('class') == 'current') {
			
			
			
		} else {
			
			$id = $(this).attr('id').split('_');
			
			callTab($id[1]);	
			
		}
	});
	
}

function callTab($id) {
	
	$current_t = $('#ctabs li.current');
	$next_t = $('#ctabs li#ctab_'+$id);
	
	$current_sel_t = $('#tabs li.current');
	$next_sel_t = $('#tabs li#tab_'+$id);
		
	$current_t.slideUp(250, function() {
									 
		$(this).removeClass('current');							 
									 
	});
	
	$next_t.slideDown(400).addClass('current').removeClass('next');
	
	$current_sel_t.removeClass('current');
	$next_sel_t.addClass('current');
	
}

