$(document).ready(function(){

	$('a.show-lang').mouseover(function() {
	$("div#intlSelect").show("fast");
	$("a.show-lang").addClass('lang-on');
	return false;
	});
	
	$("div#intlSelect").hover(
      function () {
      }, 
      function () {
        $(this).hide('slow');
		$("a.show-lang").removeClass('lang-on');
      }
    );
	
	// set text field and textarea classes
	$("input[type='text'][class='']").addClass("input-text");
	$("textarea[class='']").addClass("input-textarea");
	
	// create moreinfo boxes
	var baseHtml = '<div class="moreInfo"><div class="tl"><div class="tr">&nbsp;</div></div><div class="content">{$mesh}</div><div class="bl"><div class="br">&nbsp;</div></div></div>';
	var meshSettings =
			{
				base:baseHtml,
				replace:true
			};
			
	$('p.moreInfo').meshtml(meshSettings);
	
	
});

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

Array.prototype.remove = function(from, to) {
  var rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  return this.push.apply(this, rest);
};

if(!Array.indexOf){
	Array.prototype.indexOf = function(obj){
		for(var i=0; i<this.length; i++){
			if(this[i]==obj){
				return i;
			}
		}
		return -1;
	}
}

function toInt ( x )
{
	return ( x > 0 ? Math.floor( x ) : Math.ceil ( x ) )
}

function changeControlCase(control) {
		for (i=0; i <document.getElementById(control).options.length; i++) {		
			var optionValue = document.getElementById(control).options[i].value;
			var lStr = optionValue.toLowerCase();
			var tStr = lStr.toTitleCase();
			var optionName;
			if(tStr == '') {
				optionName= new Option("Select...","", true); 
			}
			else{
				optionName = new Option(tStr, optionValue, false);
			}
			document.getElementById(control).options[i] = optionName ;			
		}
	}

	
String.prototype.toTitleCase = function() {
    return this.replace(/([\w&`'‘’"“.@:\/\{\(\[<>_]+-? *)/g, function(match, p1, index, title) {
        if (index > 0 && title.charAt(index - 2) !== ":" &&
        	match.search(/^(a(nd?|s|t)?|b(ut|y)|en|for|i[fn]|o[fnr]|t(he|o)|vs?\.?|via)[ \-]/i) > -1)
            return match.toLowerCase();
        if (title.substring(index - 1, index + 1).search(/['"_{(\[]/) > -1)
            return match.charAt(0) + match.charAt(1).toUpperCase() + match.substr(2);
        if (match.substr(1).search(/[A-Z]+|&|[\w]+[._][\w]+/) > -1 || 
        	title.substring(index - 1, index + 1).search(/[\])}]/) > -1)
            return match;
        return match.charAt(0).toUpperCase() + match.substr(1);
    });
};
