function getScrollWidth()
{
   var w = window.pageXOffset ||
           document.body.scrollLeft ||
           document.documentElement.scrollLeft;
           
   return w ? w : 0;
}

function getScrollHeight()
{
   var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;
           
   return h ? h : 0;
}

//this function returns an aray of elements with a given className
//optional:tagname to match combination
function getElementsByClassName (clsName){
	var retVal = new Array();
	var elements = document.getElementsByTagName("*");
	
	for(var i = 0;i < elements.length;i++){
		if(elements[i].className.indexOf(" ") >= 0){
			var classes = elements[i].className.split(" ");
			for(var j = 0;j < classes.length;j++){
				if(classes[j] == clsName) retVal.push(elements[i]);
			}
		}
	 	else if(elements[i].className == clsName) 
		retVal.push(elements[i]);
	}
	return retVal;
}


//this will add additional markup to tabs
function markUpTabs(){
	
}


function trim(value) {
	  value = value.replace(/^\s+/,'');
	  value = value.replace(/\s+$/,'');
	  return value;
}


function submitSearch(frm){
	alert('submit Search');
	return false;
}
var isIE;
function init(){
	isIE = navigator.appName.indexOf("Microsoft Internet Explorer") != -1;
	if(navigator.appName.indexOf("Microsoft Internet Explorer") != -1 && getInternetExplorerVersion() <=6){setTimeout("warnIE6();", 1000);}
	setButtons();
	setSmartInputs();
}


//change the opacity for different browsers
function changeOpac(objectID, opacity) {
	if(jQuery) {
		$("#"+objectID).css("opacity",opacity/100);
	} else {
	    var object = document.getElementById(objectID).style;
	    object.opacity = (opacity / 100);
	    object.MozOpacity = (opacity / 100);
	    object.KhtmlOpacity = (opacity / 100);
	    object.filter = "alpha(opacity=" + opacity + ")";
	}
} 

function toggle(id){
	var div = document.getElementById(id);
	if(div.offsetHeight == 0){
		div.style.display = "block";
	}
	else{
		div.style.display = "none";
	}
}

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

function warnIE6(){
	if(readCookie("IEwarned")!= "yes"){
		alert("Esta web es mucho más rápida y más satisfactoria usando:\n\n- Internet Explorer 7 o superior\n- FireFox 3 o superior\n- Opera 9 o superior\n- Safari 4 o superior\n- Chrome 3 o superior\n\nEstás usando Internet Explorer " + getInternetExplorerVersion() + ", que tiene varios problemas graves de seguridad.");
		createCookie("IEwarned", "yes", 7);
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}