/******************************************************************************
* eshopPayboxScript.js                                                        *
* ------------------                                                          *
*                                                                             *
* SECURED PAYMENT INTEGRATION IN PAGES                                        *
*                                                                             *
*******************************************************************************
*                                                                             *
* Copyright 2000-2006 Isotools, all right reserved                            *
*                                                                             *
******************************************************************************/


function displaySecuredOrderModes(amount, bChecked)
{
	var html = "<td align='left' class='fontColorStandardText fontFamilyStandardText fontSizeNormal'>";
	html += "<input type='hidden' name='date' value='" + htmlEncode(getCurrentDate()) + "'>";
	html += "<input type='hidden' name='montant' value='" + amount + "EUR'>";
	html += "<input type='hidden' name='basketCN'	value='" + cookieName + "'>";
	html += "<input type='hidden' name='coordCN' value='" + coordCookie + "'>";
	html += "<input type='hidden' name='lgue' value='" + userLang + "'>";
	html += "<input type='hidden' name='curCode' value='" + currencyCode + "'>";
	var checked = (bChecked)?" CHECKED" : "";
	html += "<input name='orderMode' type='radio' value='securedpayment'" + checked + ">" + thesaurus.paybox2;
	html += "</td>";
	return html;	
}

function validateSecuredOrder()
{
	// expiration date for cookies
	var exp = new Date();
	exp.setTime(exp.getTime() + (86400 * 1000 * 30));
	// make email body and save it in a cookie
	var strOrder = makeOrderMail('securedPayment');
	replace (strOrder, "\n", "<br>");
	strOrder = escape(strOrder);
	deleteCookie("mailOrder");
	setCookie("mailOrder", strOrder, exp);
	// record email to send order
	var orderRecipient = emailOrder;
	deleteCookie("orderRecipient");

	setCookie("orderRecipient", escape(orderRecipient), exp);
}

function showInstructionsSecured()

{
	var html = thesaurus.paybox1;
	return html;
}

function getSecuredOrderID(search)

{
	
	var infoArray = search.split("&");
	var i;
	
	for (i=0 ; i< infoArray.length ; i++)
	{
		var tmp = infoArray[i].split("=");
		
		if (tmp[0] == "orderID")
			return tmp[1];
	}
	return "???";

}

function getCurrentDate()
{
	var date = new Date();
	var strDay = "" + date.getDate();
	if (strDay.length == 1) strDay = "0" + strDay;
	var strMonth = "" + (date.getMonth() + 1);
	if (strMonth.length == 1) strMonth = "0" + strMonth;
	var strYear = "" + date.getFullYear ();
	var strHour = "" + (date.getHours());
	if (strHour.length == 1) strHour = "0" + strHour;;
	var strMin = "" + (date.getMinutes());
	if (strMin.length == 1) strMin = "0" + strMin;
	var strSec = "" + (date.getSeconds());
	if (strSec.length == 1) strSec = "0" + strSec;;
	var strDate = strDay + "/" + strMonth + "/" + strYear + ":" + strHour + ":" + strMin + ":" +strSec
	return strDate;
}

function htmlEncode( str )
{
	str = str.replace(/&/g, "&amp;" ) ;
	str = str.replace(/</g, "&lt;" ) ;
	str = str.replace(/>/g, "&gt;" ) ;
	str = str.replace(/\"/g, "&quot;" ) ;
	str = str.replace(/'/g, "&#x27;" ) ;
	return str ;
}