
function CheckPasswordFormat(source, arguments){
	
   var password = document.all.PinTextBox.value;
   var validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var validNumbers = "0123456789";
   var validAll = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
   var isValid = false;
   var hasChars = false;
   var hasNumbers = false;
   var hasAllValid = false;
   var char;

   for (i = 0; i < password.length; i++){ 
      
      char = password.charAt(i); 
      if (validChars.indexOf(char) != -1) 
      {
				hasChars = true;
      }
    }

   for (i = 0; i < password.length; i++){ 
      
      char = password.charAt(i); 
      if (validNumbers.indexOf(char) != -1) 
      {
				hasNumbers = true;
      }
    }
    
    for (i = 0; i < password.length; i++){ 
      
      char = password.charAt(i); 
      if (validAll.indexOf(char) != -1) 
      {
				hasAllValid = true;
      }
      else
      {
				hasAllValid = false;
      }
    }

   if (hasChars && hasNumbers && hasAllValid && password.length >= 8 && password.length <= 12)
   {
		isValid = true;
   }
    arguments.IsValid = isValid;

}

function showHideDIV(divName)
{
	el = document.getElementById(divName);
	if (el.style.display == 'none')
	{
		document.getElementById(divName).style.display = 'block';
	}
	else {
		document.getElementById(divName).style.display = 'none';
	}
}

/// <summary>
/// Opens the reports in a new window
/// Valentin Gosetto
/// </summary>
function OpenWindonReport(page){
	window.open(page, 'window', 'width=850, height=650, menubar=no, resizable=no, scrollbars=yes');
}


/// <summary>
/// Sends to the printer the page
/// Valentin Gosetto
/// </summary>
function PrintWindow(){
   bV = parseInt(navigator.appVersion)
   if (bV >= 4) window.print()
}

/// <summary>
/// Used in all pages
/// Disables the Enter key.
/// Valentin Gosetto - 23.Jan.2006
/// </summary>
function CheckKey()
{
	var pagePath = window.location.pathname;
	var pageName = pagePath.substring(pagePath.lastIndexOf('/') + 1);
	if (pageName != 'Login.aspx')
	{
		if (window.event.keyCode == 13)
			window.event.keyCode = null;
	}
}

function showDetails(action)
{
	var action;
	IE4 = (document.all && !document.getElementById) ? true : false;
	NS4 = (document.layers) ? true : false;
	IE5 = (document.all && document.getElementById) ? true : false;
	NS6 = (!document.all && document.getElementById) ? true : false;
		
	var link;
	link = action + "link";
	linkText = document.getElementById(link);
	linkText.firstChild.nodeValue;

	if (linkText.firstChild.nodeValue == "+")
	{
		linkText.firstChild.nodeValue = "- ";
	}
	else if (linkText.firstChild.nodeValue == "- ")
	{
		linkText.firstChild.nodeValue = "+";
	}
		
	linkText = document.getElementById(action);
	if (IE4) { prefix = document.all(arguments[0]).style; }
	if (NS6 || IE5) { prefix = linkText.style }
	if (NS4){ prefix = document.layers(arguments[0]); }

	if (prefix.display == "block")
	{
		prefix.display = "none";
	}
	else
	{
		prefix.display = "block";
	}
	
	////
	link = action + "lineup";
	linkText = document.getElementById(link);
	linkText.firstChild.nodeValue;

	if (linkText.firstChild.nodeValue == "+")
	{
		linkText.firstChild.nodeValue = "- ";
	}
	else if (linkText.firstChild.nodeValue == "- ")
	{
		linkText.firstChild.nodeValue = "+";
	}
		
	linkText = document.getElementById(link);
	if (IE4) { prefix = document.all(arguments[0]).style; }
	if (NS6 || IE5) { prefix = linkText.style }
	if (NS4){ prefix = document.layers(arguments[0]); }

	if (prefix.display == "block")
	{
		prefix.display = "none";
	}
	else
	{
		prefix.display = "block";
	}
	
	////
	link = action + "linedown";
	linkText = document.getElementById(link);
	linkText.firstChild.nodeValue;

	if (linkText.firstChild.nodeValue == "+")
	{
		linkText.firstChild.nodeValue = "- ";
	}
	else if (linkText.firstChild.nodeValue == "- ")
	{
		linkText.firstChild.nodeValue = "+";
	}
		
	linkText = document.getElementById(link);
	if (IE4) { prefix = document.all(arguments[0]).style; }
	if (NS6 || IE5) { prefix = linkText.style }
	if (NS4){ prefix = document.layers(arguments[0]); }

	if (prefix.display == "block")
	{
		prefix.display = "none";
	}
	else
	{
		prefix.display = "block";
	}
}

function showSubDetails(action)
{
	var action;
	IE4 = (document.all && !document.getElementById) ? true : false;
	NS4 = (document.layers) ? true : false;
	IE5 = (document.all && document.getElementById) ? true : false;
	NS6 = (!document.all && document.getElementById) ? true : false;
		
	var link;
	link = action + "sublink";
	linkText = document.getElementById(link);
	linkText.firstChild.nodeValue;

	if (linkText.firstChild.nodeValue == "+")
	{
		linkText.firstChild.nodeValue = "- ";
	}
	else if (linkText.firstChild.nodeValue == "- ")
	{
		linkText.firstChild.nodeValue = "+";
	}

	linkText = document.getElementById(action);
	if (IE4) { prefix = document.all(arguments[0]).style; }
	if (NS6 || IE5) { prefix = linkText.style }
	if (NS4){ prefix = document.layers(arguments[0]); }

	if (prefix.display == "block")
	{
		prefix.display = "none";
	}
	else
	{
		prefix.display = "block";
	}
	
	///
	var action;
	IE4 = (document.all && !document.getElementById) ? true : false;
	NS4 = (document.layers) ? true : false;
	IE5 = (document.all && document.getElementById) ? true : false;
	NS6 = (!document.all && document.getElementById) ? true : false;
		
	var link;
	link = action + "linedown";
	linkText = document.getElementById(link);
	linkText.firstChild.nodeValue;

	if (linkText.firstChild.nodeValue == "+")
	{
		linkText.firstChild.nodeValue = "- ";
	}
	else if (linkText.firstChild.nodeValue == "- ")
	{
		linkText.firstChild.nodeValue = "+";
	}

	linkText = document.getElementById(link);
	if (IE4) { prefix = document.all(arguments[0]).style; }
	if (NS6 || IE5) { prefix = linkText.style }
	if (NS4){ prefix = document.layers(arguments[0]); }

	if (prefix.display == "block")
	{
		prefix.display = "none";
	}
	else
	{
		prefix.display = "block";
	}
	
	
	///
	var action;
	IE4 = (document.all && !document.getElementById) ? true : false;
	NS4 = (document.layers) ? true : false;
	IE5 = (document.all && document.getElementById) ? true : false;
	NS6 = (!document.all && document.getElementById) ? true : false;
		
	var link;
	link = action + "lineup";
	linkText = document.getElementById(link);
	linkText.firstChild.nodeValue;

	if (linkText.firstChild.nodeValue == "+")
	{
		linkText.firstChild.nodeValue = "- ";
	}
	else if (linkText.firstChild.nodeValue == "- ")
	{
		linkText.firstChild.nodeValue = "+";
	}

	linkText = document.getElementById(link);
	if (IE4) { prefix = document.all(arguments[0]).style; }
	if (NS6 || IE5) { prefix = linkText.style }
	if (NS4){ prefix = document.layers(arguments[0]); }

	if (prefix.display == "block")
	{
		prefix.display = "none";
	}
	else
	{
		prefix.display = "block";
	}
	
}

function showDetailsLeftMenu(action)
{
	var action;
	IE4 = (document.all && !document.getElementById) ? true : false;
	NS4 = (document.layers) ? true : false;
	IE5 = (document.all && document.getElementById) ? true : false;
	NS6 = (!document.all && document.getElementById) ? true : false;
		
	var link;
	link = "DistributorInfoBar1_" + action + "linkLeft";
	linkText = document.getElementById(link);
	linkText.firstChild.nodeValue;

	linkText = document.getElementById("DistributorInfoBar1_" + action);
	if (IE4) { prefix = document.all(arguments[0]).style; }
	if (NS6 || IE5) { prefix = linkText.style }
	if (NS4){ prefix = document.layers(arguments[0]); }

	if (prefix.display == "block")
	{
		prefix.display = "none";
	}
	else
	{
		prefix.display = "block";
	}

}

/// <summary>
/// Used in Contact.aspx
/// If Yes, the field Distributor can not be empty
/// Valentin Gosetto - 27.Jan.2006
/// </summary>
function CheckMember(source, arguments)
{
	if (document.all.MemberYesRadioButton.checked==true){
		if (document.all.DistributorTextBox.value == ''){
			arguments.IsValid = false;
			return;
		}
	}
	arguments.IsValid = true;
	return;
}


/// <summary>
/// Used in Contact.aspx
/// Valentin Gosetto - 27.Jan.2006
/// </summary>
function AcceptTerms(source, arguments)
{
	if (document.all.AcceptCheckBox.checked==false){
		arguments.IsValid = false;
		return;
	}
	arguments.IsValid = true;
	return;
}


/// <summary>
/// Used in BasicEnrollment.ascx
/// Mask for phone numbers, it adds a "-" between the numbers
/// Diana Marín - 09.Feb.2006
/// </summary>
function mask(str,textbox,loc,delim){
var locs = loc.split(',');

for (var i = 0; i <= locs.length; i++){
	for (var k = 0; k <= str.length; k++){
	 if (k == locs[i]){
	  if (str.substring(k, k+1) != delim){
	   if (event.keyCode != 8){ //backspace
	    str = str.substring(0,k) + delim + str.substring(k,str.length);
       }
	  }
	 }
	}
 }
textbox.value = str
}

/// <summary>
/// Used in BasicEnrollment.ascx and UpgradeCOE
/// Hide all the controls of Social Security Number when the country is Canada
/// Diana Marín - 01.Aug.2006
/// </summary>
function hideCanadaSSN( canadaSSNLabel, tableSocialSN) { 
	if( canadaSSNLabel == null ) 
	return; 

	tableSocialSN.style.display = "none";
}


function setLength(id, length){
   window.document.getElementById(id).setAttribute('maxlength', length);
}



function setFocus(control)
{
document.getElementById(control).focus()
}

function SimpleShowDetails(action)
{
	var action;
	IE4 = (document.all && !document.getElementById) ? true : false;
	NS4 = (document.layers) ? true : false;
	IE5 = (document.all && document.getElementById) ? true : false;
	NS6 = (!document.all && document.getElementById) ? true : false;
		
	var link;
	link = action + "link";
	linkText = document.getElementById(link);
	linkText.firstChild.nodeValue;

	if (linkText.firstChild.nodeValue == "+")
	{
		linkText.firstChild.nodeValue = "- ";
	}
	else if (linkText.firstChild.nodeValue == "- ")
	{
		linkText.firstChild.nodeValue = "+";
	}
		
	linkText = document.getElementById(action);
	if (IE4) { prefix = document.all(arguments[0]).style; }
	if (NS6 || IE5) { prefix = linkText.style }
	if (NS4){ prefix = document.layers(arguments[0]); }

	if (prefix.display == "block")
	{
		prefix.display = "none";
	}
	else
	{
		prefix.display = "block";
	}
}
function showSubDetails(action)
{
	var action;
	IE4 = (document.all && !document.getElementById) ? true : false;
	NS4 = (document.layers) ? true : false;
	IE5 = (document.all && document.getElementById) ? true : false;
	NS6 = (!document.all && document.getElementById) ? true : false;
		
	var link;
	link = action + "sublink";
	linkText = document.getElementById(link);
	linkText.firstChild.nodeValue;

	if (linkText.firstChild.nodeValue == "+")
	{
		linkText.firstChild.nodeValue = "- ";
	}
	else if (linkText.firstChild.nodeValue == "- ")
	{
		linkText.firstChild.nodeValue = "+";
	}

	linkText = document.getElementById(action);
	if (IE4) { prefix = document.all(arguments[0]).style; }
	if (NS6 || IE5) { prefix = linkText.style }
	if (NS4){ prefix = document.layers(arguments[0]); }

	if (prefix.display == "block")
	{
		prefix.display = "none";
	}
	else
	{
		prefix.display = "block";
	}
	
	///
	var action;
	IE4 = (document.all && !document.getElementById) ? true : false;
	NS4 = (document.layers) ? true : false;
	IE5 = (document.all && document.getElementById) ? true : false;
	NS6 = (!document.all && document.getElementById) ? true : false;
		
	var link;
	link = action + "linedown";
	linkText = document.getElementById(link);
	linkText.firstChild.nodeValue;

	if (linkText.firstChild.nodeValue == "+")
	{
		linkText.firstChild.nodeValue = "- ";
	}
	else if (linkText.firstChild.nodeValue == "- ")
	{
		linkText.firstChild.nodeValue = "+";
	}

	linkText = document.getElementById(link);
	if (IE4) { prefix = document.all(arguments[0]).style; }
	if (NS6 || IE5) { prefix = linkText.style }
	if (NS4){ prefix = document.layers(arguments[0]); }

	if (prefix.display == "block")
	{
		prefix.display = "none";
	}
	else
	{
		prefix.display = "block";
	}
	
	
	///
	var action;
	IE4 = (document.all && !document.getElementById) ? true : false;
	NS4 = (document.layers) ? true : false;
	IE5 = (document.all && document.getElementById) ? true : false;
	NS6 = (!document.all && document.getElementById) ? true : false;
		
	var link;
	link = action + "lineup";
	linkText = document.getElementById(link);
	linkText.firstChild.nodeValue;

	if (linkText.firstChild.nodeValue == "+")
	{
		linkText.firstChild.nodeValue = "- ";
	}
	else if (linkText.firstChild.nodeValue == "- ")
	{
		linkText.firstChild.nodeValue = "+";
	}

	linkText = document.getElementById(link);
	if (IE4) { prefix = document.all(arguments[0]).style; }
	if (NS6 || IE5) { prefix = linkText.style }
	if (NS4){ prefix = document.layers(arguments[0]); }

	if (prefix.display == "block")
	{
		prefix.display = "none";
	}
	else
	{
		prefix.display = "block";
	}
	
}

	function EmptyLabel(labelID)
	{
		document.getElementById(labelID).innerText= '';
	
	}

		function printReport(){
		
			var reportsUrl = document.getElementById("TextBoxReportServerPath").value;
			var reportPath = document.getElementById("TextBoxReportPath").value;
			var reportParameters = document.getElementById("TextBoxReportParameters").value;
			/*RSClientPrint.MarginLeft = 15;
			RSClientPrint.MarginTop = 12.7;
			RSClientPrint.MarginRight = 0;
			RSClientPrint.MarginBottom = 40;*/
			var tempStr = reportParameters;
			reportParameters = tempStr.substr(0, tempStr.indexOf("&rc:zoom=Page Width")) + tempStr.substr(tempStr.indexOf("&rc:zoom=Page Width")+19);
			RSClientPrint.Culture = 1040;
			RSClientPrint.UICulture = 1042;
			RSClientPrint.Print(reportsUrl, reportPath+"_print"+reportParameters, document.title);
		}

	function disableButton(item, message)
	{
		if (message == null){
		message = 'Processing, please wait';
		}
		//parentElement = item.parentNode;
		var messageDiv = document.createElement('div');
		messageDiv.setAttribute('align', 'center');
		messageDiv.setAttribute('innerHTML', message);
		messageDiv.className = "FormTextError";
		item.parentNode.appendChild(messageDiv);
		
		item.disabled = 'DISABLED';
		
	}
	function showLoadingImage(divId){
		document.getElementById(divId).innerHTML ="<IMG src=../images/preLoader.gif>";		
	}
	
	
	
//mask for  phone number

var patron = new Array(3,3,4);
var patronZipUSA = new Array(4);
var patronZipCanada = new Array(3,3);

function mascara(d,sep,pat,nums){
if(d.valant != d.value){
	val = d.value;
	largo = val.length;
	val = val.split(sep);
	val2 = '';
	for(r=0;r<val.length;r++){
		val2 += val[r];	
	}
	if(nums){
		for(z=0;z<val2.length;z++){
			if(isNaN(val2.charAt(z))){
				letra = new RegExp(val2.charAt(z),"g");
				val2 = val2.replace(letra,"");
			}
		}
	}
	val = '';
	val3 = new Array();
	for(s=0; s<pat.length; s++){
		val3[s] = val2.substring(0,pat[s])
		val2 = val2.substr(pat[s])
	}
	for(q=0;q<val3.length; q++){
		if(q ==0){
			val = val3[q];
		}
		else{
			if(val3[q] != ""){
				val += sep + val3[q];
				}
		}
	}
	d.value = val;
	d.valant = val;
	}
}
