var swfObject = {
	insert: function(swf, swfId, swfWidth, swfHeight, swfVersion, swfBackgroundColor, targetElm, imgSrc){
		var so = new SWFObject(swf, swfId, swfWidth, swfHeight, swfVersion, swfBackgroundColor);
		
		if(imgSrc != undefined){
			so.addVariable("src", imgSrc);
		}
		so.addParam("wmode", "transparent");
		so.write(targetElm);
	}
}

var printObj = {
	addPrint: function(targetElm){
		var targetURL = $("#"+targetElm).attr("href");
		$("#"+targetElm).click(function(){
			printObj.printWindow(targetURL, 500, 600); 
			return false;
		});
	},
	
	printWindow: function(targetURL, w, h, pagetitle, pType) {
		/* set popheight and width */
		var popup_height = h;
		var popup_width = w;	
	
		/* Center popup window */
		var intwidt;
		var intheight;
		
		intwidth = screen.availWidth;
		intheight = screen.availHeight;
		intwidth = parseInt (intwidth);
		intheight = parseInt (intheight);
		
		var w = window.open(targetURL, '' ,'height=' + popup_height + ',width=' + popup_width + ',toolbar=no,scrollbars=yes')
	
		target = w.document;
		
		if (intwidth > 0 && intheight > 0){
			w.moveTo ( ( ( intwidth-popup_width ) / 2 ), ( ( intheight - popup_height ) / 2) );
		}
		w.focus();
	}
}

/* replace date selectboxes & adds calendar widget */
var dateField = {
	replace: function(targetDiv, model, field){
		$("."+targetDiv).empty().append('<input id="'+model.concat(field)+'" class="date date-pick" type="text" value="" name="data['+model+']['+field.toLowerCase()+']" />');
		dateField.addCall();
	},
	addCall: function(){
		$('.date-pick').datePicker({clickInput:true})
	}
}

$(document).ready(function(){
	//validateForm("JobAddForm");
	//validateForm("JobEditForm");
	//validateForm("SpecialistAddForm");
	
	$('.organisaties').mouseover(function(){
		$(".kandidaten").removeClass('active');
		$(this).addClass('active');
	});

	$('.kandidaten').mouseover(function(){
		$(".organisaties").removeClass('active');
		$(this).addClass('active');
	});
	
	/* form validation */
	/*function validateForm(formId){
		if(document.getElementById(formId)){
			jQuery.validator.messages.required = "";
			jQuery.validator.messages.email = "";
	
			if(document.getElementById(formId)){
				//$.metadata.setType("attr", "validate");
				var validator = $("#"+formId).bind("invalid-form.validate", function() {
					//$("#form-message").html("Het formulier bevat " + validator.numberOfInvalids() + " fouten.");
					$("#form-message").hide();
				}).validate({
					//errorElement: "em",
					//errorContainer: $("#form-message"),
					//errorPlacement: function(error, element) {
					//	error.appendTo(element.parent("div"));
					//}
				});
			}
		}
	}*/
	
	/* progessive enhanced hovers ;) */
	if(document.getElementById("submit")){
		document.getElementById("submit").onmouseover = function(){
			this.src='/img/form_submit_hover.jpg';
		}
		document.getElementById("submit").onmouseout = function(){
			this.src='/img/form_submit.jpg';
		}
	}
	
});
