

function setcookie(name, value, expire){
	var timestamp=new Date(expire);
	document.cookie=name + "=" + escape(value) + "; expires=" + timestamp.toGMTString();
}

function setcookieDemopayment(name, value){
	document.cookie=name + "=" + escape(value) + ";";
}

function getcookie(name){
	var cookies = document.cookie.split(/;/);
	for(var i=0; i < cookies.length; i++){
		var mycook = cookies[i].split(/=/);
		if(mycook[0]==name)return unescape(mycook[1]);
	}
}

function YELLOWPAY_doPay(oPayForm, bShowWaitForPay){
	var sFormTarget = 'PaymentTerminal';
	var oWin = null;


	oWin = new SMPopup();

	with(oWin){
		targetName = sFormTarget;
		targetUrl = "https://yellowpay.postfinance.ch/checkout/Yellowpay.aspx?userctrl=Invisible";
		locationReplace = true;
		showScroll = true;
		showModal = false;
		pWidth = 800;
		pHeight = 560;
		openPage();
	};

	

	with(oPayForm){
		action = 'https://yellowpay.postfinance.ch/checkout/Yellowpay.aspx?userctrl=Invisible';
		target = sFormTarget;
		submit();
	};

	return(bShowWaitForPay);
};

function YELLOWPAY_setFieldValue(fieldName, fieldValue){
	switch(fieldName){
		case 'txtShopId':
			fieldValue = 'marderabwehr_yp'; break;
		case 'txtOrderIDShop':
			fieldValue =  SMShop.getAttribute("sid"); break;
		case 'txtOrderTotal':
			var oAmount = new cSMPrice();
			oAmount.decode(SMShop.basket.getAttribute(_SMAFinalSum));
			fieldValue = cprimary.format(Math.round(oAmount.gross * 20) / 20, SM_CNOFORMAT).toFixed(2);
			break;
		case 'txtBTitle':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_SALUTATION");break;
		case 'txtBLastName':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_LASTNAME"); break;
		case 'txtBFirstName':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_FIRSTNAME"); break;
		case 'txtBAddr1':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_STREET_1"); break;
		case 'txtBAddr2':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_STREET_1"); break;
		case 'txtBAddr1':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_STREET_1"); break;
		case 'txtBPostBox':
			fieldValue = '';
			break;
		case 'txtBZipCode':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_POSTCODE"); break;
		case 'txtBCity':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_CITY"); break;
		case 'txtBCountry':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_COUNTRY", true); break;
		case 'txtBTel':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_PHONE_NUMBER");break;
		case 'txtBFax':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_FAX_NUMBER");break;
		case 'txtBEmail':
			fieldValue = SMShop.getFormValue("BILLTO", "BILLTO_EMAIL"); break;
		case 'txtHash':
			var str;
			var oAmount = new cSMPrice();
			oAmount.decode(SMShop.basket.getAttribute(_SMAFinalSum));
			str = 4103 + "CHF" + cprimary.format(Math.round(oAmount.gross * 20) / 20, SM_CNOFORMAT).toFixed(2) + decodeURI("4v13IYo7hc_%7Bs0=%7DN");
			fieldValue = hex_md5(str);
		    	break;

		case 'txtHistoryBack':
			fieldValue = "false";
			break;
	};
	return(fieldValue);
};

function YELLOWPAY_removePayFormFields(){
	return(true);
};

function YELLOWPAY_setForwardPayformFieldNames(){
	var sFields = ''; // semicolon separated string with paymethods formfields to show in ordermail
	return(sFields);
};

function YELLOWPAY_setResponseQueryCaptions(param){
	var sCaption = '';
	switch(param.toLowerCase()){
		case 'transid': sCaption = 'Transaktionsnr.'; break;
		default: sCaption = param;
	};
	return(sCaption);
};
