toggleRoof = function()
{
	var s = $('#loginForm');
	var h = $('#show');
	h.bind("click", function(e)
		{
			$(s).slideToggle();
			if(h.text() == 'Show') h.text('Hide');
			else if (h.text() == 'Hide') h.text('Show');
		}
	);
}

toggleShowHide = function(handle, element, txtShow, txtHide, showIcons) {
	if($(element).css('display') == "none")
	{
		$(element).show();
		if(showIcons == 1)
		{
			$(handle).html('<img src="' + homepageUrl + 'images/ifc/icons/close.gif" alt="' + txtHide + '" /> ' + '<span>' + txtHide + '</span>');
		} else {
			$(handle).html(txtHide);
		}
	} else  {
		$(element).hide();
		if(showIcons == 1)
		{
			$(handle).html('<img src="' + homepageUrl + 'images/ifc/icons/show.gif"  alt="' + txtShow + '" /> ' + '<span>' + txtShow + '</span>');
		} else {
			$(handle).html(txtShow);
		}
	}
};


searchtext = function()
{
	var box = $("#q");
	box.focus( function() { if(box.val() == 'search') { box.val(''); } });	
	box.blur(function(){ if(box.val() == '') { box.val('search'); } });	
}

showFull = function(id) {
	$("#abstract_" + id).toggle();
	$("#abstract_" + id + "_full").toggle();
}

switchDisplay = function ()
{
	$("a#english").click(function () { 
      $("#pageLeft").css('width', '100%').show();
      $("#pageRight").hide();
    });
    
	$("a#serbian").click(function () { 
      $("#pageLeft").hide();
      $("#pageRight").css('width', '100%').show();
    });
    
    $("#both").click( function()
    {
      $("#pageLeft").css('width', '48%').show();
      $("#pageRight").css('width', '48%').show();
    });
}


String.prototype.toPHP = function() 
{ 
	var s = this;
	s=s.replace(/\\/g, "\\\\");
	s=s.replace(/\"/g, "\\\"");
	s=s.replace(/\n/g, "\\n");
	s=s.replace(/\r/g, "");
	return 's:'+s.length+':"'+s+'";'
}

toggleAbstract = function ()
{
	$("a.abstractHandle").click(function () { 
		var id = $(this).attr("id");
		$("#text_"+id).toggle();		
		if($(this).text() == 'show abstract')
		{
			$(this).text('hide abstract');
			$(this).css('background', 'url(/resources/images/icons/hide.gif) no-repeat right 0');
		} else {
			$(this).text('show abstract');
			$(this).css('background', 'url(/resources/images/icons/show.gif) no-repeat right 0');
		}
    });
    
}


showLoading = function()
{
	$("#loading").slideDown();
}


$(window).ready(function()
{
	toggleRoof();
	searchtext();
	switchDisplay();
	toggleAbstract();
	if($('a[class*=faceboxLink]').html() != null)
	{
		$('a[class*=faceboxLink]').facebox();
	}
	
});