function isNumeric(test){
    if(test != parseInt(test)){
        return false;
    }else{
        return true;
    }
}

function trim (myString){
    return myString.replace(/^s+/g,'').replace(/s+$/g,'')
}

var myEffect;
function playCarousel(dir){
    if($('carousel_items_container').offsetWidth >= $('carousel_container').offsetWidth){
        var diffX = ($('carousel_container').offsetWidth - $('carousel_items_container').offsetWidth);

        myEffect = new Effect.Move('carousel_items', {
            duration: 5.0,
            x: (diffX * dir),
            y: 0,
            transition: Effect.Transitions.linear
        });

        setTimeout( 'playCarousel('+ (dir * -1) +')', 6000 );
    }

}

// JavaScript Document

// DropDownMenu by Miha Hribar
// http://hribar.info
function prepareMenu() {
    // first lets make sure the browser understands the DOM methods we will be using
  	if (!document.getElementsByTagName) return false;
  	if (!document.getElementById) return false;

  	// lets make sure the element exists
  	if (!document.getElementById("menu")) return false;
  	var menu = document.getElementById("menu");

  	// for each of the li on the root level check if the element has any children
  	// if so append a function that makes the element appear when hovered over
  	var root_li = menu.getElementsByTagName("td");
  	for (var i = 0; i < root_li.length; i++) {
  	    var li = root_li[i];
  	    // search for children
  	    var child_ul = li.getElementsByTagName("ul");
  	    if (child_ul.length >= 1) {
  	        // we have children - append hover function to the parent
  	        li.onmouseover = function () {
  	            if (!this.getElementsByTagName("ul")) return false;
  	            var ul = this.getElementsByTagName("ul");
  	            ul[0].style.display = "block";
  	            return true;
  	        }
  	        li.onmouseout = function () {
  	            if (!this.getElementsByTagName("ul")) return false;
  	            var ul = this.getElementsByTagName("ul");
  	            ul[0].style.display = "none";
  	            return true;
  	        }

                if (!li.getElementsByTagName("li")) return false;
                var child_li = li.getElementsByTagName("li");
                if(child_li.length > 1){
                    for (var j = 0; j < child_li.length; j++) {
                        var li2 = child_li[j];
                        if (li2.getElementsByTagName("ul")) {
                            var child2_ul = li2.getElementsByTagName("ul");
                            if (child2_ul.length >= 1) {
                                var w = (li2.parentNode.getWidth() - 10)  +"px";
                                child2_ul[0].style.marginLeft  = w;
                            }
                        }
                    }
            }
  	    }

  	}

  	return true;
}

