/*
  name - name of the desired cookie
  return string containing value of specified cookie or null
  if cookie does not exist
*/

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function formSubmit()
{
	//TOMAS BACKUP PLAN
	//document.getElementById("ApplyForm").action = "https://www.gemoney.co.uk/application/TransformationCard/eligibility.html";
	
	
	document.getElementById('route').value = getCookie("route");
	document.getElementById('product').value = "0001";
	document.getElementById('banner').value = getCookie("banner");
	//alert('This is what we are sending in the form\n Field:      Value\n ------------------------------------------------------------------------\n route: '+document.getElementById('route').value+'\n product: '+document.getElementById('product').value+'\n banner: '+document.getElementById('banner').value);
	document.getElementById("ApplyForm").submit();
}

function loanSubmit(productCode)
{
	document.getElementById("LoanForm").action = "https://www.gemoney.co.uk/apply/gemoneyloans/apply.jsp ";
	document.getElementById('route').value = getCookie("route");
	document.getElementById('product').value = productCode;
	document.getElementById('banner').value = getCookie("banner");
	document.getElementById('viaCalc').value = 'N';
	//alert('This is what we are sending in the form\n Field:      Value\n ------------------------------------------------------------------------\n route: '+document.getElementById('route').value+'\n product: '+document.getElementById('product').value+'\n banner: '+document.getElementById('banner').value+'\n viaCalc: '+document.getElementById('viaCalc').value);
	document.getElementById("LoanForm").submit();
}


function loanCalcSubmit()
{
	document.getElementById("LoanForm").action = "https://www.gemoney.co.uk/apply/gemoneyloans/calculator.jsp";
	document.getElementById('route').value = getCookie("route");
	document.getElementById('product').value ='L142L143';
	document.getElementById('banner').value = getCookie("banner");
	document.getElementById('viaCalc').value = 'Y';
	//alert('This is what we are sending in the form\n Field:      Value\n ------------------------------------------------------------------------\n route: '+document.getElementById('route').value+'\n product: '+document.getElementById('product').value+'\n banner: '+document.getElementById('banner').value+'\n viaCalc: '+document.getElementById('viaCalc').value);
	document.getElementById("LoanForm").submit();
	
}

function loanSummarybox(productCode)
{
	document.getElementById("LoanForm").action = "https://www.gemoney.co.uk/apply/gemoneyloans/summarybox.jsp";
	document.getElementById('route').value = getCookie("route");
	document.getElementById('product').value = productCode;
	document.getElementById('banner').value = getCookie("banner");
	document.getElementById('viaCalc').value = 'Y';
	//alert('This is what we are sending in the form\n Field:      Value\n ------------------------------------------------------------------------\n route: '+document.getElementById('route').value+'\n product: '+document.getElementById('product').value+'\n banner: '+document.getElementById('banner').value+'\n viaCalc: '+document.getElementById('viaCalc').value);
	document.getElementById("LoanForm").submit();
}