/*	Revoltz JS, Framework
	This code is copyright (c) Ernesto Mendez 2010.
	http://der-design.com */

$ = jQuery;

function get_metavar(meta) {

	var selector = 'meta[name=' + meta + ']';

	return $(selector).attr('content');

}

function append_slash(url) {

	url += ( url[url.length-1] != '/' ) ? '/' : '';

	return url;

}

function add_action(where, callback) {

	try { hooks; } catch(e) { hooks = []; }

	if ( ! hooks[where] ) { hooks[where] = []; }

	hooks[where].push(callback);
	
}

function do_action(where) {

	try { hooks } catch(e) { return false; }

	if ( ! hooks[where] )  { return false; }

	for ( var i in hooks[where] ) {

		var c = hooks[where][i];

		c();

	}
}

function is_ie7() {
	
	return (navigator.appVersion.indexOf("MSIE 7.")==-1) ? false : true;
	
}

function is_ie8() {
	
	return (navigator.appVersion.indexOf("MSIE 8.")==-1) ? false : true;

}

function maxval(values) {

	var max = 0;

	for ( var i in values ) {

		max = ( values[i] >= max ) ? values[i] : max;

	}

	return max;

}

function cycle(increment, current, length) {

	increment = parseInt(increment);

	current = parseInt(current);

	length = parseInt(length);

    var pos = current + increment;

    if (pos == 0) {return length;}

    if (pos > length) {return 1;}

    return pos;
	
}

function basename(url) {

	url = url.split('/');

	name = url[url.length-1];

	return name;
}

function common_lib_functions() {

	$('a[rel=_blank]').attr('target', '_blank');

}