/* OTYS JavaScript Repository */
/* Contains simple scripts which dont require advanced libarys */

/*
 * @Info : Fetch image and add it as background image to object.
 * @Created : 19/01/2011 - Maikel Doeze - OTYS Recruiting Technology
 * @Param : string
 * @Output : bool
*/
function SetBackground($v,$p)
{
	if($s = $($v).children('img').attr("src"))
	{
		$($p).css('background-image','url('+ $s +')');
		return true;
	}
}

/*
 * @Info : Replace crumblePath home text with other text or url
 * @Created : 15/06/2011 - Maikel Doeze - OTYS Recruiting Technology
 * @Param : string
 * @Param : string
 * @Param : string
 * @Output : bool
*/
function setCrumblePath($o,$t,$c)
{
	if($c)
	{
		$u = $c;
	}
	else
	{
		$u = $($o +" a:first-child").attr('href');
	}
	$($o +" a:first-child").replaceWith("<a href=\"" + $u + "\">"+$t+"</a>");
	return true;
}

/*
 * @Info : Jquery CrumblePath
 * @Created : 27/10/2011 - Maikel Doeze - OTYS Recruiting Technology
 * @Param : string
 * @Param : string
 * @Param : string
 * @Output : bool
*/
function createCrumblePath(mid,iid,hna)
{
	// Get all sub levels
	var c = new Array();
	c[0] = '<a href="[website]">'+hna+'</a>';
	c[1] = $(mid).find('.mainLevactive a').eq(0).clone();
	c[2] = $(mid).find('.mainLevactive .subLevel_1active a').eq(0).clone();
	c[3] = $(mid).find('.mainLevactive .subLevel_2active a').eq(0).clone();
	
	// Set links
	for(x in c)
	{
		$(c[x]).appendTo(iid);
	}
	
	$(iid).find('a:last-child').addClass('lastCrumble');
}
