// JavaScript Document

/* ***********************************************
    loads url in iframe, transfers body content into div
    provides defaults for iframe and display div ID's 
    also supports use with multiple iframes and divs
    optional message for loading in display div 
    supports functions to be called once the div has been populated with new content 
    function in iframed document can be invoked should some operations need to be performed from there 
 ********************************************* */
function LoadPage(URL, CookieName, LoadingMessage, iFrameID, DivID) {
    // defaults for iframe, display div
    iFrameID       = iFrameID || 'buffer'; 
    DivID          = DivID || 'display'; 
    LoadingMessage = LoadingMessage || false;
    CookieName     = CookieName || false;
  
    if ( window.frames[iFrameID] ) {
        // Could use location.replace method if you do not want back button to load previous iframe url 
        // window.frames[ifrmId].location.replace(url);
        window.frames[iFrameID].location = URL;
        var isLayer = document.getElementById ? document.getElementById(DivID) : null;
        if (isLayer && LoadingMessage) { // Option to display message while retrieving data 
            isLayer.innerHTML = LoadingMessage;
            isLayer.style.display = 'block'; 
        }
        document.title = window.frames[iFrameID].document.title;
        if (CookieName) { document.cookie = CookieName + '=' + URL; } 
        return false;
    } 
    return true; // other browsers follow link
}


/* ***********************************************
 called onload of iframe 
 displays body content of iframed doc in div
 checks for and invokes optional functions in both current document and iframed document 
 ********************************************* */
function SyncPage(CookieName, iFrameID, DivID, fp) {
    // defaults for iframe, display div
    iFrameID   = iFrameID || 'buffer'; 
    DivID      = DivID || 'display'; 
    CookieName = CookieName || false;
    
    var isLayer = document.getElementById ? document.getElementById(DivID) : null;
    if ( window.frames[iFrameID] && isLayer ) {
		// SetAndDisplayInfo(10);
        isLayer.innerHTML = window.frames[iFrameID].document.body.innerHTML;
        isLayer.style.display = 'block'; 

        // when using with script, may have some operations to coordinate
        // function in current doc or iframed doc (doOnIframedLoad)
        if ( typeof fp == 'function' ) {
            fp();
        }
        
        // Demonstrated in tooltip demo
        if ( typeof window.frames[iFrameID].doOnIframedLoad == 'function' ) {
            window.frames[iFrameID].doOnIframedLoad();
        }
        document.title = window.frames[iFrameID].document.title;
        if (CookieName) { document.cookie = CookieName + '=' + window.frames[iFrameID].location; } 
    }
}


/* ***********************************************
 User to write a message in a specific object
 in the HTML tag (normally <div> or <span>. 
 Maybe work with others types. Valid for ALL Browsers.

 Parms: TheObj     : The NAME (or ID) of the object
        TheContent : The HTML content
 ********************************************* */
function WriteInto(TheObj, TheContent)
{
	if (document.getElementById)
	{
		x = document.getElementById(TheObj);
		x.innerHTML = '';
		x.innerHTML = TheContent;
	}
	else if (document.all)
	{
		x = document.all[TheObj];
		x.innerHTML = TheContent;
	}
	else if (document.layers)
	{
		x = document.layers[TheObj];
		text2 = '<P CLASS="testclass">' + TheContent + '</P>';
		x.document.open();
		x.document.write(text2);
		x.document.close();
	}
}




/* ***********************************************
 Get the PHYSYCAL POSITION of the object.

 Parms  : TheObj = The ID of the object

 Return a structure as "[ X, Y ]"
********************************************* */
function GetXY(TheObj)
{
  if (document.getElementById) {
       x= document.getElementById(TheObj).offsetLeft;
       y= document.getElementById(TheObj).offsetTop;
       }
     else if (document.all) {
		x = document.all[TheObj].left;
		y = document.all[TheObj].top;
	   } 
	  else if (document.layers) {
		x = document.layers[TheObj].left;
		y = document.layers[TheObj].top;
		}
	return [ x , y ];
}



/* ***********************************************
 Get the SIZE of the object.

 Parms  : TheObj = The ID of the object

 Return a structure as "[ W, H ]"
********************************************* */
function GetObjSize(TheObj)
{
 if (document.getElementById) {
       w= document.getElementById(TheObj).width;
       h= document.getElementById(TheObj).height;
       }
     else if (document.all) {
		w = document.all[TheObj].width;
		h = document.all[TheObj].height;
	   } 
	  else if (document.layers) {
		w = document.layers[TheObj].width;
		h = document.layers[TheObj].height;
		}
	return [ w , h ];
}


/* ***********************************************
 Get the Internal Document Size of the HTML area.

 Parms  : TheObj = The ID of the object
 
 Return a structure as "[ W, H ]"
 ********************************************* */
function GetDocSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [ myWidth , myHeight ];
}



/* ***********************************************
 Used to never allow page to be framed
 ********************************************* */
function NeverFramed()
{
 if (self != top)
 {
   top.location.replace(document.location.href);
 }
}


/* ***********************************************
 Used to never allow page to be OUT framed
 ********************************************* */
function NeverOutFramed()
{
 if (self == top)
 {
  document.cookie = 'currentPage=' + document.location.href;
  top.location.replace('MainPage.php');
 }
}

/* ***********************************************
 Used to read a Cookie
 ********************************************* */
function readCookie(cookieName) 
{
  cookie_array = document.cookie.split ("; ");
  for (x=0; x < cookie_array.length; x++) 
   {
     cookieParts_array = cookie_array[x].split("=");
     if (cookieParts_array[0] == cookieName) 
	{
	 return cookieParts_array[1];
        } // IF
   } // FOR
  return null;
} // function readCookie


/* ***********************************************
 Used to TOGGLE the DISPLAY CSS attribute
 ********************************************* */
function toggleDisplay(me)
{
 if (me.style.display=="block") 
   { me.style.display="inline"; }
  else
   { 
    if (me.style.display=="inline")
      { me.style.display="none";  }
     else 
      { me.style.display="block"; }
   }
}

/* ***********************************************
 Used to TOGGLE the VISIBILITY CSS attribute
 ********************************************* */
function toggleVisibility(me)
{
  if (me.style.visibility=="hidden")
  {
   me.style.visibility="visible";
  } else {
   me.style.visibility="hidden";
  }
}


function ChangeDisplay(obj, attr)
{
  if (document.getElementById)  { document.getElementById(obj).style.display=attr; }
    else if (document.all)      { document.all[obj].style.display=attr;            }
      else if (document.layers) { document.layers[TheObj].style.display=attr;      }
}

function ChangeVisibility(obj, attr)
{
  if (document.getElementById)  { document.getElementById(obj).style.visibility=attr; }
    else if (document.all)      { document.all[obj].style.visibility=attr;            }
      else if (document.layers) { document.layers[TheObj].style.visibility=attr;      }
}


//      alert("Text is now 'none'. It will reappear in three seconds.");
 //     window.setTimeout("blueText.style.display='block';",3000,"JavaScript");


// Before you reuse this script you may want to have your head examined
// 
// Copyright 1999 InsideDHTML.com, LLC.  

function doBlink() {
  // Blink, Blink, Blink...
  var blink = document.all.tags("BLINK")
  for (var i=0; i < blink.length; i++)
    blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function startBlink() {
  // Make sure it is IE4
  if (document.all)
    setInterval("doBlink()",1000)
}

// dont forget to use: window.onload = startBlink;


var TheSelectecArea  = 'The_Area_Yellow';
var TheSelectedSpot  = null;
var TheSelectedPrice = 0;

function SwitchAreas(ID) {

ChangeDisplay('The_Area_Yellow' , 'none'); 
ChangeDisplay('The_Area_Orange' , 'none'); 
ChangeDisplay('The_Area_Blue'   , 'none'); 
ChangeDisplay('The_Area_Green'  , 'none'); 
ChangeDisplay('The_Area_Pink'   , 'none'); 

ChangeDisplay(ID, 'block'); 
TheSelectecArea = ID;
}

/*
function SelectExhibitArea(ID) {

switch (ID)
{
 case 1: // Area_Yellow
         ChangeDisplay('Area_Yellow'   , 'block'); 
         break;
 case "Orange_Yellow": 
       ChangeDisplay('Area_Yellow'   , 'block'); 
	   break;
 case "Blue_Yellow": 
       ChangeDisplay('Area_Yellow'   , 'block'); 
	   break;
 case "Green_Yellow": 
       ChangeDisplay('Area_Yellow'   , 'block'); 
	   break;
 case "Pink_Yellow": 
       ChangeDisplay('Area_Yellow'   , 'block'); 
	   break;
 }  // Switch Statement
}
*/

function SetAndDisplayInfo(ID) {
  var TheValue = parent.AreaPrice[ID];
  var TheComplement = "";
  if (parent.ApplyDiscount) {
	  TheValue = TheValue - ((TheValue * 10) / 100);
	  TheComplement = "<br /><br /><font color='red'><strong>Important:</strong> For purchases made <u>AFTER</u> <strong>" + parent.StringDiscountDate + "</strong> the same spot may cost up to <strong><u>" + formatCurrency(parent.AreaPrice[ID]) + "</u></strong>. Save money, <strong>BUY NOW!</strong></font>";
	  }

  var STR1 = '<u><strong>Here the description of your current <em>Exhibitor Space</em> choice:</strong></u><br />';
  var STR2 = '<br />' + parent.AreaDescription[ID] + ' (<u>' + parent.AreaColor[ID] +'</u> area).<br />';
  var STR3 = '<br />If you purchase this spot <u>TODAY</u>, before discounts and taxes, you will be paying only <strong>' + formatCurrency(TheValue) + '</strong>.';
  var STR4 = '<p class="FooterNote" style="margin-bottom=0;">Please, continue to checkout to chose your payment mode, apply discounts, coupons, taxes and calculate the final cost of your exhition area.</p>';

  WriteInto('SelectedAreaDescriptionReport', STR1 + STR2 + STR3 + TheComplement + STR4); 
  
  document.forms['ExhibitorSubscriptionForm'].SelectedSpotArea.value=ID;
  document.forms['ExhibitorSubscriptionForm'].Price.value=TheValue;
  document.forms['ExhibitorSubscriptionForm'].AreaColor.value=parent.AreaColor[ID];
  document.forms['ExhibitorSubscriptionForm'].Discount.value=parent.ApplyDiscount;
  document.forms['ExhibitorSubscriptionForm'].AreaDescription.value=parent.AreaDescription[ID] + ' (<u>' + parent.AreaColor[ID] +'</u> area).';
  document.forms['ExhibitorSubscriptionForm'].ExibitionSpot[ID].checked=true;
  document.forms['ExhibitorSubscriptionForm'].IsAnythingSelected.value="YES";
}

var DiscountFullPayment = 10;
var DiscountPreviousDay = 0;

function SetPaymentType(ID) {
  document.forms['PaymentForm'].PMType[ID].checked = true;
  if (ID==0)
   { DiscountFullPayment = 10; 
     ChangeDisplay('TBL_FullPayment' , 'table-row');
	 document.forms['PaymentForm'].PaidInFull.value = 'YES';
   } 
   else
   { DiscountFullPayment = 0; 
     ChangeDisplay('TBL_FullPayment' , 'none');
	 document.forms['PaymentForm'].PaidInFull.value = 'NO';
   } 
}

function SwitchPaymentType(ID) {
ChangeDisplay('DirectDeposit', 'none'); 
ChangeDisplay('MoneyOrder'   , 'none'); 
ChangeDisplay('CreditCard'   , 'none'); 
switch (ID)
{
 case 0: // Direct Deposit
         ChangeDisplay('DirectDeposit', 'block'); 
  		 document.forms['PaymentForm'].PaymentType[ID].checked = true;
		 document.forms['PaymentForm'].PaymentTypeSelected.value = 'Direct Deposit';
         break;
 case 1: // Money Order
         ChangeDisplay('MoneyOrder', 'block'); 
  		 document.forms['PaymentForm'].PaymentType[ID].checked = true;
		 document.forms['PaymentForm'].PaymentTypeSelected.value = 'Money Order';
         break;
 case 2: // Credit Card
         ChangeDisplay('CreditCard', 'block'); 
  		 document.forms['PaymentForm'].PaymentType[ID].checked = true;
		 document.forms['PaymentForm'].PaymentTypeSelected.value = 'Credit Card';
         break;
} // Switch Statement
}

function CalculateInvoice(Price, Discount) {
var The_InvoicePrice = Price;
var The_InvoiceDiscountDay = Discount;
var The_InvoiceDiscountFull = DiscountFullPayment;
var The_InvoiceCoupon = 0;

var The_InvoiceTaxes = 7.75;
var The_InvoiceTotalDiscounts = 0;
var The_InvoiceTotalCoupons = 0;
var The_GrandTotal = 0;

WriteInto('InvoicePrice', formatCurrency(The_InvoicePrice));

var Discount1 = (The_InvoicePrice * The_InvoiceDiscountDay) / 100;
WriteInto('InvoiceDiscountDay', formatCurrency(Discount1));

var Discount2 = (The_InvoicePrice * The_InvoiceDiscountFull) / 100;
WriteInto('InvoiceDiscountFull', formatCurrency(Discount2));

WriteInto('InvoiceCoupon', formatCurrency(The_InvoiceCoupon));

var PreTotal = The_InvoicePrice -(Discount1 + Discount2 + The_InvoiceCoupon);
var Taxes = (PreTotal * The_InvoiceTaxes) / 100;
WriteInto('InvoiceTaxes', formatCurrency(Taxes));

WriteInto('InvoiceTotalDiscounts', formatCurrency(Discount1 + Discount2));
WriteInto('InvoiceTotalCoupons', formatCurrency(The_InvoiceCoupon));
WriteInto('GrandTotal', formatCurrency(PreTotal + Taxes));

document.forms['PaymentForm'].SF_InvoiceDiscoutnDay.value = Discount1;
document.forms['PaymentForm'].SF_InvoiceDiscoutnFull.value = Discount2;

document.forms['PaymentForm'].TotalDiscounts.value = Discount1 + Discount2;
document.forms['PaymentForm'].TotalTaxes.value = Taxes;
document.forms['PaymentForm'].TotalPrice.value = PreTotal + Taxes;
}



function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + 'US$ ' + num + '.' + cents);
}





/* ********************************************************
 *  This Function Validate ALL Fields at the
 *  Exhibitor Registration Form
 *********************************************************/ 
function ValidateFields_ExhibitorRegistration(TheForm)
{
  var MSG_IN = "W A R N I N G !\nErrors were found on your entry!\n\n";
  var MSG_OUT = "\n\nYou must revise and correct the entered information before proceed.";	

  document.forms[TheForm].BTN_Send.disabled = true;
  document.forms[TheForm].CB_Accept.checked = false;

// +++++++++ Company Name  
  if (isWhitespace(document.forms[TheForm].CompanyName.value))
    {
    MSG = "The 'Company Name' cannot be empty.\nIf you are not a company, use may your name or your main product name instead.";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].CompanyName.focus();
    return false;
	}

// +++++++++ CompanyActivityArea 
  if (isWhitespace(document.forms[TheForm].CompanyActivityArea.value))
    {
    MSG = "The 'Areas of Activity' must be disclosed.\nExample: Food, Clothing, Solar Energy, Research, Development, Alternative Fuel, Venture Capitalist, etc.";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].CompanyActivityArea.focus();
    return false;
	}

// +++++++++ CompanyAddress1 
  if (isWhitespace(document.forms[TheForm].CompanyAddress1.value))
    {
    MSG = "The 'Business Address' must be entered.\nWe suggest you to use your main business location, but you can also use your PO Box or any other mailing address instead.";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].CompanyAddress1.focus();
    return false;
	}
 
// +++++++++ CompanyCity 
  if (isWhitespace(document.forms[TheForm].CompanyCity.value))
    {
    MSG = "The 'City' must be entered.\nWhere is your business located at? If it is not a city, you may enter the 'county', 'province' or 'local territory' as it may be used on your location.";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].CompanyCity.focus();
    return false;
	}
 
// +++++++++ CompanyState 
  if (isWhitespace(document.forms[TheForm].CompanyState.value))
    {
    MSG = "The 'State' must be entered.\nCommonly the 'State' is an abbreviation of 2 letters that refers to the region in which your City/Province is located at. If you don't know this information, please check with your local authorities before proceed.";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].CompanyState.focus();
    return false;
	}
 
// +++++++++ Zip Code
  if (isWhitespace(document.forms[TheForm].CompanyZipCode.value))
    {
    MSG = "The 'Zip Code' must be entered.\nHowever, if your location doesn't require or doesn't have Postal Zip Codes, please enter '0000' instead.";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].CompanyZipCode.focus();
    return false;
	}

// +++++++++ Country
  if (isWhitespace(document.forms[TheForm].CompanyCountry.value))
    {
    MSG = "The 'Country' must be entered.\nFor instance: If you are in United States, you can enter 'US', 'USA' or 'United States'. For England you can enter 'UK' or 'England'.";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].CompanyCountry.focus();
    return false;
	}
 
// +++++++++ CompanyPhone
  if (isWhitespace(document.forms[TheForm].CompanyPhone.value))
    {
    MSG = "The 'Phone Number' must be entered.\nIf you don't have a unique phone number for your company you can enter your personal phone number instead. Remember to use: Country (Area Code) Phone Number.";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].CompanyPhone.focus();
    return false;
	}

// +++++++++ ContactPerson
  if (isWhitespace(document.forms[TheForm].ContactPerson.value))
    {
    MSG = "The 'Contact Person' must be defined.\nPlease, enter you name before proceed. If you are not the contact person please enter the name of the person who will be entilted to be contact regards to the Trade Show requirements.";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].ContactPerson.focus();
    return false;
	}

// +++++++++ Title
  if (isWhitespace(document.forms[TheForm].Title.value))
    {
    MSG = "The 'Title' must be entered.\nYou must disclose the position of the contact person at " + document.forms[TheForm].CompanyName.value + ". If the contact person is not part of the company personnel, plese define him/her as 'Independent Agent'.";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].Title.focus();
    return false;
	}

// +++++++++ Phone
  if (isWhitespace(document.forms[TheForm].Phone.value))
    {
    MSG = "The 'Phone Number' must be entered.\nIf your contact phone number is the same number used by the " + document.forms[TheForm].CompanyName.value + " you may just enter it again, otherwise enter your direct contact phone instead. Remember to use: Country (Area Code) Phone Number.";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].Phone.focus();
    return false;
	}

// +++++++++ Email
  if (isWhitespace(document.forms[TheForm].Email.value))
    {
    MSG = "The 'E-mail' must be disclosed.\nIf your direct e-mail address is the same that is used by the "  + document.forms[TheForm].CompanyName.value + " you may just enter it again, otherwise enter your direct e-mail instead.";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].Email.focus();
    return false;
	}

// +++++++++ CompanyEmail
  if (!isWhitespace(document.forms[TheForm].CompanyEmail.value))
    if (isEmail(document.forms[TheForm].CompanyEmail.value) == false)
      {
      MSG = "The entered 'E-mail' is invalid or mistyped.";  
      alert(MSG_IN + MSG + MSG_OUT);
	  document.forms[TheForm].CompanyEmail.focus();
      return false;
      }

// +++++++++ Email
  if (isEmail(document.forms[TheForm].Email.value) == false)
    {
    MSG = "The entered 'E-mail' is invalid or mistyped.";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].Email.focus();
    return false;
	}

// +++++++++ SelectedSpotArea
  if (isWhitespace(document.forms[TheForm].IsAnythingSelected.value))
    {
    MSG = "You haven't selected the Exhibitor Booth for you business.\nTo find the right booth for your business you may click on one of the five colored options available at the \"Exhibitor's Booth\" and then selecet one of the options that will be displayed for related to the chosen area.";
	alert(MSG_IN + MSG + MSG_OUT);
//	document.forms[TheForm].Email.focus();
    return false;
	}

  document.forms[TheForm].BTN_Send.disabled = false;
  document.forms[TheForm].CB_Accept.checked = true;

  document.forms[TheForm].submit();
}  


/* ********************************************************
 *  This Function Validate ALL Fields at the
 *  Exhibitor Contact Request Form
 *********************************************************/ 
function ValidateFields_ContactMeForm(TheForm)
{
  var MSG_IN = "W A R N I N G !\nErrors were found on your entry!\n\n";
  var MSG_OUT = "\n\nYou must revise and correct the entered information before proceed.";	

// +++++++++ Name  
  if (isWhitespace(document.forms[TheForm].Name.value))
    {
    MSG = "The 'Name' cannot be empty.\nPlease, enter your name or the name of the person to be contacted.";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].Name.focus();
    return false;
	}

// +++++++++ Email
  if (isEmail(document.forms[TheForm].Email.value) == false)
    {
    MSG = "The entered 'E-mail' is invalid or mistyped.\nWe need a valid e-mail address to be used to contact " + document.forms[TheForm].Name.value + ".";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].Email.focus();
    return false;
	}

// +++++++++ Phone  
  if (isWhitespace(document.forms[TheForm].Phone.value))
    {
    MSG = "The 'Phone' cannot be empty.\nPlease, enter the phone number to be used to contact " + document.forms[TheForm].Name.value + ".";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].Phone.focus();
    return false;
	}
  document.forms[TheForm].submit();
}


/* ********************************************************
 *  This Function Validate ALL Fields at the
 *  Exhibitor Contact Request Form
 *********************************************************/ 
function ValidateFields_CreditCardPayment(TheForm, processIt)
{

  if (document.forms[TheForm].PaymentType[2].checked) {
	
  var MSG_IN = "W A R N I N G !\nErrors were found on your entry!\n\n";
  var MSG_OUT = "\n\nYou must revise and correct the entered information before proceed.";	

  var WorkString = document.forms[TheForm].CC_Type.value;
  switch (WorkString)
  {
	  case "Visa":
	       if (!isVisa(document.forms[TheForm].CC_Number.value)) 
		   {
            MSG = "The Credit Card number entenred doesn't appears to be for a Visa valid card.\nPlease, review the number or select the proper Credit Card type and try again."
			alert(MSG_IN + MSG + MSG_OUT);   
			document.forms[TheForm].CC_Number.focus();
			return false;
		   }
		   break;
	  
	  case "MasterCard":
	       if (!isMasterCard(document.forms[TheForm].CC_Number.value)) 
		   {
            MSG = "The Credit Card number entenred doesn't appears to be for a Master Card valid card.\nPlease, review the number or select the proper Credit Card type and try again."
			alert(MSG_IN + MSG + MSG_OUT);   
			document.forms[TheForm].CC_Number.focus();
			return false;
		   }
		   break;
	  
	  case "Amex":
	       if (!isAmericanExpress(document.forms[TheForm].CC_Number.value)) 
		   {
            MSG = "The Credit Card number entenred doesn't appears to be for an American Express valid card.\nPlease, review the number or select the proper Credit Card type and try again."
			alert(MSG_IN + MSG + MSG_OUT);   
			document.forms[TheForm].CC_Number.focus();
			return false;
		   }
		   break;
	  
	  case "Discover":
	       if (!isDiscover(document.forms[TheForm].CC_Number.value)) 
		   {
            MSG = "The Credit Card number entenred doesn't appears to be for a Discover valid card.\nPlease, review the number or select the proper Credit Card type and try again."
			alert(MSG_IN + MSG + MSG_OUT);  
			document.forms[TheForm].CC_Number.focus();
			return false;
		   }
		   break;
	  
  } 
  
  if (processIt) {
     if (document.forms[TheForm].CC_ExpDate_Month.value == "NONE")
		   {
            MSG = "Please, selectt the proper Expiration Date (month) for the entered Credit Card."
			alert(MSG_IN + MSG + MSG_OUT);  
			document.forms[TheForm].CC_ExpDate_Month.focus();
			return false;
		   }
     if (document.forms[TheForm].CC_ExpDate_Year.value == "NONE")
		   {
            MSG = "Please, selectt the proper Expiration Date (year) for the entered Credit Card."
			alert(MSG_IN + MSG + MSG_OUT);  
			document.forms[TheForm].CC_ExpDate_Year.focus();
			return false;
		   }
     if (isWhitespace(document.forms[TheForm].CVV.value))
		   {
            MSG = "The Card Verification Value (CVV) cannot be empty."
			alert(MSG_IN + MSG + MSG_OUT);  
			document.forms[TheForm].CVV.focus();
			return false;
		   }
     if (!isInteger(document.forms[TheForm].CVV.value))
		   {
            MSG = "The Card Verification Value (CVV) entered is invalid. The value must contrain only numbers."
			alert(MSG_IN + MSG + MSG_OUT);  
			document.forms[TheForm].CVV.focus();
			return false;
		   }
     if (isWhitespace(document.forms[TheForm].Cardholder.value))
		   {
            MSG = "Please, enter the Card Holder's Name exactly as it appears on the card."
			alert(MSG_IN + MSG + MSG_OUT);  
			document.forms[TheForm].Cardholder.focus();
			return false;
		   }
     if (isWhitespace(document.forms[TheForm].BillingAddress1.value))
		   {
		   MSG = "The 'Billing Address' must be entered.\nThis address must match with the current billing address for the entered Credit Card.";
		   alert(MSG_IN + MSG + MSG_OUT);
		   document.forms[TheForm].BillingAddress1.focus();
		   return false;
		   }
     if (isWhitespace(document.forms[TheForm].BillingCity.value))
		   {
		   MSG = "The 'City' must be entered.\nThis information must match with the current billing address for the entered Credit Card.";
		   alert(MSG_IN + MSG + MSG_OUT);
		   document.forms[TheForm].BillingCity.focus();
		   return false;
		   }
     if (isWhitespace(document.forms[TheForm].BillingState.value))
		   {
		   MSG = "The 'State' must be entered.\nThis information must match with the current billing address for the entered Credit Card.";
		   alert(MSG_IN + MSG + MSG_OUT);
		   document.forms[TheForm].BillingState.focus();
		   return false;
		   }
     if (isWhitespace(document.forms[TheForm].BillingZipCode.value))
		   {
		   MSG = "The 'Zip Code' must be entered.\nThis information must match with the current billing address for the entered Credit Card. However, if your location doesn't require or doesn't have Postal Zip Codes, please enter '0000' instead.";
		   alert(MSG_IN + MSG + MSG_OUT);
		   document.forms[TheForm].BillingZipCode.focus();
		   return false;
		   }
     if (isWhitespace(document.forms[TheForm].BillingCountry.value))
		   {
		   MSG = "The 'Country' must be entered.\nThis information must match with the current billing address for the entered Credit Card.";
		   alert(MSG_IN + MSG + MSG_OUT);
		   document.forms[TheForm].BillingCountry.focus();
		   return false;
		   }
     if (isWhitespace(document.forms[TheForm].BillingPhone.value))
		   {
		   MSG = "The 'Phone Number' must be entered.\nThe phone number must belong to the Card Holder of the aforementioned Credit Card.";
		   alert(MSG_IN + MSG + MSG_OUT);
		   document.forms[TheForm].BillingPhone.focus();
		   return false;
		   }
     }
   } 
  ChangeDisplay('TheCheckout', 'none'); 
  ChangeDisplay('TheCheckoutProcessing', 'block'); 
  document.forms[TheForm].submit(); 
}



/* ********************************************************
 *  This Function Validate ALL Fields at the
 *  Exhibitor Contact Request Form
 *********************************************************/ 
function ValidateFields_SendMessageForm(TheForm)
{

  var MSG_IN = "W A R N I N G !\nErrors were found on your entry!\n\n";
  var MSG_OUT = "\n\nYou must revise and correct the entered information before proceed.";	

  if (isWhitespace(document.forms[TheForm].Name.value))
    {
    MSG = "The 'Contact Person' must be defined.\nPlease, enter you name before proceed. If you are not the contact person please enter the name of the person who will be entilted to be contact regards to this message.";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].Name.focus();
    return false;
	}

  if ( (isWhitespace(document.forms[TheForm].Email.value)) || (isEmail(document.forms[TheForm].Email.value) == false))
    {
    MSG = "The entered 'E-mail' is invalid, empty or mistyped.\nYou must enter a valid e-mail to be able to send messages using this tool.";  
    alert(MSG_IN + MSG + MSG_OUT);
    document.forms[TheForm].Email.focus();
    return false;
    }
  if (isWhitespace(document.forms[TheForm].Message.value))
    {
    MSG = "You can't send an EMPTY message. Please, use the 'Your Message' field to disclose the meaning of your communication or request.";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].Message.focus();
    return false;
	}

  if (isWhitespace(document.forms[TheForm].SIP_SF_Input.value))
    {
    MSG = "You must enter the CONFIRMATION CODE before proceed.\nThe code is a set of numbers in blue color displayed inside a grid and underneath the Confirmation Code field.\nYou must type this number exactly as it is presented.";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].SIP_SF_Input.focus();
    return false;
	}

  if (document.forms[TheForm].SIP_SF_Input.value != document.forms[TheForm].SIP_SF.value)
    {
    MSG = "The CONFIRMATION CODE you enter doesn't match with the displayed code. You must type this number exactly as it appear.\nThe code is a set of numbers in blue color displayed inside a grid and underneath the Confirmation Code field.";
	alert(MSG_IN + MSG + MSG_OUT);
	document.forms[TheForm].SIP_SF_Input.value="";
	document.forms[TheForm].SIP_SF_Input.focus();
    return false;
	}

// +++++++++ EMPTY SUBJECTS
  if (isWhitespace(document.forms[TheForm].Subject.value))
    {
	document.forms[TheForm].Subject.value = "General Message sent thru the Trade Show Contact Us page";
	}
  document.forms[TheForm].submit(); 
}


function randomString(size) {
//    var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var chars = "123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghikmnpqrstuvwxyz";
	var string_length = size;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}
