//leegmaken van inputveld bij klikken

// break out of frameset! The framebuster
if (parent.frames.length > 0) { parent.location.href = self.document.location }

function clearText(theField){
	if(theField.value == theField.defaultValue){
		theField.value = "";
		theField.style.color = "#000000";
	}
}
//vullen van inputveld bij naast klikken
function setText(theField){
	if(theField.value == ""){
		theField.value = theField.defaultValue;
		theField.style.color = "#999999";
	}
}
// Controleren of er een user cookie is
function showUserInfo() {
	if ($.cookie('ACOM')) {
		$("#userQuickLogin").hide();
		$("#userInfo").show();
		$.AjaxCFC({
			url: "/controllers/userController.cfc",
			method: "getUsername",
			data: {},
			unnamedargs: false,
			success: function(data){ $("#userInfo span").text(' als: ' + data); }
		});
	}
}
function showMessage() {
	$("#message").fadeIn('slow')
		.animate({opacity: 1.0}, 3000)
		.fadeOut('slow', function() { $(this).remove();
		});
}
function showRegisterFormWindow() {
	if (!$("#registerWindow").length) {
		$(document.body).append($('<div id="registerWindow">'));
	}
	$("#registerWindow").load("/registerForm.htm", function(){
		$("#registerWindow").dialog({
			title : "Registreren bij Arbeidsmarkt.com",
			resizable: false,
			width : 350,
			heigth : 220,
			minWidth : 350,
			minHeight : 220
		});
		$("#registerWindow").show();
	});
}

$(document).ready(function(){
	showUserInfo();
	showMessage();
	$("#registerWindow").hide();
	$("dd").hide();
	/*$("dt").each(function(){ 
		$(this).click(function(){
			$("dd:visible").slideUp("slow");
			$(this).next("dd").eq(0).slideToggle("slow");
		});
	});*/
	
	/*$(".column").Sortable({
		accept:"box",
		handle:".top",
		helperclass:"spaceContainer",
		opacity:0.7,
		tolerance:"intersect"
	});*/
	
	//class toekennen aan actief menu-item
	$("#menu_2 a").each(function(){
		/*//huidige pagina checken in url
		url = document.location.href
		slash1 = url.indexOf("/")
		slash2 = url.indexOf("/",slash1+1)
		slash3 = url.indexOf("/",slash2+1)
		slash4 = url.indexOf("/",slash3+1)
		begin = url.indexOf("",slash3+1)
		end = url.indexOf("",slash3)
		end = url.indexOf("",slash4)
		page = url.substring(begin,end)
		if(slash4 == -1) page = url.substring(begin);
		if(page == "") page = "index.htm";
		
		//href checken in menu-item
		href = $(this).attr("href")
		firstChar = href.substring(0,1)
		lastChar = href.substring(href.length,href.length-1)
		first7Char = href.substring(0,7)
		if(firstChar == "/") href = href.substring(1);
		if(lastChar == "/") href = href.substring(0,href.length-1);
		slash1 = href.indexOf("/")
		if(first7Char !== "http://" && slash1 !== -1) href = href.substring(0,slash1);
		if(first7Char == "http://") href = href.substring(begin,end);
		if(href == "") href = "index.htm";*/
		
		//huidige pagina checken in url
		url = document.location.href
		end = url.indexOf(".")
		page = url.substring(0,end)
		
		//href checken in menu-item
		href = $(this).attr("href")
		end = href.indexOf(".")
		href = href.substring(0,end)
		
		//pagina en href vergelijken
		if(page == href) $(this).addClass("active");
	});
});



function addExternalLinks(pageLink,pageTitle,div){
	var str = '';
	str += '<a rel="nofollow" href="http://del.icio.us/post?url='+pageLink+'&amp;title='+pageTitle+'">';
	str += '<img src="/img/delicious.gif" alt="del.icio.us" title="Voeg toe aan del.icio.us">';
	str += '</a>';
	str += '<a rel="nofollow" href="http://digg.com/submit?phase=1&url='+pageLink+'&title='+pageTitle+'">';
	str += '<img src="/img/digg.gif" alt="digg" title="Voeg toe aan digg">';
	str += '</a>';
	str += '<a rel="nofollow" href="http://ma.gnolia.com/signin?add_url='+pageLink+'&title='+pageTitle+'">';
	str += '<img src="/img/magnolia.gif" alt="ma.gnolia" title="Voeg toe aan ma.gnolia">';
	str += '</a>';
	str += '<a rel="nofollow" href="http://nujij.nl/jij.lynkx?t='+pageTitle+'&u='+pageLink+'">';
	str += '<img src="/img/nujij.gif" alt="NUjij.nl" title="Voeg toe aan NUjij.nl">';
	str += '</a>';
	str += '<a rel="nofollow" href="http://reporter.msn.nl/?f=contribute&Title='+pageTitle+'&URL='+pageLink+'&cat_id=6&tag_id=13&ref=Arbeidsmarkt.com&amp;remark=&HL=BlogArticle">';
	str += '<img src="/img/msnreporter.gif" alt="MSN Reporter" title="Voeg toe aan MSN Reporter">';
	str += '</a>';
	$(div).html(str);
};
