function ocultar(){
document.getElementById('m-1').style.display="none";
document.getElementById('m-2').style.display="none"; 
document.getElementById('m-3').style.display="none"; 
document.getElementById('m-4').style.display="none";
document.getElementById('m-5').style.display="none";

if (browserHasFlashOverlayIssue())
	$('.flashToHide').show();
}

function ChangeClass(obj, new_style) {
    obj.className = new_style;
		
}

function mostrar(objeto){
ocultar()

if (browserHasFlashOverlayIssue())
	$('.flashToHide').hide();

for(i=1;i<=1;i=i+1){
document.getElementById('m-'+i).style.display="none";}
	if (document.getElementById(objeto).style.display == ""){
	document.getElementById(objeto).style.display="none"; 
	}
	else
	{
	document.getElementById(objeto).style.display=""; 
	}
}


/***********************************************
* Contractible Headers script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated Mar 23rd, 2004.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var enablepersist="off" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="yes" //Collapse previously open content when opening present? (yes/no)

//if (document.getElementById){
//document.write('<style type="text/css">')
//document.write('.switchcontent{display:none;}')
//document.write('</style>')
//}

function getElementbyClass(classname){
ccollect=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
}

function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

/* ******** */

var ignorePopClick = false;

function showpop(id) {
	expandcontent(id);

	$('#' + id).unbind('click');
	$('#' + id).click(function(e) {
		if (ignorePopClick) {
			ignorePopClick = false;
			return;
		} else
			contractcontent();
	});

	$('#' + id + ' div:first').click(function(e) {
		ignorePopClick = true;
	});
}

/* ******** */

function expandcontent(cid){
if (typeof ccollect!="undefined"){
if (collapseprevious=="yes")
contractcontent(cid)

$('#' + cid).show(300);
//document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "block"
}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_ac_onload(){

uniqueidn=window.location.pathname+"firsttimeload"
getElementbyClass("switchcontent")
if (enablepersist=="on" && typeof ccollect!="undefined"){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0" 
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
if (!firsttimeload)
revivecontent()
}

}

$(document).ready(function() {
	do_ac_onload();
});

/*
if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload
*/

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate



//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

/* ******** tool tip ********* */

// pre-load tool tip images
$(document).ready(function() {
	$('body').append('<div style="display: none;"><img src="/img/toolTipTop.gif" /><img src="/img/toolTipMid.gif" /><img src="/img/toolTipBtm.gif" /></div>');
});

$(document).ready(function() {
	$('.toolTip').hover(
		function() {
		this.tip = this.title;
		$(this).append(
			'<div class="toolTipWrapper">'
				+'<div class="toolTipTop"></div>'
				+'<div class="toolTipMid">'
					+this.tip
				+'</div>'
				+'<div class="toolTipBtm"></div>'
			+'</div>'
		);
		this.title = "";
		this.width = $(this).width();
		$(this).find('.toolTipWrapper').css({left:this.width-40})
		$('.toolTipWrapper').fadeIn(300);
	},
	function() {
		$('.toolTipWrapper').fadeOut(100);
		$(this).find('.toolTipWrapper').remove();
			this.title = this.tip;
		}
	);
});

/* ********* flash overlay issue in IE *********** */

function browserHasFlashOverlayIssue() {
	if ($.browser.msie) {
		var browserVer = new String($.browser.version);
		browserVer = browserVer.substr(0, (browserVer.indexOf('.') >= 0 ? browserVer.indexOf('.') : 0));
		if (browserVer <= 8)
			return true;
	}
	return false;
}

/* ********* sending indicator *********** */

// pre-load sending indicator
$(document).ready(function() {
	$('body').append('<div id="sendingIndicatorPopup" class="sendindBlock"><p align="center"><img src="/img/spinner.gif" /><br /><br />&nbsp;<span id="sendingIndicatorTxt">Sending...</span></p></div>');
});

function show_sending_indicator(txt) {
	if (txt)
		$('#sendingIndicatorTxt').text(txt);

    //Fade in the Popup
    $('#sendingIndicatorPopup').fadeIn(200).css({ 'width': 200 });

    //Define margin for center alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding  and border width defined in the css
    var popMargTop = ($('#sendingIndicatorPopup').height() + 80) / 2;
    var popMargLeft = ($('#sendingIndicatorPopup').width() + 80) / 2;

    //Apply Margin to Popup
    $('#sendingIndicatorPopup').css({
        'margin-top' : -popMargTop,
        'margin-left' : -popMargLeft
    });

    //Fade in Background
    $('body').append('<div id="sendindFade"></div>'); //Add the fade layer to bottom of the body tag.
    $('#sendindFade').css({'filter' : 'alpha(opacity=60)'}).fadeIn(200); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=60)'}) is used to fix the IE Bug on fading transparencies 
}

function hide_sending_indicator() { //When clicking on the close or fade layer...
    $('#sendindFade , .sendindBlock').fadeOut(200);
}

/* ********* modal popups *********** */

var popHideJs = '';
var popPreCloseJs = '';

var showModalPop = function(popURL, popID, popWidth, hideJs, preCloseJs) {
	popHideJs = hideJs;
	popPreCloseJs = preCloseJs;
	
	if (browserHasFlashOverlayIssue())
		$('.flashToHide').hide();

	var sizeFn = function() {
		//Define margin for center alignment (vertical   horizontal) - we add 40px to the height/width to accomodate for the padding  and border width defined in the css
		var popMargTop = ($('#' + popID).height() + 40) / 2;
		var popMargLeft = ($('#' + popID).width() + 40) / 2;
	
		//Apply Margin to Popup
		$('#' + popID).css({
			'margin-top' : -popMargTop,
			'margin-left' : -popMargLeft
		});
		// add close btn
		$('#' + popID).prepend('<a href="#" class="popupClose"><img src="/img/close_pop.png" class="popupClose" title="Close" alt="Close" /></a>');
	};

	var loadFn = function() {
		//Fade in the Popup
		$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) });

		//Fade in Background
		$('body').append('<div id="popupFade"></div>'); //Add the fade layer to bottom of the body tag.
		$('#popupFade').css({'filter' : 'alpha(opacity=60)'}).fadeIn(200); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=60)'}) is used to fix the IE Bug on fading transparencies 
		sizeFn();
	};

	if (popURL && popURL != '#') {  // if remote
		// add a div for the popup if doesn't exist
		if (!document.getElementById('modalPopup'))
			$('body').append('<div id="modalPopup" class="popupBlock"></div>');
		// clear the div
		$('#modalPopup').empty();
		$('#modalPopup').html('<div align="center"><img src="/img/spinner.gif" style="margin: 50px 0px;" /></div>');
		popID = 'modalPopup';
		loadFn();
		$.ajaxSetup({ cache: false });
		$.get(popURL, function(data) {
			$('#modalPopup').html(data);
			sizeFn();
		});
	} else
		loadFn();
};

var closeModalPop = function(spd) {
	if (popPreCloseJs) {
		eval(popPreCloseJs);
		popPreCloseJs = '';
	}
	if (spd == undefined) spd = 200;
	if (popHideJs || spd == 0) {
		$('.popupBlock').hide();
		$('#popupFade, a.popupClose').remove();
		if (browserHasFlashOverlayIssue())
			$('.flashToHide').show();
		if (popHideJs) { eval(popHideJs); popHideJs = ''; }
		return;
	}
	//Close Popups and Fade Layer
	$('#popupFade , .popupBlock').fadeOut(spd, function() {
		$('#popupFade, a.popupClose').remove();  //fade them both out
		if (browserHasFlashOverlayIssue())
			$('.flashToHide').show();
	});
};

$(document).ready(function() {
	//When you click on a link with class of modalPop 
	$('a.modalPop').click(function() {
		var popURL = $(this).attr('href'); //Get Popup url (if remote loaded)
		var popID = $(this).attr('popid'); //Get Popup Name (if local)
		var popWidth = $(this).attr('popwidth');
		var hideJs = $(this).attr('hidejs');
		var preCloseJs = $(this).attr('preclosejs');

		showModalPop(popURL, popID, popWidth, hideJs, preCloseJs);
		return false;
	});
	
	//Close Popups and Fade Layer
	$('a.popupClose, #popupFade').live('click', function() { //When clicking on the close or fade layer...
		closeModalPop();
		return false;
	});
});

/* ********* product selector wizard *********** */

var cfgPreSelList;

function showSelector(preSelList) {
	cfgPreSelList = new String(preSelList).split(',');

	if (!document.getElementById('selectorPop')) {
		show_sending_indicator('Loading Product Selector...');

		$.ajaxSetup({ cache: false });

		// load supporting javascript
		$.getScript('/js/popSelector.js', function(data, status) {
			// now load selector wizard
			$.get('/popSelector.php', function(data) {
				$('body').append(data);
				hide_sending_indicator();
				cfgReset();
				showModalPop('', 'selectorPop', '742', null, "$('.wizPage').hide();");  // preCloseJs needed for IE7
			});
		});
	} else {
		cfgReset();
		showModalPop('', 'selectorPop', '742', null, "$('.wizPage').hide();");  // preCloseJs needed for IE7
	}
}

/* ********* misc *********** */

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function clearform(form) {
	var elements, i, elm; 

	if (document.getElementsByTagName) {
		elements = form.getElementsByTagName('input');
		for( i=0, elm; elm=elements.item(i++); ) {
			if (elm.getAttribute('type') == "text")
				elm.value = '';
		}
		elements = form.getElementsByTagName('textarea');
		for( i=0, elm; elm=elements.item(i++); )
			elm.value = '';
	}
	// Actually looking through more elements here
	// but the result is the same.
	else {
		elements = form.elements;
		for( i=0, elm; elm=elements[i++]; ) {
			if (elm.value)
				elm.value ='';
		}
	}
}

function validatePassword(id) {
	if ($('#' + id).val().length < 8)
		return 'The password must be a minimum of 8 charcters.';
	if ($('#' + id).val().match(/\S \S/))
		return 'The password must not contain spaces.';
	if (!$('#' + id).val().match(/[A-Z]/))
		return 'The password must contain at least one uppercase letter.';
	if (!$('#' + id).val().match(/[a-z]/))
		return 'The password must contain at least one lowercase letter.';
	if (!$('#' + id).val().match(/[0-9!@#\$%\^&\*\(\)\-_\+=\{\[\}\]\|\\;:'\",\<\.\>\/\?]/))
		return 'The password must contain at least one number or symbol.';

	return '';
}

function validatePassword2(id1, id2) {
	var err = validatePassword(id1);
	if (err) return err;
	if ($('#' + id2).val() == '')
		return 'The password cannot be blank.';
	if ($('#' + id1).val() != $('#' + id2).val())
		return 'Both passwords must match.';
	
	return '';
}

function validateEmail(id) {
	if (!$('#' + id).val().match(/\S+\@\S+\.\S+/))
		return 'The email address does not appear to be valid.';

	return '';
}

function validateEmail2(id1, id2) {
	if (!$('#' + id1).val().match(/\S+\@\S+\.\S+/))
		return 'The email address does not appear to be valid.';
	if ($('#' + id2).val() == '')
		return 'The email address cannot be blank.';
	if ($('#' + id1).val() != $('#' + id2).val())
		return 'Both email addresses must match.';
	
	return '';
}

