/**
* Kryffo JavaScript stuff.
* @author NOSE
*/
var KRYFFO = {
	
	/**
	* Initialize.
	*/
	initReady: function() {
		KRYFFO.initValidation();
		KRYFFO.initBlowup();
		//KRYFFO.initExternalLinks();
		KRYFFO.initPrintLinks();
	},
	initLoad: function() {
	},
	
	/**
	* Initialize the validation.
	*/
	initValidation: function() {
		var vforms = jQuery(".validate");
		if (vforms.size() > 0 ) {
			// rules
			var rules = new ValidatorRuleCollection();
			
			rules.add('validator-required', 'Eingabe erforderlich.', function(fieldValue, fieldObj) {
				if (fieldValue == "")	return false;
				return true;
			});
			
			rules.add('validator-email', 'Ung&uuml;ltige Email Adresse.', function(fieldValue, fieldObj) {
				if (fieldValue == "")	return true;
				return /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(fieldValue);
			});
			// validator
			jQuery(vforms).validationAideEnable(rules, {showSummary:true,summaryMessage:"Bitte erg&auml;nze folgende Angaben:"});	
		}
	},
	
	/**
	* Initialize the blowup.
	*/
	initBlowup: function() {
		jQuery("#content a").each(function(){
			var hr = jQuery(this).attr("href");
			var img = jQuery("img:first",this);
			if (hr) {
				if (hr.match(".jpg") || hr.match(".gif") || hr.match(".png") || hr.match(".JPG") || hr.match(".GIF") || hr.match(".PNG")) {
					jQuery(this).addClass("blowup");
					jQuery(this).attr("title",img.attr("title"));
				}
			}
		});
		jQuery(".blowup").blowup();
	},
	
	/**
	* Initializes the external links.
	*/
	initExternalLinks: function() {
		var internal = "http://www.la-grande-bouffe.ch";
		jQuery("#content a, #marginal a").each(function(){
			var h = jQuery(this).attr("href");
			var hs = h.substring(0,1);
			if (h.indexOf(internal) < 0 && hs != "/" && hs != "#") {
				jQuery(this).addClass("external");
				jQuery(this).attr("target","_blank");
				try {
					var t = jQuery(this).attr("title");
					jQuery(this).attr("title","Externer Link: " + t);
				}
				catch (ex) {
				}
			}
		});
	},
	
	/**
	* Initializes the print links.
	*/
	initPrintLinks: function() {
		jQuery(".print, .print a").bind("click",function(){
			window.print();
			return false;
		});
	}
}
jQuery(document).ready(function(){
	KRYFFO.initReady();
});
jQuery(window).bind("load",function(){
	KRYFFO.initLoad();
});



