$(document).ready(function(){
	
	if( $('#searchform #s').length )
	{
		$('#searchform #s').click( function() {
			
			$(this).val("");
			
		} )
	}
	/*
	if($('#en').length)
	{
		$('#en').click(function(){
			alert('The English version is currently unavailable. We are working on having it ready as soon as possible. Thank you.');
			return false;
		})
	}
	
	if($('#ro').length)
	{
		$('#ro').click(function(){
			return false;
		})
	}
	*/
	
	if( $('.homepage .box').length )
	{
		var i=1;
		$('.box').each(function() {
			$(this).attr('id', 'box' + i);
			i++;
			$(this).prepend('<div class="top"></div>');
			$(this).append('<div class="bottom"></div>');
		})
	}
	
	/*-------------------------------menu divider--------------------------------*/
	$('#menu li:not(:last)').each(function(){
		$(this)	.append('<span class="divider"></span>');
	})
	/*-------------------------------menu divider--------------------------------*/
	
	$('#side_menu ul ul').hide();
	$('#side_menu ul li.current_page_item ul').show();
	// $('#side_menu ul li a').hover(function(){
		// $(this).parent().find('ul').slideToggle(300);
	// });
	
	//$('#side_menu .children .children').hide();
	
	$('.current_page_ancestor .children').show();
	$('.current_page_item ul ul').hide();
	
	/*-------------------------------more btn--------------------------------*/
	$('.more').each(function(){
		$(this).html("<span class='more_left'></span><span>" + $(this).html()+ "</span><span class='more_right'></span>")
	})
	/*-------------------------------more btn--------------------------------*/
	
	/*
	$().ready(function() {
		$('#video_slider').codaSlider();
	});
	
	$().ready(function() {
		$('#news_slider').codaSlider();
	});
	*/
	
	if($('#judet'))
	{
		if($('#judet').val() == '')
		{
			$('#judet').change(function()
									{
								  getSubcategories( $('#judet').val(), $('#judet') ) 
									}
								  );
		}else
		{

			getSubcategories($('#judet').val(), $('#judet'));
			$('#judet').change(function()
									{
								  getSubcategories( $('#judet').val(), $('#judet') ) 
									}
								  );
		}
	}
	
})


function getSubcategories(id, elParent)
{	
	var id_get = 0;
	if(getGetVar('id'))
	{
		id_get = getGetVar('id');	
	}
	$('#localitate').empty();
	$('#localitate').append('<option value=""> alege localitate</option>');
	$.getJSON("/wp-content/plugins/specialisti/get/localitati.php?id=" + id, function(json){
		$.each(json, function(i, item)
		{
			$('#localitate').append('<option value=' + item.id + '> ' + item.oras + '</option>');
		})
	})

}

function getGetVar(getvar)
{
	var $_GET = {};

	document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
		function decode(s) {
			return decodeURIComponent(s.split("+").join(" "));
		}
	
		$_GET[decode(arguments[1])] = decode(arguments[2]);
	});
	
	return ($_GET[getvar]);
}
