
function requestSharebar(url)
{
	jQuery.get(url +'/sharebar.php', function(data) {
		jQuery('#sharebar_container').html(data);
		alert(data);
	})

}

function expandPost(id)
{
	
	
	var target = jQuery('#'+id);
	var targetBtn = jQuery('#'+id+'_button');
	if(target.css('display') == 'none')
	{
		target.slideDown('normal');
		if(targetBtn.text() == 'Expand info')
		{
			targetBtn.text('Hide info');
		}
		if(targetBtn.text() == 'Visa info')
		{
			targetBtn.text('Dölj info');
		}
	}
	else	
	{
		target.slideUp('normal');
		if(targetBtn.text() == 'Hide info')
		{
			targetBtn.text('Expand info');
		}
		if(targetBtn.text() == 'Dölj info')
		{
			targetBtn.text('Visa info');
		}
	}
}

function initHover(url)
{	
	/*jQuery('.project_screenshot').mouseenter(function()
	{
		alert("hejsan");
		//jQuery('this').html("ss");
	});
	jQuery('.project_screenshot').mouseleave(function()
	{
		//jQuery('this').html("");
	});*/
}


function is_touch_device() {  
  try {  
    document.createEvent("TouchEvent");  
    return true;  
  } catch (e) {  
    return false;  
  }  
}


jQuery(document).ready(function($)
{

	//alert(is_touch_device());

	var selectedImage = "";
	//$( 'ul.children' ).hide();
	
	if(!is_touch_device())
	{
		$('.main_menu li').hover(function()
		{
			
			var current = $(this).children('a');
			
			if(current.parent('li').attr('class').indexOf('top_item') != -1)
			{
				selectedImage = current.css('background-image');
				current.css('color','#FFF');
				current.css('background-image',selectedImage);
				current.css('background-repeat','repeat-x');
			}
			else if($(this).parent('ul').parent('li').attr('class').indexOf('top_item') != -1 && $(this).children('.children').size() > 0)
			{
				var childHeight = $(this).children('a').height();
				$(this).children('.children').children(':first-child').children('a').css('height',childHeight+'px');
			}
			
			$(this).children('.children').stop(true, true).show('fast');

		},function()
		{
			
			var current = $(this).children('a');
			
			if(current.parent('li').attr('class').indexOf('top_item') != -1)
			{
				current.removeAttr('style');
			}
			
			
			$(this).children('.children').stop(true, true).hide('fast');
			
			
		});
	}
	else
	{
		$('.main_menu li').click(function(e)
		{
			if($(this).children('.children').css('display') == 'none')
			{
				e.preventDefault();
				
				$('.main_menu li').each(function()
				{
					var current2 = $(this).children('a');
			
					if(current2.parent('li').attr('class').indexOf('top_item') != -1)
					{
						current2.removeAttr('style');
					}
					
					
					$(this).children('.children').stop(true, true).hide('fast');
					
				});
				
				var current = $(this).children('a');		
				if(current.parent('li').attr('class').indexOf('top_item') != -1)
				{
					selectedImage = current.css('background-image');
					current.css('color','#FFF');
					current.css('background-image',selectedImage);
					current.css('background-repeat','repeat-x');
				}
				else if($(this).parent('ul').parent('li').attr('class').indexOf('top_item') != -1 && $(this).children('.children').size() > 0)
				{
					var childHeight = $(this).children('a').height();
					$(this).children('.children').children(':first-child').children('a').css('height',childHeight+'px');
				}
				
				$(this).children('.children').stop(true, true).show('fast');
				
			}
			
			
			
		});
	}
	

});
