/* IE6 flicker fix
-------------------------------------------------- */
try { document.execCommand("BackgroundImageCache", false, true); } catch(e){}

var dom = {
	ce: function(name, cls, html) {
		var el = document.createElement(name);
		$(el).addClass(cls).html(html);
		return $(el);
	},
	
	add_opt: function(sel_obj, text, val) {
		opt = new Option(text, val);
		o = sel_obj.get(0);
		o.options[o.options.length] = opt;
		return sel_obj;
	}

}
 
function is_numeric(num) {
	s = new String(num);
	if (!isNaN(s/1)) { 
		return true;
	} else {
		if (!s.length) { return false; }
		s = s.replace(",", ".");
		return (!isNaN(s/1));
	}
}
function redirect(url) {
	if (url.indexOf('://')==-1) {
		url = 'http://'+url;
	}
	window.location.href = url;
}
var tabControl = {
	init: function(tab) {
		$('ul.tabs:not(.no_js)').hide();
		$('.tabs>li>a:not(.no_js)').each(function() {
			$(this).click(function(){ tabControl.activate($(this)); });
		});
		if(tab===undefined) {
			tab = 1;
		}
		setTimeout(function() {
			$('.tabs>li>a[rel=tab_el_'+tab+']:not(.no_js)').click();
			$('ul.tabs:not(.no_js)').show();
		}, 200);
	},
	clear: function() {
		$('.tabs>li>a:not(.no_js)').each(function() { $(this).removeClass("active");});
		$('.tabContainer').each( function() { $(this).hide(); });
	},

	activate: function(obj) {
		if (typeof obj == 'number') {
			obj = $('.tabs>li>a[rel=tab_el_'+obj+']:not(.no_js)');
		}
		this.clear();
		obj.addClass("active");
		$("#"+obj.attr('rel')).show();
	}




}

/* Togglers */

function toggleId(id) {
    $(id).style.display = ($(id).style.display == "none") ? "" : "none";
}

function toggleItems() {
	$A(toggleItems.arguments).each(function(id){
	    toggleId(id);
	});
}

function HasClassName(objElement, strClass){
	if ( objElement.className ){
		var arrList = objElement.className.split(' ');
		var strClassUpper = strClass.toUpperCase();
		for ( var i = 0; i < arrList.length; i++ ){
			if ( arrList[i].toUpperCase() == strClassUpper ){
				return true;
			}
		}
	}
   return false;
}

/* Class manipulation */

function AddClassName(objElement, strClass, blnMayAlreadyExist){
	if ( objElement.className ){
		var arrList = objElement.className.split(' ');
		if ( blnMayAlreadyExist ){
			var strClassUpper = strClass.toUpperCase();
			for ( var i = 0; i < arrList.length; i++ ){
				if ( arrList[i].toUpperCase() == strClassUpper ){
					arrList.splice(i, 1);
					i--;
				}
			}
		}
		arrList[arrList.length] = strClass;
		objElement.className = arrList.join(' ');
	} else {
		objElement.className = strClass;
	}
}

function RemoveClassName(objElement, strClass){
	if ( objElement.className ){
		var arrList = objElement.className.split(' ');
		var strClassUpper = strClass.toUpperCase();
		for ( var i = 0; i < arrList.length; i++ ){
			if ( arrList[i].toUpperCase() == strClassUpper ){
				arrList.splice(i, 1);
				i--;
			}
		}
		objElement.className = arrList.join(' ');
	}
}

