var securePath = 'https://www.lokiero.es';
//https://www.lokiero.es
var t = null;

function scrollSideDeal()
{
  if (document.getElementById("divSide"))
  {
     //the_timeout=setTimeout('moveDiv("divSide");',10);
     moveDiv('divSide');
     //document.getElementById("divSide").style.top = (window.pageYOffset+94)+'px';
     //alert(document.body.scrollTop);
     //alert(window.pageYOffset);
  }
}

function getStyleObject(objectId)
{
    // cross-browser function to get an object's style object given its
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
}

function moveDiv(aDiv)
{
  // get the stylesheet
  //
  var the_style = getStyleObject(aDiv);
  if (the_style)
  {
    // get the current coordinate and add 5
    //
    var current_top = parseInt(the_style.top);
    var distance = ((window.pageYOffset+94)-current_top);
    if (distance>0)
    {
      var direction = 1;
      var new_top = current_top + (distance/80);
    }
    else
    {
      var direction = 2;
      var new_top = current_top - (distance/80);
    }
    window.defaultStatus = distance +'px';

    // set the top property of the DIV, add px at the
    // end unless this is NN4
    //
    if (document.layers)
    {
      the_style.top = new_top;
    }
    else
    {
      the_style.top = new_top + "px";
    }

    // if we haven't gone to far, call moveDiv() again in a bit
    //
    if (direction == 1)
    {
       if (new_top < (window.pageYOffset+94))
       {
         the_timeout = setTimeout('moveDiv("divSide");',2);
       }
    }
    else
    {
       if (new_top > (window.pageYOffset+94))
       {
         the_timeout = setTimeout('moveDiv("divSide");',2);
       }
    }
  }
}

//------------------------------------------------------------------------------
function hello()
{
  alert('hello');
}
//------------------------------------------------------------------------------
function strAfter(aNeedle, aHaystack)
{
  if (aHaystack.indexOf(aNeedle)>-1)
  {
     return aHaystack.substring(aHaystack.indexOf(aNeedle) + aNeedle.length);
  }
  else
  {
     return aHaystack;
  }
}
//------------------------------------------------------------------------------
function strBefore(aNeedle, aHaystack)
{
  if (aHaystack.indexOf(aNeedle)>-1)
  {
     return aHaystack.substring(0, aHaystack.indexOf(aNeedle));
  }
  else
  {
     return aHaystack;
  }
}
//------------------------------------------------------------------------------
function getStyle(aElement, styleProp)
{
	var x = aElement;
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}
//------------------------------------------------------------------------------
function showObject(aObject, aObjName)
{
  var objResult = "";
  for (var Property in aObject)
  {
     objResult += aObjName + "." + Property + " = " + aObject[Property] + "\n\r";
  }
  alert(objResult);
}
//------------------------------------------------------------------------------
function delay(aMilliSeconds)
{
  var date = new Date();
  var curDate = null;

  do { curDate = new Date(); }
  while(curDate-date < aMilliSeconds);
}
//------------------------------------------------------------------------------
function hello()
{
	alert('hello');
}
//------------------------------------------------------------------------------
function showMap(aLat, aLng)
{
  if (GBrowserIsCompatible())
  {
    var map = new GMap2(document.getElementById("divMap"));
    map.addControl(new GSmallMapControl());
    //map.addControl(new GMapTypeControl());

    map.setCenter(new GLatLng(aLat, aLng), 15);

    var position = new GLatLng(aLat, aLng);
    var marker   = new GMarker(position);
    map.addOverlay(marker);
  }
}
//------------------------------------------------------------------------------
function createParamStr(aForm)
{
   var paramstr = '';
   for (var i=0; i<aForm.length; i++)
   {
     if((aForm[i].className == 'inputxCheckout') && (aForm[i].value==''))
     {
        alert('Por favor, rellena los campos obligatorios.');
        aForm[i].focus();
        return false;
     }
     if(aForm[i].type == 'checkbox')
     {
        if (aForm[i].checked)
        {
           paramstr += '&'+ strAfter('input',aForm[i].name) +'='+aForm[i].value;
        }
     }
     else
     {
        paramstr += '&'+ strAfter('input',aForm[i].name) +'='+encodeURIComponent(aForm[i].value);
     }
   }
   return paramstr;
}
//------------------------------------------------------------------------------
function checkReturn(aEvent)
{
  aEvent = aEvent || window.event;
  if((aEvent.keyCode==13) || (aEvent.which == 13))
  {
     return true;
  }
  return false;
}
//------------------------------------------------------------------------------
function getCenterPosition(aWidth, aHeight)
{
  var wHeight = aHeight;
  var wWidth  = aWidth;
  var wLeft   = parseInt(parseInt(screen.width/2)  - parseInt(wWidth/2));
  var wTop    = parseInt(parseInt(screen.height/2) - parseInt(wHeight/2));
  return('width='+wWidth+', height='+wHeight+', left='+wLeft+', top='+wTop);
}
//------------------------------------------------------------------------------
function getCentered(aWidth)
{
  totalWidth = 952;
  //totalWidth = document.getElementById('PageWrapper').style.width;
  var wLeft   = parseInt(parseInt(totalWidth/2)  - parseInt(aWidth/2));
  //wLeft       = Math.max(parseInt(wLeft - 160),20);
  return parseInt(wLeft);
}
//------------------------------------------------------------------------------
function getScrollPos()
{
  var result = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
  return result;
}
//------------------------------------------------------------------------------
function doLogin(aEmail, aPassword, aSource)
{
  var fafterRequest = 	function(returnValue, evalThis)
  							{
                          if (returnValue=='true')
                          {
                             //getDiv('lddfunc.php', 'divPaySecureForm', 'getpayformloggedin', null);
                          }
                       };
  if (aSource=='paysecure')
  {
     getDiv('lddfunc.php','divRegisterSecure','login&aemail=' + aEmail + '&apassword=' + aPassword, fafterRequest);
  }
  else
  {
     getDiv('lddfunc.php','divPaySecureForm','login&aemail=' + aEmail + '&apassword=' + aPassword, fafterRequest);
  }
  
}
//------------------------------------------------------------------------------
function doLogout()
{
  var fafterRequest = 	function(returnValue, evalThis)
  							{
                          getDiv('lddfunc.php', 'divPaySecureForm',    'getpayformnotloggedin', null);
                       };
  getDiv('lddfunc.php','divLoginSecure','logout', fafterRequest);
}
//------------------------------------------------------------------------------
function doLogoutIndex(aMsg)
{
  var fafterRequest = 	function(returnValue, evalThis)
  							{
                          getDiv('lddfunc.php', 'divHeadMenu', 'showloggedin', null);
                          getDiv('lddfunc.php', 'divLoginSignin', 'showindexlogin', null);
                          alert(aMsg);
                       };
  getDiv('lddfunc.php','divLoginSecure','logout', fafterRequest);
}
//------------------------------------------------------------------------------
function doPartnerLogin(aEmail, aPassword)
{
  getDiv('../lddfunc.php','divShopData','partnerlogin&aemail=' + aEmail + '&apassword=' + aPassword, null);
}
//------------------------------------------------------------------------------
function doPartnerLogout()
{
  getDiv('../lddfunc.php','divShopData','partnerlogout', null);
}
//------------------------------------------------------------------------------
function checkMail(aThis)
{
  var fafterRequest = 	function(returnValue, evalThis)
  							{
                          eval(evalThis);
                       };
  if (aThis.value!='')
  {
     getDiv('lddfunc.php', 'divPassword', 'checkmail&amail='+aThis.value, fafterRequest);
  }
}
//------------------------------------------------------------------------------
function comparePassword(aPassword, aRepeatPassword)
{
   if(aPassword==aRepeatPassword)
   {
      document.getElementById('divPasswordOk').innerHTML = '<img src="img/checked.png">';
   }
   else
   {
      document.getElementById('divPasswordOk').innerHTML = '<img src="img/checked.png" style="visibility: hidden;">';
   }
}
//------------------------------------------------------------------------------
function getLoginInfo()
{
   getDiv('logininfo.inc.php', 'divPassword', '', null);
}

//------------------------------------------------------------------------------
function doRegister(aForm, aSource, aPasswordMessage, aLengthMessage)
{
  var fafterRequest = 	function(returnValue, evalThis)
                        {
                          if (returnValue=='true')
                          {
                             //getDiv('lddfunc.php', 'divPaySecureForm',    'getpayformloggedin', null);
                          }
                        };
  var paramstrclient 	= createParamStr(aForm);
  if (paramstrclient==false) return false;
  if (aForm.elements['inputPassword'].value != aForm.elements['inputRepeatPassword'].value)
  {
    alert(aPasswordMessage);
    return false;
  }
  if (aForm.elements['inputPassword'].value.length < 2)
  {
    alert(aLengthMessage);
    return false;
  }
  if (aSource=='paysecure')
  {
     getDiv('lddfunc.php', 'divRegisterSecure', 'createclient'+paramstrclient, fafterRequest);
  }
  else
  {
     getDiv('lddfunc.php', 'divPaySecureForm', 'createclient'+paramstrclient, fafterRequest);
  }
  return true;
}
//------------------------------------------------------------------------------
function updateRegister(aForm)
{
  var fafterRequest = 	function(returnValue, evalThis)
  							{
                       };
  var paramstrclient 	= createParamStr(aForm);
  if (paramstrclient==false) return false;
  getDiv('lddfunc.php', null, 'updateclient'+paramstrclient, fafterRequest);
  alert('Gracias por actualizar tus datos.');
}
//------------------------------------------------------------------------------
function saveProspect(aForm)
{
  var fafterRequest = 	function(returnValue, evalThis)
  							{
                       };
  var paramstrprospect = createParamStr(aForm);
  if (paramstrprospect==false) return false;
  getDiv('lddfunc.php', 'divProspectData', 'createprospect'+paramstrprospect, null);
}
//------------------------------------------------------------------------------
function saveShippingData(aForm)
{
  var fafterRequest = 	function(returnValue, evalThis)
  							{
                       };
  var paramstrprospect = createParamStr(aForm);
  if (paramstrprospect==false) return false;
  getDiv('lddfunc.php', 'divShippingData', 'updateshippingdata'+paramstrprospect, null);
}
//------------------------------------------------------------------------------
function saveRecommended(aForm)
{
  var fafterRequest = 	function(returnValue, evalThis)
  							{
                       };
  var paramstrprospect = createParamStr(aForm);
  if (paramstrprospect==false) return false;
  //alert(paramstrprospect);
  getDiv('lddfunc.php', 'divProspectData', 'createrecommended'+paramstrprospect, null);
}
//------------------------------------------------------------------------------
function sendNewPw(aForm)
{
  var fafterRequest = 	function(returnValue, evalThis)
  							{
                       };
  var paramstrpw = createParamStr(aForm);
  if (paramstrpw==false) return false;
  getDiv('lddfunc.php', 'divProspectData', 'sendnewpw'+paramstrpw, null);
}
//------------------------------------------------------------------------------
function createNewPw(aForm)
{
  var fafterRequest = 	function(returnValue, evalThis)  							{
                       };
  var paramstrpw = createParamStr(aForm);
  if (paramstrpw==false) return false;
  //alert(paramstrpw);
  getDiv('lddfunc.php', 'divProspectData', 'createnewpw'+paramstrpw, null);
}
//------------------------------------------------------------------------------
function shareToFacebook(u,t)
{
  a = new Date();
  b     = a.getHours();
  c     = a.getMinutes();
  d      = a.getSeconds();
  aTime = b+':'+c+':'+d;
  window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'?'+aTime+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;
}
//------------------------------------------------------------------------------
function shareToTwitter(aMessage, aUrl)
{
  window.open('http://twitter.com/home/?status='+encodeURIComponent(aMessage)+' '+encodeURIComponent(aUrl),'sharer','toolbar=0,status=0,width=800,height=436');return false;
}

//------------------------------------------------------------------------------
function shareToMySpace(aMessage, aUrl)
{
  window.open('http://www.myspace.com/index.cfm?fuseaction=postto&u='+encodeURIComponent(aUrl)+'&t='+encodeURIComponent(aMessage),'sharer','toolbar=0,status=0,width=800,height=436');return false;
}
//------------------------------------------------------------------------------
function followToFacebook()
{
  window.open('http://www.facebook.com/pages/lokiero/125038357507062','follow','scrollbars=1,toolbar=0,status=0,'+ getCenterPosition(1024,600));return false;
}
//------------------------------------------------------------------------------
function followToTwitter()
{
  window.open('http://www.twitter.com/lokiero_es','follow','scrollbars=1,toolbar=0,status=0,'+ getCenterPosition(1024,600));return false;
}

//------------------------------------------------------------------------------
function showDeal(aDealId, aNL)
{
  if (!aDealId)
  {
     aDealId=0;
  }
  var fafterRequest =  function(returnValue, evalThis)
                       {
                          var aMainDealId   = document.getElementById('maindealid').value;
                          var aDealStop     = document.getElementById('dealstop'+aMainDealId).value;
                          callTimeLeft('divTime'+aMainDealId, aDealStop);
                          callSold('divSold'+aMainDealId, aMainDealId, aMainDealId);
                          eval(evalThis);
                          if (document.getElementById('mainimagesodis')) mainimage.Bas();
                       };
  getDiv('lddfunc.php','divDeal','showdeal&adealid='+aDealId+'&nl='+aNL, fafterRequest);
}
//------------------------------------------------------------------------------
function showSideDeals(aMainDealId)
{
  var fafterRequest =  function(returnValue, evalThis)
                       {
                          showAllTimesLeft();
                          showAllSold();
                       };
  getDiv('lddfunc.php','divSideDeals','showsidedeals&amaindealid='+aMainDealId, fafterRequest);
}
//------------------------------------------------------------------------------
function showTimeLeft(aTargetDiv, aDealStop)
{
  getDiv('lddfunc.php', aTargetDiv, 'showtimeleft&dealstop='+aDealStop, null);
}
//------------------------------------------------------------------------------
function callTimeLeft(aTargetDiv, aDealStop)
{
  showTimeLeft(aTargetDiv, aDealStop);
  setTimeout(function(){callTimeLeft(aTargetDiv, aDealStop);}, 60000);
}
//------------------------------------------------------------------------------
function showAllTimesLeft()
{
  var fafterRequest =  function(returnValue, evalThis)
                       {
                          eval(evalThis);
                       };

  getDiv('lddfunc.php', 'null', 'showalltimesleft', fafterRequest);
  setTimeout('showAllTimesLeft()', 60000);
}
//------------------------------------------------------------------------------
function showSold(aTargetDiv, aDealId, aMainDealId)
{
  //alert(aDealId+' '+aMainDealId);
  getDiv('lddfunc.php', aTargetDiv, 'showsold&adealid='+aDealId+'&amaindealid='+aMainDealId, null);
}
//------------------------------------------------------------------------------
function callSold(aTargetDiv, aDealId, aMainDealId)
{
  showSold(aTargetDiv, aDealId, aMainDealId),
  setTimeout(function(){callSold(aTargetDiv, aDealId, aMainDealId);}, 60000);
}

//------------------------------------------------------------------------------
function showAllSold()
{
  var fafterRequest =  function(returnValue, evalThis)
                       {
                          eval(evalThis);
                       };
  aMainDealId = document.getElementById('maindealid').value;
  getDiv('lddfunc.php', 'null', 'showallsold&amaindealid='+aMainDealId, fafterRequest);
  setTimeout('showAllSold()', 60000);
}

//------------------------------------------------------------------------------
function showCheckout(aDealId, aGift)
{
  var fafterRequest =  function(returnValue, evalThis)
                       {
                       };
  document.getElementById('divCheckout').style.left = '50px';
  document.getElementById('divCheckout').style.top  = parseInt(getScrollPos()+20)+'px';
  getDiv('lddfunc.php', 'divCheckout', 'showcheckout&dealid='+aDealId+'&gift='+aGift, fafterRequest);
}
//------------------------------------------------------------------------------
function showCheckoutDirect(aDealId)
{
  document.getElementById('divCheckout').style.left = '8px';
  getDiv('lddfunc.php', 'divCheckout', 'showcheckout&dealid='+aDealId, null);
}
//------------------------------------------------------------------------------
function hideCheckout()
{
  document.getElementById('divCheckout').style.left = '-2290px';
}
//------------------------------------------------------------------------------
function calculateCheckout(aQty, aPrice, aSaving)
{
  if (aQty<1) aQty=1;
  document.getElementById('inputTotalAmount').value = (aQty*aPrice).toFixed(2);
  document.getElementById('spanTotalSaving').innerHTML = (aQty*aSaving).toFixed(2);
  document.getElementById('AMOUNT').value = aQty*aPrice;
}
//------------------------------------------------------------------------------
function checkQty(aQty, aPrice, aSaving)
{
  if (aQty<1) aQty=1;
  if (aQty>20) aQty=20;
  document.getElementById('inputQuantity').value = aQty;
  document.getElementById('quantity').value = aQty;
  document.getElementById('inputTotalAmount').value = (aQty*aPrice).toFixed(2);
  document.getElementById('spanTotalSaving').innerHTML = (aQty*aSaving).toFixed(2);
  document.getElementById('AMOUNT').value = aQty*aPrice;
}
//------------------------------------------------------------------------------
function payNow(aDealId, aClientId, fDealData, fPayData, aMessage)
{
  if(!document.getElementById('cbTerms').checked)
  {
     alert(aMessage);
     document.getElementById('cbTerms').focus();
     return false;
  }
  var paramstrdeal     = createParamStr(fDealData);

  var fafterRequest  = function(returnValue)
                       {
                          var aOrderId   = strBefore(',', returnValue);
                          returnValue    = strAfter (',', returnValue);
                          var aTimeStamp = strBefore(',', returnValue);
                          returnValue    = strAfter (',', returnValue);
                          var aMD5Hash   = strBefore(',', returnValue);
                          returnValue    = strAfter (',', returnValue);
                          var aAmount    = returnValue;

                          document.getElementById('ORDER_ID').value       = aOrderId;
                          document.getElementById('TIMESTAMP').value      = aTimeStamp;
                          document.getElementById('MD5HASH').value        = aMD5Hash;
                          document.getElementById('AMOUNT').value         = aAmount;
                          //alert( 'Form Data: ' + document.getElementById('amount').value );
                          fPayData.submit();
                       };

  paramstrdeal +='&ClientId='+aClientId;
  paramstrdeal +='&DealId='+aDealId;
  getDiv('lddfunc.php', 'null', 'createdealorder'+paramstrdeal, fafterRequest);
}

//------------------------------------------------------------------------------
function payPayPal(aDealId, aClientId, fDealData, fPayPal, aMessage, aLoggedin, aLoginMessage)
{
  if(aLoggedin!=1)
  {
     alert(aLoginMessage);
     //document.getElementById('inputEmail').focus();
     return false;
  }
  if(!document.getElementById('cbTerms').checked)
  {
     alert(aMessage);
     document.getElementById('cbTerms').focus();
     return false;
  }
  var paramstrdeal     = createParamStr(fDealData);
  var fafterRequest  = function(returnValue)
                       {
                          var aOrderId   = strBefore(',', returnValue);
                          returnValue    = strAfter (',', returnValue);
                          var aTimeStamp = strBefore(',', returnValue);
                          returnValue    = strAfter (',', returnValue);
                          var aMD5Hash   = strBefore(',', returnValue);
                          returnValue    = strAfter (',', returnValue);
                          var aAmount    = returnValue;

                          document.getElementById('item_number').value    = aOrderId;

                          //alert(aAmount);
                          //alert( 'Amount: ' + document.getElementById('amount').value );

                          fPayPal.submit();
                       };

  paramstrdeal +='&ClientId='+aClientId;
  paramstrdeal +='&DealId='+aDealId;
  showCheckoutTransfer(10);
  getDiv('lddfunc.php', 'null', 'createdealorder'+paramstrdeal, fafterRequest);
}

//------------------------------------------------------------------------------
function transferToClient(aDealId, aClientId, fDealData, fPayPal, aMessage, aLoggedin, aLoginMessage)
{
  if(aLoggedin!=1)
  {
     alert(aLoginMessage);
     //document.getElementById('inputEmail').focus();
     return false;
  }
  if(!document.getElementById('cbTerms').checked)
  {
     alert(aMessage);
     document.getElementById('cbTerms').focus();
     return false;
  }
  var paramstrdeal     = createParamStr(fDealData);
  var fafterRequest  = function(returnValue)
                       {
                          var aOrderId   = strBefore(',', returnValue);
                          returnValue    = strAfter (',', returnValue);
                          var aTimeStamp = strBefore(',', returnValue);
                          returnValue    = strAfter (',', returnValue);
                          var aMD5Hash   = strBefore(',', returnValue);
                          returnValue    = strAfter (',', returnValue);
                          var aAmount    = returnValue;

                          document.getElementById('item_number').value    = aOrderId;

                          //alert(aAmount);
                          //alert( 'Amount: ' + document.getElementById('amount').value );

                          //window.location='https://postpago.masmovil.es/signup.jsp?wlang=es&show=true&dealerid=C01497&usercode=C01497&show=true&moda=coml';
			  window.location='https://alta.masmovil.es/index.php?product_codename=lokiero&web_dealer=C01497';

                       };

  paramstrdeal +='&ClientId='+aClientId;
  paramstrdeal +='&DealId='+aDealId;
  //showCheckoutTransfer(10);
  getDiv('lddfunc.php', 'null', 'createdealorder'+paramstrdeal, fafterRequest);
}

//------------------------------------------------------------------------------
function paySSL(aForm)
{
  window.name = 'basePage';
  paramstr    = 'scrollbars=1, toolbar=0, status=0, '+ getCenterPosition(1000,700);
  window.open(securePath+'/paysecure.php','paysecure', paramstr);
}
//------------------------------------------------------------------------------
function loginSSL()
{
  window.name = 'basePage';
  window.onfocus = function(){
                                getDiv('lddfunc.php', 'divHeadMenu', 'showloggedin', null);
                                getDiv('lddfunc.php', 'divLoginSignin', 'showindexlogin', null);
                             };
  paramstr    = 'scrollbars=1, toolbar=0, status=0, '+ getCenterPosition(800,440);
  window.open(securePath+'/loginsecure.php','loginsecure', paramstr);
}
//------------------------------------------------------------------------------
function newpwSSL()
{
  paramstr    = 'scrollbars=1, toolbar=0, status=0, '+ getCenterPosition(800,600);
  window.open(securePath+'/newpw.php','newpw', paramstr);
}
//------------------------------------------------------------------------------
function yourbusinessSSL(aForm)
{
  paramstr    = 'scrollbars=1, toolbar=0, status=0, '+ getCenterPosition(800,600);
  window.open(securePath+'/yourbusinesssecure.php','yourbusinesssecure', paramstr);
}
//------------------------------------------------------------------------------
function recommendSSL(aForm)
{
  paramstr    = 'scrollbars=1, toolbar=0, status=0, '+ getCenterPosition(800,600);
  window.open(securePath+'/recommendsecure.php','recommendsecure', paramstr);
}
//------------------------------------------------------------------------------
function mySSL(aForm)
{
  paramstr    = 'scrollbars=1, toolbar=0, status=0, '+ getCenterPosition(800,600);
  window.open(securePath+'/mysecure.php','mysecure', paramstr);
}
//------------------------------------------------------------------------------
function showVoucher(aVoucher)
{
  paramstr    = 'scrollbars=1, toolbar=0, status=0, '+ getCenterPosition(800,600);
  window.open(securePath+'/pdfout.php?p='+aVoucher+'.pdf','showvoucher', paramstr);
}
//------------------------------------------------------------------------------
function showPromotion(aDealId)
{
  paramstr    = 'scrollbars=1, toolbar=0, status=0, '+ getCenterPosition(800,600);
  window.open('dealreport.php?d='+aDealId,'showreport', paramstr);
}
//------------------------------------------------------------------------------
function showWhatIs()
{
  document.getElementById('divWhatIs').style.left = '-800px';
  resizeElement('divWhatIs',800, 500, 80, 120, '');
}
//------------------------------------------------------------------------------
function hideWhatIs()
{
  document.getElementById('divWhatIs').style.left = '-3100px';
}
//------------------------------------------------------------------------------
function showSelectLocation()
{
  var fafterRequest =  function()
                       {
                          document.getElementById('divSelectLocation').style.left = '-600px';
                          resizeElement('divSelectLocation',600, 450, 140, 130, '');
                       };
  getDiv('selectlocations.php', 'divSelectLocation', 'x', fafterRequest);
}
//------------------------------------------------------------------------------
function hideSelectLocation()
{
  document.getElementById('divSelectLocation').style.left = '-4235px';
}
//------------------------------------------------------------------------------
function showFAQ(aTop)
{
  showSlide(aTop, 'divFAQ', 600, 800);
}
//------------------------------------------------------------------------------
function showSubscribe(aTop)
{
  showSlide(aTop, 'divSubscribe', 500, 800)
}
//------------------------------------------------------------------------------
function showInvite(aTop)
{
  showSlide(aTop, 'divInvite', 500, 800)
}
//------------------------------------------------------------------------------
function showContactUs(aTop)
{
  showSlide(aTop, 'divContactUs', 400, 600)
}
//------------------------------------------------------------------------------
function showTerms(aTop)
{
  showSlide(aTop, 'divTerms', 600, 800)
}
//------------------------------------------------------------------------------
function showCheckoutTerms(aTop)
{
  showSlide(0, 'divTerms', 400, 800)
}
//------------------------------------------------------------------------------
function showCheckoutTransfer(aTop)
{
  showSlide(0, 'divTransfer', 400, 600)
}
//------------------------------------------------------------------------------
function showWho(aTop)
{
  showSlide(aTop, 'divWho', 600, 800)
}
//------------------------------------------------------------------------------
function showSocial(aTop)
{
  showSlide(aTop, 'divSocial', 440, 600)
}
//------------------------------------------------------------------------------
function showSubscribeFirst(aTop)
{
  showSlide(aTop, 'divSubscribeFirst', 590, 760)
}
//------------------------------------------------------------------------------
function showLanding(aTop)
{
  //showSlide(aTop, 'divPlatformLanding', 660, 760)
  var aSlide               = document.getElementById('divPlatformLanding');
  aSlide.style.minheight   = '500px';
  aSlide.style.width       = '900px';
  aSlide.style.left        = getCentered(parseInt(900))+'px';
  aSlide.style.top         = parseInt(getScrollPos()+aTop)+'px';
  fadeIn(aSlide);
}

//------------------------------------------------------------------------------

function showAllDeals(aTop, aMainDealId)
{
   var fafterRequest =  function()
                       {
                          var aSlide               = document.getElementById('divAllDeals');
                          aSlide.style.minheight   = '500px';
                          aSlide.style.width       = '900px';
                          aSlide.style.left        = getCentered(parseInt(900))+'px';
                          aSlide.style.top         = parseInt(getScrollPos()+aTop)+'px';
                       };
   getDiv('alldeals.php', 'divAllDeals', '&i='+aMainDealId, fafterRequest);
  //fadeIn(aSlide);
}//------------------------------------------------------------------------------

function showPromoConditions(aTop)
{
  showSlide(aTop, 'divPromoConditions', 440, 440)
}
//------------------------------------------------------------------------------
function showSlide(aTop, aSlideName, aHeight, aWidth, aOffset)
{
  if (!aOffset) aOffset=0;
  var aSlide          = document.getElementById(aSlideName);
  var aMargin         = parseInt(aWidth/2)
  aSlide.style.height = aHeight+'px';
  aSlide.style.width  = aWidth+'px';

  aSlide.style.left   = getCentered(parseInt(aWidth+aOffset))+'px';
  aSlide.style.top    = parseInt(getScrollPos()+aTop)+'px';
  //fadeIn(aSlide);
}
//------------------------------------------------------------------------------
function hideSlide(aSlideName)
{
  document.getElementById(aSlideName).style.left = '-1920px';
}

//------------------------------------------------------------------------------
function selectLocation(aLocationId, aLocationName)
{
  aLocationName = strAfter(': ', aLocationName);
  //alert(aLocationName);
  var fafterRequest =  function(returnValue)
                       {
                          showDeal();
                       };
  getDiv('lddfunc.php', 'null', 'selectlocation&alocationid='+aLocationId+'&alocationname='+aLocationName, fafterRequest);
}
//------------------------------------------------------------------------------
function resizeElement(elementId, targetWidth, targetHeight, targetLeft, targetTop, direction)
{
  var aElement= document.getElementById(elementId);
  var aWidth  = parseInt(getStyle(aElement, 'width'));
  var aHeight = parseInt(getStyle(aElement, 'height'));
  var aLeft   = parseInt(getStyle(aElement, 'left'));
  var aTop    = parseInt(getStyle(aElement, 'top'));

  var aWidthDiff    = parseInt(targetWidth-aWidth);
  var aHeightDiff   = parseInt(targetHeight-aHeight);
  var aLeftDiff     = parseInt(targetLeft-aLeft);
  var aTopDiff      = parseInt(targetTop-aTop);

  if (t==null)
  {
     t= window.setInterval(function callFunc() {zoomElement(aElement, targetWidth, targetHeight, targetLeft, targetTop, aWidthDiff, aHeightDiff, aLeftDiff, aTopDiff, direction); }, 10);
  }
}
//------------------------------------------------------------------------------
function zoomElement(aElement, targetWidth, targetHeight, targetLeft, targetTop, aWidthDiff, aHeightDiff, aLeftDiff, aTopDiff, direction)
{
  var div     = 20;
  var aWidth  = parseInt(getStyle(aElement, 'width'))+parseInt(aWidthDiff/div);
  var aHeight = parseInt(getStyle(aElement, 'height'))+parseInt(aHeightDiff/div);
  var aLeft   = parseInt(getStyle(aElement, 'left'))+parseInt(aLeftDiff/div);
  var aTop    = parseInt(getStyle(aElement, 'top'))+parseInt(aTopDiff/div);

  if (Math.abs(aHeight-parseInt(targetHeight))<5)
  {
     aElement.style.width     = targetWidth+'px';
     aElement.style.height    = targetHeight+'px';
     aElement.style.left      = targetLeft+'px';
     aElement.style.top       = targetTop+'px';
     clearInterval(t);
     t = null;
  }
  else
  {
     aElement.style.width     = parseInt(aWidth)+'px';
     aElement.style.height    = parseInt(aHeight)+'px';
     aElement.style.left      = parseInt(aLeft)+'px';
     aElement.style.top       = parseInt(aTop)+'px';
  }

}

//------------------------------------------------------------------------------
function fadeIn(aElement)
{
  if (t==null)
  {
     t= window.setInterval(function callFunc() {fadeElement(aElement, 'in', 100); }, 20);
  }
}
//------------------------------------------------------------------------------
function fadeElement(aElement, direction, targetOpacity)
{
  var aOpacity            = parseFloat(getStyle(aElement, 'opacity'));
  var aNewOpacity         = parseFloat(aOpacity+0.02);
  aElement.style.opacity  = aNewOpacity;

  if ((aNewOpacity*100) >= targetOpacity)
  {
     aElement.style.opacity  = (targetOpacity/100);
     clearInterval(t);
     t = null;
  }
}

//------------------------------------------------------------------------------
function checkEmpty(aField, aTest)
{
  if (aField.value == aTest) aField.value = '';
}

//------------------------------------------------------------------------------
function doInvite(aList, aLoggedin, aMessage)
{
  if (aLoggedin!=1)
  {
     alert(aMessage);
     return false;
  }
  var fafterRequest =   function(returnValue, evalThis)
                        {
                           eval(evalThis);
                           showInvite(-30);
                       };
  getDiv('lddfunc.php', 'divInvite', 'doinvite&alist='+aList, fafterRequest);
}

//------------------------------------------------------------------------------
function doInviteByNL(aForm)
{
  var aparamStr = createParamStr(aForm);
  if (aparamStr==false) return false;
  var fafterRequest =   function(returnValue, evalThis)
                        {
                           eval(evalThis);
                           showInvite(-30);
                       };
  getDiv('lddfunc.php', 'divInvite', 'doinvitebynl'+aparamStr, fafterRequest);
}

//------------------------------------------------------------------------------
function doSubscribe()
{
  var aThis         =  document.getElementById('inputSubscribe');
  var aMail         =  aThis.value;
  var aLocationId   =  document.getElementById('selectLocation').value;

  var fafterRequest =  function(returnValue, evalThis)
  							{
                          eval(evalThis);
                          if (returnValue=='1')
                          {
                             getDiv('lddfunc.php', 'divSubscribe', 'dosubscribe&amail='+aMail+'&alocationid='+aLocationId, null);
                             showSubscribe(100);
                          }
                       };
  getDiv('lddfunc.php', 'null', 'checksubscriber&amail='+aMail+'&alocationid='+aLocationId, fafterRequest);
}

//------------------------------------------------------------------------------
function doSubscribeFirst()
{
  var aThis         =  document.getElementById('inputSubscribeFirst');
  var aMail         =  aThis.value;
  var aLocationId   =  document.getElementById('selectLocationFirst').value;
  var aPostalCode   =  document.getElementById('inputSubscribeFirstPostalCode').value;

  var fafterRequest =  function(returnValue, evalThis)
  							{
                          eval(evalThis);
                          if (returnValue=='1')
                          {
                             getDiv('lddfunc.php', 'divSubscribe', 'dosubscribe&amail='+aMail+'&alocationid='+aLocationId+'&apostalcode='+aPostalCode, null);
                             hideSlide('divSubscribeFirst');
                             showSubscribe(100);
                          }
                       };
  getDiv('lddfunc.php', 'null', 'checksubscriber&amail='+aMail+'&alocationid='+aLocationId, fafterRequest);
}

//------------------------------------------------------------------------------
function checkVoucher(aForm, aMsgOk, aMsgKeyError, aMsgDuplicate)
{
  var fafterRequest = 	function(returnValue, evalThis)
  							{
                          //alert(returnValue);
                          if (returnValue=='0')
                          {
                             if (confirm(aMsgOk))
                             {
                                getDiv('lddfunc.php', 'divShopDeals', 'redeemvoucher'+paramstrclient, fafterRequest);
                             }
                          }
                          if (returnValue=='1')
                          {
                             alert(aMsgKeyError);
                          }
                          if (returnValue=='2')
                          {
                             alert(aMsgDuplicate);
                          }
                       };
  var paramstrclient 	= createParamStr(aForm);
  //alert(paramstrclient);
  if (paramstrclient==false) return false;
  getDiv('../lddfunc.php', 'divShopData', 'checkvoucher'+paramstrclient, fafterRequest);
}


