
var contentZoom = new TextZoom (
	    "menuTop", // Reference element
	    "contentZ", // Target element
	    0.1, // Zoom ratio
	    100, // Minimum font size (%)
	    120
    ); // Maximum font size (%)
	

// removes html text element and replaces with an image tag
function loadImageHeader(cssClass, size, color){		
	items = $(cssClass);
	items.each(function(){
		txtString = $(this).html();
		width = $(this).innerWidth();
		txtString = escape(txtString);
		if (txtString.length > 0) {
			$(this).after("<img  class='blocked' src='/image.php?color=" + color +"&text=" + txtString +"&size=" + size +"&width="+width+"'>").remove();	
		}
	});
	
}

function candOnline(id){
	if (id > 0) {
		window.open ("/candidatura.php?cid="+ id ,"candidaturas","resizable=1,width=680,height=350");	
	}
	else {
		window.open ("/candidatura.php","candidaturas","resizable=1,width=680,height=350");
	}
	
	
	return false;
}

// Reads text from inside HTML tag and puts image inside, without removing
function loadImageLink(cssClass, size, color, caps, fontF){		
	items = $(cssClass);
	
	items.each(function(){
		txtString = $(this).html();
		if (caps == "capitalise") {
			caps2 = "true";
		}
		else {
			caps2 = "false";
		}
		if (fontF.length) {
			fontAdd = "&font="+fontF;
		}
		
		width = $(this).innerWidth();
		txtString = escape(txtString);
		if (txtString.length > 0) {
			$(this).html("<img class='blocked' src='/image.php?color=" + color +"&text=" + txtString +"&size=" + size +"&width="+width+"&caps="+caps2 + fontAdd + "'>");	
		}	
	});
	
}


// Homepage scroller
function resetVis(){
	$(".courseHead").stop().slideDown();
	$(".cList").stop().slideUp();
	$("#resetVis").stop().slideUp();
	$("#hpzoom").animate({"width":"165px"},500);
}

function swapCourse(){
	cID = $(this).attr("rel");
	
	if($(".cList[rel="+cID+"]").is(":visible")){
		$("#hpzoom").animate({"width":"165px"},500);
		$("#leftc").animate({"width":"250px"},500);
		$(".courseHead").stop().slideDown();
		$(".cList[rel="+cID+"]").stop().slideUp();
		$("#resetVis").stop().slideUp();
		return;
	}
	else {
		$(".courseHead:not([rel="+cID+"])").stop().slideUp();
		$("#hpzoom").animate({"width":"400px"},500);
		$("#leftc").animate({"width":"500px"},500);
		$("#hpScroll .cList:not([rel="+cID+"])").stop().slideUp();
		$("#hpScroll .cList[rel="+cID+"]").stop().slideDown();
		$("#resetVis").stop().slideDown();	
	}
}


function swapDestaque(){
	cID = $(this).attr("rel");
	
	if($(".cList[rel="+cID+"]").is(":visible")){
		
		$(".courseHead").stop().slideDown();
		$(".cList[rel="+cID+"]").stop().slideUp();
		$("#resetVis").stop().slideUp();
		return;
	}
	else {
		
		$(".courseHead:not([rel="+cID+"])").stop().slideUp();
		$("#destaque .cList:not([rel="+cID+"])").stop().slideUp();
		$("#destaque .cList[rel="+cID+"]").stop().slideDown();
		$("#resetVis").stop().slideDown();	
	}
}
	
$(document).ready(function() {
	$(".iconLeft img").click(function(){
		window.location = "/";
	});
	$("#hpScroll .courseHead:not([rel=mba])").click(swapCourse);
	$("#destaque .courseHead").click(swapDestaque);
	
	textZoomInit();	
});

