﻿jQuery.fn.infoPopup = function(oParams) {
	var text 	= $(this).attr("title");
	
	if(oParams.pos == "L"){
		var div		= $("div.popup_infoL[@rel="+oParams.type+"]");
	} else {
		var div		= $("div.popup_info[@rel="+oParams.type+"]");
	}
	
	var cDiv	= div.find("div");
	var item	= $(this);
	var typeID	= oParams.typeID;
	
	item.removeAttr("title");
	
	item.hover(function() {
		cDiv.html(text);
		div.appendTo(item.parent());
		div.show();
	}, function() {
		div.hide();
		div.insertBefore($("#"+typeID));
	});
};

jQuery.fn.extend({
	
	initInfoPopups: function(pos) {
		if(!pos){
			pos="";
		}
		
		var thumbs 	= $(this).find("label.error img");
		var type	= $(this).attr("id")+"Display";
		var typeID	= $(this).attr("id");
		thumbs.each( function(i) {
			if($(this).attr("title")){
				$(this).infoPopup({"type":type,"typeID":typeID,"pos":pos});
			}
		});
	}
	
});

jQuery.fn.toggleDefault = function(text) {
	$(this).focus( function() {
		if ( $(this).val() == text ) {
			$(this).val("");
		}
	});
	$(this).blur( function() {
		if ( $(this).val() == "" ) {
			$(this).val(text);
		}
	});
};

$(document).ready(function() {
	
	// apply to all png images and to div#logo 
	$('img[@src$=.png], div#purple_beam, div#login_inner').ifixpng(); 
	
	//sifr fonts
	$.sifr({ 
		path: '/java/font'
	});
	
	$('h1').sifr( {
		font: 'Adobe Garamond',
		textAlign: 'left'
	});
	
	$('h2').sifr( {
		font: 'Adobe Garamond Italic',
		textAlign: 'left'
	});
	
	$('span.big').sifr({
		font: 'Adobe Garamond',
		textAlign: 'left',
		offsetTop: 5
	});
	
	$('span.midSize').sifr( {
		font: 'Adobe Garamond',
		textAlign: 'left'
	});
	
	$('#phrase').sifr( {
		font: 'Asenine',
		textAlign: 'left'
	});
	
	//shade balk resizing
	if($("div#shade").length > 0){
		$("div#shade").css("height", $("td#beam_left_border").height());
		$(window).resize( function() { $("div#shade").css("height", $("td#beam_left_border").height()) } );
	}
	
	$("input#v1").toggleDefault(YM_trans("E-mailadres"));
	$("input#v2").toggleDefault(YM_trans("Wachtwoord"));
	
});