
function getElementById(oID,oDoc)
{
    if( document.getElementById ) 
      {
        return document.getElementById(oID); 
      }
    if (document.all ) 
      {
        return document.all[oID]; 
      }
    if( !oDoc ) { oDoc = document; }
    if (document.layers) 
      {
        if( oDoc.layers[oID] ) 
          { 
            return oDoc.layers[oID]; 
          } 
        else 
          {
            for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) 
            {
              y = getRefToDiv(oID,oDoc.layers[x].document); 
            }
            return y; 
          }
      }
  return false;
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

function initCarConfig(objCarConfigId)
{
  eval('initCarConfig_' + objCarConfigId + '()');
}

function recallStep(objTabId, stepNum)
{
    var i = 0;
    showTabStep(objTabId, parseInt(stepNum)); 
    setCurrentStep(objTabId, stepNum);
    if (stepNum == 3)
      eval(objTabId + '_getStep_3_State()')
    else
      getStep(objTabId, stepNum);
    var sn = stepNum - 1;
    manageSummaryVisibility(objTabId, eval(objTabId + '_SummaryVisibilities[' + sn + ']'));
    manageObjectVisibility(objTabId, eval(objTabId + '_ObjectVisibilities[' + sn + ']'));
    ////////
    manageOtherDisplays(stepNum)
	////////
    setReloadStep(objTabId, stepNum, '0');
    eval(objTabId + '_ManageNavDisplays()');////////
}


function callPreviousStep(objTabId)
{
	callStep(objTabId, parseInt(eval(objTabId + "_step_current")) - 1);
}

function callNextStep(objTabId)
{
	callStep(objTabId, parseInt(eval(objTabId + "_step_current")) + 1);
}

function callStep(objTabId, stepNum)
{
    if (isBusyWorking(objTabId))
    {
      alert ('We are still processing your request. Please wait...');
      return;
    }
    checkStepChanged(objTabId, getCurrentStep(objTabId)); //For now this has to be called before getReloadStep
    if (!getStepAvailability(objTabId, stepNum))
    {
      alert ('Available steps: ' + getAllAvailableSteps(objTabId, ', ', ' & '));
      return;
    }
    //var i = 0;
    ////////
    if (document.getElementById("divBuildHeaderText"))
	{
		if (stepNum != 5) 
			document.getElementById("divBuildHeaderText").style.display = '';
	}
	////////
    manageSummaryVisibility(objTabId, eval(objTabId + '_SummaryVisibilities[stepNum - 1]'));
    manageObjectVisibility(objTabId, eval(objTabId + '_ObjectVisibilities[stepNum - 1]'));
    ////////
    manageOtherDisplays(stepNum)
	////////
    switch (getReloadStep(objTabId,stepNum))
    {
        case '0':
          showTabStep(objTabId, stepNum);
          setCurrentStep(objTabId,stepNum);
          break;
        case '1':
          showTabStep(objTabId, stepNum);
          setCurrentStep(objTabId,stepNum);
          getStep(objTabId, stepNum);
          break;
        case '2':
          recallStep(objTabId, stepNum);
          break;
    }
    eval(objTabId + '_ManageNavDisplays()');////////
}

function showTabStep(objID, stepNum)
{
  var i=0;
  for (i = eval(objID + "_step_first"); i < stepNum; i++)
    {
        getElementById(objID + "_divStep" + i).style.display = 'none';
        getElementById(objID + "_cellStep" + i).className ='gabrielsCarConfigTabInactive';
    }
  getElementById(objID + "_cellStep" + stepNum).className = 'gabrielsCarConfigTabActive';
  getElementById(objID + "_divStep" + stepNum).style.display = "";
  for (i = stepNum + 1; i <= eval(objID + "_step_total"); i++)
    {
        getElementById(objID + "_divStep" + i).style.display = "none";
        getElementById(objID + "_cellStep" + i).className = "gabrielsCarConfigTabInactive";
    }
}

function stepOver(objID, stepNum)
{
  if (stepNum == eval(objID + "_step_current")) return;
  getElementById(objID + "_cellStep" + stepNum).className = 'gabrielsCarConfigTabOver';
  getElementById(objID + "_cellStep" + stepNum).style.cursor = 'pointer';
}

function stepOut(objID, stepNum)
{
  if (stepNum == eval(objID + "_step_current")) return;
  getElementById(objID + "_cellStep" + stepNum).className = 'gabrielsCarConfigTabInactive';
}

function getStep(objID, stepNum)
{
   return eval(objID + "_reload_" + stepNum + "()");
}

function getCurrentStep(objID)
{
  return eval(objID + "_step_current");
}

function setCurrentStep(objID, stepNum)
{
  eval(objID + "_step_current = stepNum");
}

function getReloadStep(objStepsId, stepNum)
{ //Values : 
  // 0 = no reload
  // 1 = load
  // 2 = reload
  var x = eval(objStepsId + '_reload') + '';
  return x.charAt(stepNum - 1);
}

function setReloadStep(objStepsId, stepNum, value)
{
  var aux = '';
  var x;
  var i;
  for (i=0; i<stepNum-1; i++)
  {
    x = eval(objStepsId + '_reload') + '';
    aux += x.charAt(i);
  }
  aux += value;
  for (i=stepNum; i<5; i++)
  {
    x = eval(objStepsId + '_reload') + '';
    aux += x.charAt(i);
  }
  eval(objStepsId + '_reload = aux');
}

function isBusyWorking(objStepsId)
{
  return eval(objStepsId + '_busy_working');
}

function getStepAvailability(objStepsId, stepNum)
{
  return eval(objStepsId + '_available[stepNum - 1]');
}

function setStepAvailability(objStepsId, stepNum, value)
{ 
  eval(objStepsId + '_available[stepNum - 1] = value');
}

function setStepAvailabilities(objStepsId, vs1, vs2, vs3, vs4, vs5)
{
  setStepAvailability(objStepsId, 1, vs1);
  setStepAvailability(objStepsId, 2, vs2);
  setStepAvailability(objStepsId, 3, vs3);
  setStepAvailability(objStepsId, 4, vs4);
  setStepAvailability(objStepsId, 5, vs5);
}

function getAllAvailableSteps(objStepId, sep, lastSep)
{
  var i;
  var aux = '';
  for (i=1; i<=5; i++)
  {
    if (getStepAvailability(objStepId,i))
    {
        aux += "," + i;
    }
  }
  if (aux.length > 0) 
  {
    aux = aux.substring(1);
  }
  var auxArr = aux.split(',');
  aux = '';
  for (i=1; i<=auxArr.length; i++)
  {
    if (i == auxArr.length) 
        aux += lastSep + i
    else
        aux += sep + i;
  }
  if (aux.length > 0)
  {
    aux = aux.trim();
    aux = aux.substring(1);
    aux = aux.trim();
  }
  return aux;
}

function setReloadSteps(objStepsId, value)
{
  var i;
  for (i=1; i<=5; i++)
    setReloadStep(objStepId,i,value); 
}

function checkStepChanged(objStepsId, stepNum)
{
  var i;
  switch (stepNum)
  {
    case 1: { break }
    case 2: 
      {
        if (eval(objStepsId + '_styleId != document.getElementById("frmCarConfig_' + objStepsId + '").hid_StyleId.value'))
          {
            eval(objStepsId + "_save_2();");
            for (i=3;i<=5;i++) 
              setReloadStep(objStepsId, i, '1');
            setStepAvailabilities(objStepsId, true, true, true, false, false);
          }
        break;
      }
    case 3: 
      {  
        if (eval(objStepsId + '_pageChanged') == true)
          {
            eval(objStepsId + '_pageChanged = false');
            for (i=4;i<=5;i++) 
              setReloadStep(objStepsId, i, '1');
            setStepAvailabilities(objStepsId, true, true, true, true, true);
          }
        break;
      }
    case 4: 
      {  
        if (eval(objStepsId + '_extColor != document.getElementById("frmCarConfig_' + objStepsId + '").hid_ExtColorCode.value')
          || eval(objStepsId + '_intColor != document.getElementById("frmCarConfig_' + objStepsId + '").hid_IntColorCode.value'))
          {
            eval(objStepsId + "_save_4();");
            setReloadStep(objStepsId, 5, '1');
            setStepAvailabilities(objStepsId, true, true, true, true, true);
          }
        break; 
      }
    case 5: {  break; }
    default: { return true; break; }
  }
}

function EraseStepInfo(objStepsId, stepNum)
{
  var i;
  switch (stepNum)
  {
    case 1: 
      { 
        break; 
      }
    case 2: 
      {
        break;
      }
    case 3: 
      {  
        break;
      }
    case 4: {  break; }
    case 5: {  break; }
    default: { break; }
  }
}

function getHidValues(objTabId, hidName)
{
  return eval(objTabId + '_getValue(hidName)');
}

function setHidValues(objTabId, hidName, hidValue)
{
  return eval(objTabId + '_setValue(hidName, hidValue)');
}

function setLiveValues(objId, stepFirst, stepTotal, stepCurrent, reload, available)
{
  if ((reload.length == 5) && (available.length == 5))
  {
    var av;
    var avStr = '';
    var i;
    for (i=0; i<5; i++)
    {
      av = (available.charAt(i) == '1');
      avStr = avStr + ',' + av;
    }
    eval('setLiveValues_' + objId + '(stepFirst, stepTotal, stepCurrent, ' + reload + avStr + ')');
  }
}

function saveStep(objTabId, stepNum)
{
  if ((stepNum == 2) || (stepNum == 4))
    eval(objTabId + '_save_' + stepNum + '()');
}

//Step 2 functions
function updatePrice(vehicleInfoObjIds,baseInvoice,baseMSRP,destInvoice,destMSRP,optInvoice,optMSRP,totInvoice,totMSRP,pop)
{
  var aux = vehicleInfoObjIds.split(',');
  var s;
  var i;
  for (i=0;i<aux.length;i++)
  {
  s = aux[i] + '_fillRows("' + baseInvoice + '","' + baseMSRP + '","' + destInvoice + '","' + destMSRP + '","' + optInvoice + '","' + optMSRP + '","' + totInvoice + '","' + totMSRP + '");';
  eval(s);
  }
}

    
function updateImage(vehicleInfoObjIds, newURL)
{
  if (vehicleInfoObjIds.length == 0) return;
  var aux = vehicleInfoObjIds.split(',');
  var i;
  for (i=0;i<aux.length;i++)
    eval( aux[i] + '_setImage("' + newURL + '")');
}

function updateName(vehicleInfoObjIds, newName, vehicleNameIds)
{
  var aux = vehicleInfoObjIds.split(',');
  var i;
  for (i=0;i<aux.length;i++)
  {
    eval(aux[i] + '_setTitle("' + newName + '");');
  }
  if (vehicleNameIds != '')
  {
	aux = vehicleNameIds.split(',');
	for (i=0;i<aux.length;i++)
	{
		document.getElementById(aux[i]).innerHTML = newName;
	}
  }
}

function updateTrimNames(objTabId, newTrimMakeName, newTrimModelName, newTrimStyleName)
{
  eval(objTabId + '_updateTrimNames(newTrimMakeName, newTrimModelName, newTrimStyleName)');
}


//Step 3 functions

function toggleOption()
{
}

function removeAllImages(objName, rootUrl)
{
  var i;
  var j = objName.length;
  var allImages = document.getElementsByTagName("img");
  for(i=0; i<allImages.length; i++)
    {
      var oneImage = allImages[i];
      if (oneImage.id.substring(0,j+9) == objName + "_imgItem_")
        {
          oneImage.src = rootUrl + getImageNameByState(0);
          oneImage.alt = "";
        }
    }
}

function setStateImage(objName, rootUrl, optionId, state)
{
  document.getElementById(objName + "_imgItem_" + optionId).src = rootUrl + getImageNameByState(state);
  document.getElementById(objName + "_imgItem_" + optionId).alt = getImageAltByState(state);
}

function getImageNameByState(state)
{
  switch (parseInt(state))
  {
    case 0:
    case 1: {return "img_padding.gif"; break}
    case 2: {return "ico_included.gif"; break}
    case 3: {return "ico_required.gif"; break}
    case 4: {return "ico_notincluded.gif"; break}
    case 5: {return "ico_upgrade.gif"; break}
    default: {return "img_padding.gif"; break}
  }
} 

function getImageAltByState(state)
{
  switch (parseInt(state))
  {
    case 0:
    case 1: {return ""; break}
    case 2: {return "Included with your selection ..."; break}
    case 3: {return "Required by your selection ..."; break}
    case 4: {return "Not Available with your selection ..."; break}
    case 5: {return "Upgraded by your selection ..."; break}
    default: {return ""; break}
  }
} 

function isOptionChecked(state)
{
  if ((parseInt(state) == 0) || (parseInt(state) == 4))
    return false
  else
    return true;
} 

function uncheckAll(objName)
{
  var i;
  var j = objName.length;
  var allInputs = document.getElementsByTagName("input");
  for(i=0; i<allInputs.length; i++)
    {
      var oneInput = allInputs[i];
      if(oneInput.type == "checkbox")
        {
          if (oneInput.id.substring(0,j) == objName)
            {
              if(oneInput.checked)
              {
                oneInput.checked = false;
              }
            }
        }
    }
}

function updateDomItems(objName, optionsStr, rootUrl)
{
  removeAllImages(objName, rootUrl);
  uncheckAll(objName);
  var options = optionsStr.split(';');
  var option;
  var i;
  for (i=0; i<options.length; i++)
  {
    option = options[i].split(',');
    if (option.length == 2)
      {
        setStateImage(objName, rootUrl, option[0], option[1]);
        if (isOptionChecked(option[1]))
          checkOption(objName, option[0]);
      }
  }
}

function closePopupInnerHTML()
{
  window.onscroll = ''; //noScroll;
  closePopup();
}

function showPopupInnerHTML(width, innerHTML)
{
  popupWidth = width; //global variable 
  popupHeight = 0; //global variable 
  closePopup();
  sizePopup(width, 3);
  document.getElementById("popup").style.height = "auto";
  document.getElementById("popup").innerHTML = innerHTML;
  showPopup();
  initPopupStay()
}

function initPopupStay()
{
  relocatePopupTimer(popupWidth, 3, 0, 1500)
  if (tooBigPopup())
    window.onscroll = ''; //noScroll;
  else
    window.onscroll = stayPopup;
}

function stayPopup()
{ 
  sizePopup(parseInt(popupWidth), parseInt(popupHeight));
}

function tooBigPopup()
{
	var wh;
	var y;
	var height = parseInt(document.getElementById("popup").style.height);

	if (window.innerWidth==undefined)
	{
		wh=(document.body.clientHeight);
	}
	else
	{
		wh=window.innerHeight;
	}
	y = Math.round((wh / 2) - (height / 2));

	return (y < 10);

}

function relocatePopupTimer(initW, initH, t, timeOut)
{
  if (document.getElementById("popup").scrollHeight > initH)
  {
    popupHeight = document.getElementById("popup").scrollHeight; //global variable
    sizePopup(initW,parseInt(document.getElementById("popup").scrollHeight));
  }
  else
    {
      current += 10;
      if (current >= timeOut)
        alert("Request timed out...")
      else
        setTimeout(function(){relocatePopupTimer(initW, initH, current, timeOut);}, 10);
    }
}

function checkOption(objName, optionId)
{
  document.getElementById(objName + "_checkItem_" + optionId).checked = true;
}

function toggleTree(objName, objCode)
{
     var trTreeChildName = objName + '_trTreeChild' + objCode;
     var imgTreeName = objName + '_imgTree'+objCode;
     if (getElementById(trTreeChildName).style.display == '')
       {
         //make it invisible
         getElementById(trTreeChildName).style.display = 'none';
         getElementById(imgTreeName).src = eval(objName + "_GetImgPlus()");
       }
     else
       {
         //make it visible
         getElementById(trTreeChildName).style.display = '';
         getElementById(imgTreeName).src = eval(objName + "_GetImgMinus()");
       }
}

//step 4 funtions

function saveSelectedExtColorUrl(objValue, objId, objTabId, imgUrl, colorSeq)
{
  var i;
  var obj = getElementById(objId + '_colorLine' + colorSeq);
  var maxVal = getElementById('frmCarConfig_' + objTabId).hid_MaxExtColors.value;
  for (i=0;i<maxVal;i++)
    {
      getElementById(objId + '_colorLine' + i).className = 'gabrielsCarConfigListColor';
    }
  obj.className = 'gabrielsCarConfigSelectedColor';
  getElementById('frmCarConfig_' + objTabId).hid_SelectedExtColorUrl.value = imgUrl;
  eval(objTabId + '_extColor ="' + objValue + '"'); 
  eval(objTabId + '_extColorName ="' + obj.innerHTML + '"');
  //this removes the selection from the interior color
  eval(objTabId + '_intColor = ""');
  eval(objTabId + '_intColorName = ""');
}

function selectIntColor(objId, objTabId, intColorCode)
{
  var maxColors = getElementById('frmCarConfig_' + objTabId).hid_MaxIntColors.value;
  for (i=0; i<maxColors; i++)
  {
    if (getElementById(objId + '_RadioIntItem' + i).value == intColorCode)
    {
      getElementById(objId + '_RadioIntItem' + i).checked = true;
      DispSaveIntColorSelected(objId, objTabId,i);
      //getElementById('frmCarConfig_' + objTabId).hid_IntColorCode.value = obj.value;
      return;
    }
  }
}

function DispSaveIntColorSelected(objId, objTabId, intSeq)
{
  var maxVal = getElementById('frmCarConfig_' + objTabId).hid_MaxIntColors.value;
  var obj = getElementById(objId + '_tdIntItem' + intSeq);
  for (i=0; i<maxVal; i++)
    {
      getElementById(objId + '_tdIntItem' + i).className = 'gabrielsCarConfigListColor';
    }
  obj.className = 'gabrielsCarConfigSelectedColor';
  var value = getElementById(objId + '_RadioIntItem' + intSeq).value;
  value = objTabId + '_intColor = "' + value + '"';
  eval(value); 
  eval(objTabId + '_intColorName = "' + obj.innerHTML + '"');
}


function showIntColors(objId, objTabId, colorsList, defaultSelect)
{ 
  var colorsArray = colorsList.split(';');
  var colorArray;
  var maxColors = getElementById('frmCarConfig_' + objTabId).hid_MaxIntColors.value;
  getElementById(objId + '_tdIntColorHeader').style.display = '';
  for (i=0; i<colorsArray.length; i++)
  {
    colorArray = colorsArray[i];
    colorArray = colorArray.split(',');
    getElementById(objId + '_trIntColor'+i).style.display = ''; 
    getElementById(objId + '_RadioIntItem'+i).value = colorArray[0];
    getElementById(objId + '_tdIntItem'+i).innerHTML = colorArray[1];
    getElementById(objId + '_tdIntItem'+i).className = 'gabrielsCarConfigListColor';
    //getElementById('tdIntItem'+i).style.background = 'white';
    //getElementById('tdIntItemRadio'+i).style.backgroundColor  = colorArray[2];
    getElementById(objId + '_RadioIntItem'+i).checked = false;
  }
  if ((colorsArray.length == 1) && defaultSelect)
  {
    getElementById(objId + '_RadioIntItem0').click()
  }
  for (i=colorsArray.length; i<maxColors; i++)
  {
    getElementById(objId + '_trIntColor'+i).style.display = 'none'; 
  }
}

function restoreImage(objTabId, vehicleInfoObjIds)
{
  var selectedUrl = getElementById('frmCarConfig_' + objTabId).hid_SelectedExtColorUrl.value;
  if (selectedUrl.length > 0)
    {
      updateImage(vehicleInfoObjIds, selectedUrl);
    }
}

function doSelectExtColor(radioObj, objId, objTabId, colorFileNameCar, colorSeq, intColorList, intDefaultSelect, vehicleSummaryIds, vehicleColorIds, colorFileNameCarBig)
{
	radioObj.checked=true; 
	saveSelectedExtColorUrl(radioObj.value, objId, objTabId, colorFileNameCar, colorSeq);
	showIntColors(objId, objTabId , intColorList, intDefaultSelect);
	updateImage(vehicleSummaryIds, colorFileNameCar); 
	updateImage(vehicleColorIds, colorFileNameCarBig);
}





////Step 5 functions (Review and Get Quote)

function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}


function FormDealers_Validate(thisTabId, theForm, emailSpell)
{
//var theForm = document.SelectDealers
if (emailSpell == undefined)
	emailSpell = 'E-mail';
var str = theForm.UserEmail.value;
str=str.replace(/^\s*/, '').replace(/\s*$/, ''); 
theForm.UserEmail.value = str;
  if (theForm.UserFirstName.value == "")
  {
    alert("Please enter your name in the \"First Name\" field.");
    theForm.UserFirstName.focus();
    return (false);
  }

  if (theForm.UserFirstName.value.length < 2)
  {
    alert("Please enter at least 2 characters in the \"First Name\" field.");
    theForm.UserFirstName.focus();
    return (false);
  }

  if (theForm.UserFirstName.value.length > 40)
  {
    alert("Please enter at most 40 characters in the \"First Name\" field.");
    theForm.UserFirstName.focus();
    return (false);
  }

  if (theForm.UserLastName.value == "")
  {
    alert("Please enter your name in the \"Last Name\" field.");
    theForm.UserLastName.focus();
    return (false);
  }

  if (theForm.UserLastName.value.length < 2)
  {
    alert("Please enter at least 2 characters in the \"Last Name\" field.");
    theForm.UserLastName.focus();
    return (false);
  }

  if (theForm.UserLastName.value.length > 40)
  {
    alert("Please enter at most 40 characters in the \"Last Name\" field.");
    theForm.UserLastName.focus();
    return (false);
  }

  if (theForm.UserEmail.value == "")
  {
    alert("Please enter your " + emailSpell + " address in the \"" + emailSpell + " Address\" field.");
    theForm.UserEmail.focus();
    return (false);
  }

  if (theForm.UserEmail.value.length < 7)
  {
    alert("Please enter at least 7 characters in the \"" + emailSpell + " Address\" field.");
    theForm.UserEmail.focus();
    return (false);
  }

  if (theForm.UserEmail.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"" + emailSpell + " Address\" field.");
    theForm.UserEmail.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzŸS‘Zs¦zÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ<ETH>ÑÒÓÔÕÖØÙÚÛÜY´<THORN>ßàáâãäåæçèéêëìíîï<eth>ñòóôõöøùúûüy´<thorn>ÿ0123456789-@#_-+=$().";
  var checkStr = theForm.UserEmail.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter, digit and \"@#_-+=$().\" characters in the \"" + emailSpell + " Address\" field.");
    theForm.UserEmail.focus();
    return (false);
  }
  
  if (!isEmailAddr(theForm.UserEmail.value))
  {
    alert("Please enter a complete " + emailSpell + " Address in the form: yourname@yourdomain.com");
    theForm.UserEmail.focus();
    return (false);
  }  
  
    if (theForm.UserTelephone.value == "")
  {
	if (theForm.UserTelephoneMandatory)
	{
		if (theForm.UserTelephone.value == "")
		{
			alert("Please enter your phone number in the \"Phone Number\" field.");
			theForm.UserTelephone.focus();
			return (false);
		}
	}	
	if (theForm.UserTelephone.value != "" )
	{
  		var checkOK = "0123456789()xX- ";
  		var checkStr = theForm.UserTelephone.value;
  		var allValid = true;
  		for (i = 0;  i < checkStr.length;  i++)
  			{
    		ch = checkStr.charAt(i);
    		for (j = 0;  j < checkOK.length;  j++)
      		if (ch == checkOK.charAt(j))
        	break;
    		if (j == checkOK.length)
    			{
      			allValid = false;
      			break;
    			}
			}
		theForm.UserTelephone.value = checkStr;
  		if (!allValid)
  			{
    		alert("Please enter only digits in \"Telephone\" field. For an extention use \"x or X\" only.");
    		theForm.UserTelephone.focus();
    		return (false);
  			}
  		checkStr = checkStr.toUpperCase();
  		checkStr = checkStr.split("X");
  		if (checkStr.length >= 1)
  		{
  			if (checkStr[0].replace(/[^0-9]/g,'').length < 10)
  			{
  			  alert("Please enter a full phone number (10 digits minimum).");
  			  return (false);
  			 } 
  		}
	   } 
  }
  else
  {
	theForm.ToContact.selectedIndex = 1; //E-Mail
  }
  if (theForm.UserTelephone)
  {
	if (theForm.UserTelephone.value == "")
		theForm.ToContact.selectedIndex = 1; //E-Mail
  }
  
	   if (theForm.ToContact.value == "")
	  {
		alert("Please select \"Contact Method\".");
		theForm.ToContact.focus();
		return (false);
	  }

       /*if (theForm.UserTelephone.value < 1 )
  		{
    	alert("Please enter a Telephone Number.");
    	theForm.UserTelephone.focus();
    	return (false);
  		}*/

  if ((theForm.UserComment) && (theForm.UserComment.value != "" ))
  {
  	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789-@%:')(#_*&+!.$/ ,- ; <=^>\"\t\r\n\f~";
  	var checkStr = theForm.UserComment.value;
  	var allValid = true;
  	var k = checkStr.length;
  	var p = 0;
  	for (i = 0;  i < k;  i++)
  	{   
    	ch = checkStr.charAt(p);
    	for (j = 0;  j < checkOK.length;  j++)
      	if (ch == checkOK.charAt(j))
      	{  	
      		p = p + 1;
        	break;
        }
        if (j == checkOK.length)
      	  checkStr = checkStr.substring(0,p) + checkStr.substring(p+1) 
  	}
  	theForm.UserComment.value = checkStr;
  	if (!allValid)
  	{
    	alert("Please enter only letter, digit, whitespace and \"@%*$/:)(#_&-+!.;,<=^> \" characters in the \"Comments\" field.");
    	document.theForm.UserComment.focus();
    	return (false);
  	}
  }
  
  if (theForm.UserAddress)
  {
	if (theForm.UserAddress.value.length < 5)
		{
		alert("Please enter at least 5 characters in the \"Address\" field.");
		theForm.UserAddress.focus();
		return (false);
		}
  }

  if (theForm.UserCity)
  {
	if (theForm.UserCity.value.length < 2)
		{
		alert("Please enter at least 2 characters in the \"City\" field.");
		theForm.UserCity.focus();
		return (false);
		}
  }
  
  if (theForm.UserState)
  {
	if (theForm.UserState.value.length < 2)
		{
		alert("Please enter 2 characters in the \"State\" field.");
		theForm.UserState.focus();
		return (false);
		}
  }
  
    if(theForm.DealersSource.value == 'JS'){
		//theForm.Provider.value = jumpStartId;
		theForm.Year.value = theForm.VehicleYear.value;
		theForm.Make.value = theForm.VehicleMake.value;  
		theForm.Model.value = theForm.VehicleModel.value; 
		//theForm.Trim.value = theForm.VehicleTrim.value; 
		theForm.Color.value = theForm.VehicleExtColor.value;
		theForm.Email.value = theForm.UserEmail.value;
		theForm.FName.value = theForm.UserFirstName.value;
		theForm.LName.value = theForm.UserLastName.value;
		theForm.Zipcode.value =  theForm.sendZip.value;
		theForm.DPhone.value = theForm.UserTelephone.value.replace("-", "");

        if (theForm.ToContact.options[theForm.ToContact.selectedIndex].value == "E" ) {
            theForm.PrefMethod.value = "Email";
        }else if(theForm.ToContact.options[theForm.ToContact.selectedIndex].value = "P") {
        	theForm.PrefMethod.value = "Phone";
        }else{
			theForm.PrefMethod.value = "Email";  
        }

        //// need to be asssigned from the front-end form
        theForm.Trim.Value = theForm.selTrimLevel ? theForm.selTrimLevel.value : theForm.VehicleTrim.value;;
		theForm.Transmission.value = theForm.SelTransmission ? theForm.SelTransmission.value : "No Preference";
		theForm.BestTime.value = theForm.SelBestTime ? theForm.SelBestTime : "Evening";
		theForm.Within.value = theForm.SelTimeFrame ? theForm.SelTimeFrame.value : "Within a Month";
		theForm.PaymentMethod.value = theForm.SelPayment ? theForm.SelPayment.value : "Loan";
		
		////
		theForm.Color.value = theForm.SelExtColor ? theForm.SelExtColor.value : "No Preference";
		////
		theForm.IntColor.value = theForm.SelIntColor ? theForm.SelIntColor.value : "";
		theForm.TradeIn.value = theForm.radioTradeIn ? theForm.radioTradeIn.value : "";
		

		//document.SelectDealers.action = "http://leads.arizonabay.com/v2/public/LeadReceiver.cfm";
    }
    else if(theForm.DealersSource.value == 'DX'){ 

        //// need to be asssigned from the front-end form
		theForm.BestTime.value = theForm.SelBestTime ? theForm.SelBestTime : "Evening";
		theForm.Within.value = theForm.SelTimeFrame ? theForm.SelTimeFrame.value : "Within 4 Weeks";
		theForm.PaymentMethod.value = theForm.SelPayment ? theForm.SelPayment.value : "Financing";

    }
            //theForm.IsLocal.value = localZip;
		//theForm.UseJumpStart.value = useJumpStart;
		
		eval(thisTabId + "_getQuote()");
}

function submit_dealers(thisTabId, theForm) 
{
 if (theForm.QuoteDealerList_DealerList)
	intCheckboxCount = theForm.QuoteDealerList_DealerList.length
 else
	return false;

 if (typeof(intCheckboxCount) == "undefined")
 {
   if (theForm.QuoteDealerList_DealerList) {
    blnAtLeastOneChecked = theForm.QuoteDealerList_DealerList.checked;
    document.getElementById('ListOfDealers').value = theForm.QuoteDealerList_DealerList.value;
  	} else {
    blnAtLeastOneChecked = false;	 
	}
 }
 else
 {
  var listD = '';
  for(i=0; i<intCheckboxCount; i++) {
   if (theForm.QuoteDealerList_DealerList[i].checked) {
    listD += '`' + theForm.QuoteDealerList_DealerList[i].value;
    //alert(listD);
	}
  }
  if (listD != '') {
    blnAtLeastOneChecked = true;
    document.getElementById('ListOfDealers').value = listD.substring(1);
  	} else {
    blnAtLeastOneChecked = false;	 
  }
 }
 if (blnAtLeastOneChecked == true) {
	return FormDealers_Validate(thisTabId, theForm);
 } 
 else 
 {
	alert('Please select a dealer(s) to request a quote.');
    return false;
 }
}

/*
function submit_dealers_Ext(theForm) 
{
 if (theForm.QuoteDealerList_DealerList)
	intCheckboxCount = theForm.QuoteDealerList_DealerList.length
 else
	return false;

 if (typeof(intCheckboxCount) == "undefined")
 {
   if (theForm.QuoteDealerList_DealerList) {
    blnAtLeastOneChecked = true;
  	} else {
    blnAtLeastOneChecked = false;	 
	}
 }
 else
 {
  for(i=0; i<intCheckboxCount; i++) {
   if (theForm.QuoteDealerList_DealerList[i].checked) {
    blnAtLeastOneChecked = true;
	break;
   	} else {
    blnAtLeastOneChecked = false;
	}
	}
 }
 if (blnAtLeastOneChecked == true) {
	return FormDealers_Validate(thisTabId, theForm);
 } 
 else 
 {
	alert('Please select a dealer(s) to request a quote.');
    return false;
 }
}
*/

// Get div content
 var getDiv_i
  function getSubmitForm2Div(formName, url, divName)
  {
    document.getElementById(divName).innerHTML = '';
    submitFormToDiv(formName, url, divName);
    return getDivContent(divName);
  }
  
  function getDivContent(divName)
  {
    getDiv_i = 0;
    return timerGetDivContent(divName);
  }
  
  function timerGetDivContent(divName)
  {  
     var timeOut = 5000;
     if (getDiv_i >= timeOut) return "";
     if (document.getElementById(divName).innerHTML == '')
     {
        alert(getDiv_i);
        setTimeout("timerGetDivContent()", 10);
        getDiv_i += 10;
        alert(getDiv_i);
        if (getDiv_i >= timeOut) 
        {
            alert("Request timed out ... Please try again");
            getDiv_i = 0;
            return;
        }
     }
     else
     {
       return "IUE";
       return document.getElementById(divName).innerHTML;
     }
  }
  
  
  
  function switching()
  {
  }
  
  function selectDealerDisplayed(objTabId)
  {
    var objSum = getElementById(objTabId + "_divSwitchStep5Summary");
    var objQuo = getElementById(objTabId + "_divSwitchStep5Quote");
    if ((objSum.style.display == 'none') && (objQuo.style.display == 'none'))
    {
      return false;
    }
    else
    {
      return (objSum.style.display != 'none');
    }
  }
  
  function selectDealerLoaded(objTabId)
  {
    return !(getElementById(objTabId + '_divStep5Quote').innerHTML == '');
  }
  
  
  function showSwitches(objTab)
  {
    var objSum = getElementById(objTab + "_divSwitchStep5Summary");
    var objQuo = getElementById(objTab + "_divSwitchStep5Quote");
    if ((objSum.style.display == 'none') && (objQuo.style.display == 'none'))
    {
      objSum.style.display = '';
    }
    else
    {
      objSum.style.display = (objSum.style.display == '') ? 'none' : '';
      objQuo.style.display = (objQuo.style.display == '') ? 'none' : '';
    }
  }
  
  function manageSummaryVisibility(objTabId, summaryDisplays)
  {
    //summary displays are : visibles + ";" + non visibles
    var auxArr = summaryDisplays.split(';'); 
    var i;
    if (auxArr.length == 2)
    {
      if (auxArr[0] != '')
        {
          var aux1 = auxArr[0].split(',');
          for (i=0; i<aux1.length; i++)
          {
            //getElementById(objTabId + '_' + aux1[i]).style.display = '';
            getElementById(aux1[i].trim() + '_divVehicleSummary').style.display = '';
          }
        }
      if (auxArr[1] != '')
        {
          var aux2 = auxArr[1].split(',');
          var objSum;
          for (i=0; i<aux2.length; i++)
          {
          objSum = aux2[i].trim() + '_divVehicleSummary';
          /*objSum2 = 'carConfig_carConfigSummaryLandscape_divVehicleSummary';
          alert('objSum =' + objSum + '\n' + 'objSum2=' + objSum2 + '\n' + 'objSum.indexOf(objSum2) = ' + objSum.indexOf(objSum2) + '\n'
          + 'getElementById(objSum) = ' + getElementById(objSum) + '\n' + 'getElementById(objSum2) = ' + getElementById(objSum2) + '\n'
          + 'objsum.length =' + objSum.length + '\n' + 'objSum2.length=' + objSum2.length);*/
          
          getElementById(objSum).style.display = 'none';
          }
        }
    }
  }
  
  function manageObjectVisibility(objTabId, objDisplays)
  {
    //obj visibilities are : visibles + ";" + non visibles
    var auxArr = objDisplays.split(';');
    var i;
    if (auxArr.length == 2)
    {
      if (auxArr[0] != '')
        {
          var aux1 = auxArr[0].split(',');
          for (i=0; i<aux1.length; i++)
          {
            getElementById(aux1[i].trim() + '_divVisibility').style.display = '';
          }
        }
      if (auxArr[1] != '')
        {
          var aux2 = auxArr[1].split(',');
          var objSum;
          for (i=0; i<aux2.length; i++)
          {
          objSum = aux2[i].trim() + '_divVisibility';
          getElementById(objSum).style.display = 'none';
          }
        }
    }
  }
  
function manageOtherDisplays(stepNum)
{/********/
	var objQuote = getElementById("carConfigGetZipQuoteExt_divVehicleSummary");
	if (objQuote)
	{
		if (stepNum == 5) 
			objQuote.style.display = 'none';
		else
			objQuote.style.display = '';
	}
  /********/ 
}
  
function initLoadingPopup(url, followMouse, checkBoxPositionRight)
{
  getElementById('divLoader').innerHTML = '<img src="' + url + '" style="border:0px"/>';
  hideLoadingPopup();
  if (document.getElementById)
    {
        if(document.layers)
          if (followMouse) document.captureEvents(Event.MOUSEMOVE); else document.captureEvents(Event.MOUSEUP);
        if (checkBoxPositionRight)
        {
          if (followMouse) document.onmousemove = moveImageLeft; else document.onmouseup = moveImageLeft;
        }
        else
        {
		  if (followMouse) document.onmousemove = moveImageRight; else document.onmouseup = moveImageRight;
		}
    }
}


function showLoadingPopup(url)
{
  getElementById('divLoader').style.display = '';
}
  

function moveImage(e)
{
   var Mxy = getMouseCoord(e);
   getElementById("divLoader").style.top = Mxy[1] + "px";
   getElementById("divLoader").style.left = Mxy[0] + "px";
}

function moveImageRight(e)
{
   var Mxy = getMouseCoord(e);
   getElementById("divLoader").style.top = Mxy[1] + "px";
   getElementById("divLoader").style.left = Mxy[0] + "px";
}

function moveImageLeft(e)
{
   var Mxy = getMouseCoord(e);
   getElementById("divLoader").style.top = Mxy[1] + "px";
   getElementById("divLoader").style.left = (Mxy[0] - 160) + "px";
}

function getMouseCoord(e) {
  var x;
  var y;
  if( !e ) { e = window.event; }
  if( !e ) { return [0,0]; }
  if( typeof( e.pageX ) == 'number' ) {
    x = e.pageX;
    y = e.pageY;
  } else if( typeof( e.clientX ) == 'number' ) {
    x = e.clientX;
    y = e.clientY;
    if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
      x += document.body.scrollLeft;
      y += document.body.scrollTop;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
      x += document.documentElement.scrollLeft;
      y += document.documentElement.scrollTop;
    }
  } else { return [0,0]; }
  return [x,y];
}
////
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
////


function hideLoadingPopup()
{
  getElementById('divLoader').style.display = 'none';
}

function getQuote(objTabId)
{ 
  eval(objTabId + '_show_5()');
}

function getQuoteZip(objTabId, objZipCode)
{ 
  eval(objTabId + '_show_5("' + objZipCode + '")');
  ////////
  getElementById("carConfigGetZipQuoteExt_divVehicleSummary").style.display = 'none';
  ////////
}

function boolArray2Str(boolArray)
{
  var retStr = '';
  for (var i=0; i<boolArray.length; i++)
  {
    retStr += (boolArray[i]) ? "1" : "0";
  }
  return retStr;
}

function validateZip(obj)
{
	 if ((obj.length == 5) && (isFinite(obj * 1.0))) return true;
	 else return false;
}

function validateZipForm(theForm, zipField)
{
	 return validateZip(eval('theForm.' + zipField + '.value'));
}

function SubmitIfEnter(e)
{ 
    var charCode
    if(e && e.which){
        e = e
        charCode = e.which
    }
    else{
        e = event
        charCode = e.keyCode 
    }

    if(charCode == 13){ 
        return false
    }
    else{
    return true
    }
}

//function under construction
function submitFormToDivResult(formName, destination, divName, errorMessage)
{
	  var form = document.getElementById(formName);
	  var query = buildQueryString(form);
	  var A = new AJAXObject(function(AjaxResponse)
		{
			try 
			{ 
				if (AjaxResponse.length > 5)
				{
					document.getElementById('divName').innerHTML = AjaxResponse;
					return true;
				}
			}
			catch( e )
			{
				alert(errorMessage + '  (' + e.message + ').');
				return false;
			}
			finally 
			{
			}
		});
		try 
		{
			A.GetPage(destination, query);
		} 
		catch( e ) 
		{
		  return false;
		} 
		finally 
		{
		}
		return false;
}

//CONFIGURATION SAVING

function saveCarConfig(objTabId, appPath, configName, popupWidth, modeLogin)
{
  var A = new AJAXObject(function(AjaxResponse)
    {
        showPopupInnerHTML(popupWidth, AjaxResponse)
    });
  
  saveStep(objTabId, eval(objTabId + '_step_current'));
  var modeStr = 'mode=12';
  var formStr = 'qsfirst=' + eval(objTabId + '_step_first') + '&qstotal=' + eval(objTabId + '_step_total') + '&qscurrent=' + eval(objTabId + '_step_current') + '&qsreload=' + boolArray2Str(eval(objTabId + '_reload')) +  '&qsavailable=' + boolArray2Str(eval(objTabId + '_available'));  
  formStr = formStr + '&StyleId=' + getHidValues(objTabId, 'hid_StyleId');
  formStr = formStr + '&GbStyleState=' + getHidValues(objTabId, 'hid_GbStyleState');
  formStr = formStr + '&StyleState=' + getHidValues(objTabId, 'hid_StyleState');
  formStr = formStr + '&ExtColor=' + getHidValues(objTabId, 'hid_ExtColorCode');
  formStr = formStr + '&IntColor=' + getHidValues(objTabId, 'hid_IntColorCode');
  formStr = formStr + '&senderTabId=' + objTabId; 
  formStr = formStr + '&SavedName=' + configName;
  if (modeLogin)
  { 
	formStr += '&' + buildQueryString(document.getElementById('popupForm'));
	modeStr = 'mode=22';
  }
  A.GetPage(appPath + 'carConfig/getConfigSaving.aspx?' + modeStr, formStr);
}

function delSavedCarConfig(appPath, objLink, configName, popupWidth)
{
  var A = new AJAXObject(function(AjaxResponse)
    {
        if (AjaxResponse.length > 0)
        {
			var ajaxArray = AjaxResponse.split("|");
			if (ajaxArray.length >= 2)
			{
				showPopupInnerHTML(popupWidth, ajaxArray[1]);
				document.getElementById('div' + configName).innerHTML = ajaxArray[0];
				document.getElementById('a_' + configName).href = 'javascript:alert("deleted!")';
				document.getElementById('a_img_' + configName).href = 'javascript:alert("deleted!")';
			}
			else
			{
				showPopupInnerHTML(popupWidth, AjaxResponse);
				alert("2" + document.getElementbyId('a_' + configName));
			}
		}
    });
  var formStr = ''
  if (configName != '')
	formStr = 'SavedName=' + configName;
  A.GetPage(appPath + 'carConfig/getConfigSaving.aspx?mode=10', formStr);
}

  
  function getSavedCarConfig(objTabId, savedName, appPath)
  {
   var A = new AJAXObject(function(AjaxResponse)
    {
      try 
      { 
        if (AjaxResponse.length > 5)
        {
          if (AjaxResponse.substring(0,5) == "[-OK]")
          {
              var ajaxArray = AjaxResponse.split("|");
              if (ajaxArray.length == 19)
                {
                  eval(objTabId + '_save_Info_1_reset(ajaxArray[11], ajaxArray[12], ajaxArray[14])');
                  eval(objTabId + '_updateTrimNames(ajaxArray[13], ajaxArray[15], ajaxArray[16])');
                  updateImage(ajaxArray[18], ajaxArray[17]);
                  eval(objTabId + '_setSerializedValue(ajaxArray[8])');
                  eval(objTabId + '_setGabrielsSerializedValue(ajaxArray[7])');
                  setHidValues(objTabId, 'hid_StyleId', ajaxArray[1]);
                  setHidValues(objTabId, 'hid_ExtColorCode', ajaxArray[9]);
                  setHidValues(objTabId, 'hid_IntColorCode', ajaxArray[10]);
                  
                  setLiveValues(objTabId, ajaxArray[2], ajaxArray[3], ajaxArray[4], ajaxArray[5], ajaxArray[6]);
                  recallStep(objTabId, ajaxArray[4]);

                }
          }
          else if (AjaxResponse.substring(0,5) == "[-KO]")
          {
				var ajaxArray = AjaxResponse.split("|");
				if (ajaxArray.length == 3)
					showPopupInnerHTML(parseInt(ajaxArray[1]), ajaxArray[2]);
          }
          else
          {
            alert(AjaxResponse);
          }
        }
      }
      catch( e )
      {
        alert('An unexpected error has occurred (' + e.message + ').\n' + 'Please try again later.\n'
            + 'If the problem persists, we suggest you close this window and re-launch the configurator.');
      }
      finally 
      {
      }
    });
   try 
   {
     A.GetPage(appPath + 'carConfig/getConfigSaving.aspx?mode=11&SavedName=' + savedName, '');
   } 
   catch( e ) 
   {
   } 
   finally 
   {
   }
  }
  
  
  function carConfigLogin(objTabId, savedName, appPath)
  {
   var A = new AJAXObject(function(AjaxResponse)
    {
      try 
      { 
        if (AjaxResponse.length > 5)
        {
          if (AjaxResponse.substring(0,5) == "[-OK]")
          {
              var ajaxArray = AjaxResponse.split("|");
              if (ajaxArray.length == 19)
                {
                  eval(objTabId + '_save_Info_1_reset(ajaxArray[11], ajaxArray[12], ajaxArray[14])');
                  eval(objTabId + '_updateTrimNames(ajaxArray[13], ajaxArray[15], ajaxArray[16])');
                  updateImage(ajaxArray[18], ajaxArray[17]);
                  eval(objTabId + '_setSerializedValue(ajaxArray[8])');
                  eval(objTabId + '_setGabrielsSerializedValue(ajaxArray[7])');
                  setHidValues(objTabId, 'hid_StyleId', ajaxArray[1]);
                  setHidValues(objTabId, 'hid_ExtColorCode', ajaxArray[9]);
                  setHidValues(objTabId, 'hid_IntColorCode', ajaxArray[10]);
                  
                  setLiveValues(objTabId, ajaxArray[2], ajaxArray[3], ajaxArray[4], ajaxArray[5], ajaxArray[6]);
                  //callStep3('carConfig_carConfigSteps');
                  recallStep(objTabId, ajaxArray[4]);
                  //alert(ajaxArray[9]); alert(ajaxArray[10]);
                  //callStep5('carConfig_carConfigSteps');
                  //eval('carConfig_carConfigSteps' + '_getStep_3_State()');
                  //carConfig_carConfigSteps_setSerializedValue(ajaxArray[8]);
                  //carConfig_carConfigSteps_setGabrielsSerializedValue(ajaxArray[7]);
                  //eval('carConfig_carConfigStep3_toggle("")');
                }
          }
          else
          {
            alert(AjaxResponse);
          }
        }
      }
      catch( e )
      {
        alert('An unexpected error has occurred (' + e.message + ').\n' + 'Please try again later.\n'
            + 'If the problem persists, we suggest you close this window and re-launch the configurator.');
      }
      finally 
      {
      }
    });
   try 
   {
     A.GetPage(appPath + 'carConfig/getConfigSaving.aspx?mode=11&SavedName=' + savedName, '');
   } 
   catch( e ) 
   {
   } 
   finally 
   {
   }
  }

//END OF CONFIGURATION SAVING

//UTILITIES//
function manageKeyByRegex(e, inputObj, pattern, flag, strToEval, maxlength)
{
	var charCode = getKey(e);
	if ((charCode == 8) || (charCode == 127)) return true;
	if (isKeyEnter(charCode))
	{ 
		eval(strToEval);
		return false;
    }
    var r = new RegExp(pattern,flag);
    var maxLengthTest = maxlength ? inputObj.value.length < parseInt(maxlength) : true; 
    return maxLengthTest && r.test(String.fromCharCode(charCode));
}
//END OF UTILITIES//

//getModule functions
function ccbc1()
{
    document.getElementById("divContent").innerHTML = '';
    submitFormToDiv("carConfigBuildCompact1", "<%=Utility.appPath%>clientModules/carConfigBuildCompact.aspx?getModel=1", "divContent");
    getContent();
}
  //var timeOut = 5000;
  //var i = 0;
  function getContent()
  {
    timerGetContent();
  }
  function timerGetContent()
  {  
     if (i >= timeOut) return;
     if (document.getElementById("divContent").innerHTML == '')
     {
        setTimeout("timerGetContent()",10);
        i += 10;
        if (i >= timeOut) 
        {
            alert("Request timed out ... Please try again");
            i = 0;
            return;
        }
     }
     else
     {
       window.parent.gotoStep2(document.getElementById("divContent").innerHTML);
     }
  }
//
