var uc = uc || {};
uc.common = uc.common || {};

//Ajaxify content
uc.common.ajaxify = function (timeout) {
	if (timeout == null) timeout = 0;	
	uc.utils.ajaxifyLink(jQuery('a.ajax-post'), 'POST', function() {uc.common.ajaxify();});
	uc.utils.ajaxifyLink(jQuery('a.ajax'), 'GET', function() {uc.common.ajaxify();});
	uc.utils.ajaxifyLink(jQuery('.ajax a'), 'GET', function() {uc.common.ajaxify();});
	uc.utils.ajaxifyForm(jQuery('form.ajax'), function() {uc.common.ajaxify();});
}

uc.common.initplayer = function(swflocation) {
	jQuery(document).ready(function() {
		// Instantiate all flow player
		flowplayer(".player-item", swflocation,
			{
				// configuration for a clip
				clip: {
					autoPlay: true,
			    	autoBuffering: true,
			    	scaling: 'fit'
				},
				// setup controlbar to use skins
				plugins: {
				  	controls: conf.skins.universcine
				}
			});
	});
}

// Process document after its loading
jQuery(document).ready(function() {
	// Ajaxify
	uc.common.ajaxify(200);
	
	// Add help feature to input text
	jQuery('input.help[type=text]').each(function(index) {
		var jq_this = jQuery(this);
		var help = jq_this.val();
		jq_this.focus(function() {if (jq_this.val() == help) jq_this.val('');});
		jq_this.blur(function() {if (jq_this.val() == '') jq_this.val(help);});
		
		var form = jq_this.parents("form:eq(0)");
		if(form) {
			form.submit(function() {if (jq_this.val() == help) return false; else return jq_this.val().length!=0;});
		}
		
	});

});

