last_section = false;

if (document.images) {
	var last_rollover = null;
	var last_src;
	var loaded  = false;
	
	home_r = new Image(142,33);
	home_r.src = "/es/img/common/nav/home_r.gif";
	
	get_r = new Image(284,33);
	get_r.src = "/es/img/common/nav/get_r.gif";
	
	more_r = new Image(284,33);
	more_r.src = "/es/img/common/nav/more_r.gif";
	
	reviews_r = new Image(142,33);
	reviews_r.src = "/es/img/common/nav/reviews_r.gif";
	
	contact_r = new Image(142,32);
	contact_r.src = "/es/img/common/nav/contact_r.gif";
	
	partner_r = new Image(142,32);
	partner_r.src = "/es/img/common/nav/partner_r.gif";
		
	loaded = true;
}

function rollover(imgName) {
	if (loaded) {
		currImage = document.getElementById(imgName);
		newImage = eval(imgName + "_r");
		if ((typeof currImage == 'object') && (typeof newImage == 'object')) {
			last_rollover = currImage;
			last_src = last_rollover.src;
			last_rollover.src = newImage.src;
		}
	}
}

function rollout() {
	if (loaded && last_rollover) {
		last_rollover.src = last_src;
		last_rollover = null;
	}
}

function openWin(url, width, height, winName) {
	window.open(url, winName, 'toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, width=' + width + ', height=' + height);
}
function openRevWin(url, width, height, winName) {
	window.open(url, winName, 'toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=1, width=' + width + ', height=' + height);
}

function close_window() {
	window.close();
}

function passwordFocus(oInput) {
	oInput.style.display = 'none';
	oInput.form.password.style.display = 'inline';
	oInput.form.password.focus();
}

function highlight_text(section) {
	lowlight_text();
	last_section = document.getElementById(section);
	last_section.style.backgroundColor = "#dddddd";
	document.location = "#" + section;
}

function lowlight_text() {
	if (last_section) {
		last_section.style.backgroundColor = "#ffffff";
		last_section = false;
	}
}

function nav_top() {
	lowlight_text();
	document.location = "#top";
}

function writeFlash(id, path, width, height, imgpath, alt) {
	path = '/es/' + path;
	flash = '';
	if (MM_FlashCanPlay) {
		flash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
		flash += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"';
		flash += ' id="' + id + '"';
		flash += ' width="' + width + '"';
		flash += ' height="' + height + '">';
		flash += '<param name="movie" value="' + path + '">';
		flash += '<param name="quality" value="best">';
		flash += '<param name="bgcolor" value="#ffffff">';
		flash += '<param name="wmode" value="transparent">';
		flash += '<embed src="' + path + '"';
		flash += ' quality="best"';
		flash += ' bgcolor="#ffffff"';
		flash += ' wmode="transparent"';
		flash += ' width="' + width + '"';
		flash += ' height="' + height + '"';
		flash += ' name="' + id + '"';
		flash += ' type="application/x-shockwave-flash"';
		flash += ' pluginspace="http://www.macromedia.com/go/getflashplayer">';
		flash += '<\/embed>';
		flash += '<\/object>';
	} else {
		flash += '<img src="/es/swf/' + imgpath + '" width="' + width + '" height="' + height + '" border="0" alt="' + alt + '" />';
	}
	document.write(flash);
}

var MM_contentVersion = 5;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if (plugin) {
	var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	for (var i = 0; i < words.length; ++i) {
		if (isNaN(parseInt(words[i])))
			continue;
		var MM_PluginVersion = words[i];
	}
	var MM_FlashCanPlay = (MM_PluginVersion >= MM_contentVersion);
} else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE") >= 0 && (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}

function GoToLanguage(selObj){

        var loc= selObj.options[selObj.selectedIndex].value;

        if (loc) {
                document.location = loc;
        } else {
                selObj.selectedIndex = 0;
        }
}

function gotoCountry(countryOptions) {

	var location = countryOptions.options[countryOptions.selectedIndex].value;
	
	if (location) {
		document.location = location;
	} else {
		countryOptions.selectedIndex = 0;
	}
}

function preSelectCountry() {
	var countryOptions = document.getElementById('country');

	if (!countryOptions)
		setTimeout("preSelectCountry()", 1000);

	var i;
	for (i = 0; i < countryOptions.length; i++) {
		if ("US" == right(countryOptions.options[i].value, 2)) {
			countryOptions.selectedIndex = i;
		}
	}

	var quicksetupOptions = document.getElementById('qsCountry');
	if (quicksetupOptions) {
		var c = 0;
		for (c = 0; c < quicksetupOptions.length; c++) {
			if ("US" == quicksetupOptions.options[c].value) {
				quicksetupOptions.selectedIndex = c;
			}
		}
	}
}

function right(str, n) {

	if (n <= 0)
		return "";
	else if (n > String(str).length)
		return str;
	else {
		var iLen = String(str).length;
		return String(str).substring(iLen, iLen - n);
	}
}

function shopSelectCountry(countryOptions) {
	var mode = document.getElementById('mode');
	mode.value = 'update';
	countryOptions.form.submit();
}

function showSecurityCodeInfo() {
	openWin('/es/securityCodeInfo.php', 640, 370, 'securityCodeInfo');
}

function toggleNav() {
	if (document.getElementById('togglenav').style.display == 'none') {
		document.getElementById('togglenav').style.display = 'inline';
		document.getElementById('showsearch').style.display = 'none';

	} else {
		document.getElementById('showsearch').style.display = 'none';
		document.getElementById('togglenav').style.display = 'all'
	}

}

function togglePass() {
	document.getElementById('passtoggleoff').style.display = 'inline';
	document.getElementById('passtoggleon').style.display = 'none';
}
