var currentDeal;

function bookNow(id) {
	currentDeal = id;
	lBoxOn('lBoxBookNow');
}

var msg = {
    noName: 'Please tell us your name',
    noEmail: 'You must supply an email address',
    noFName: 'Please tell us your friends name',
    noFEmail: 'You must supply an email address for your friend'
}

function booknowSubmit() {
    if (isEmpty('bookname', msg.noName)) return;
    if (isEmpty('bookemail', msg.noEmail)) return;
	var d = currentDeal;
	xhr('/shotleft/iMail.ashx?req=booknow&touremail=' + elv('touremail' + d) + '&email=' + elv('bookemail') + '&name=' + elv('bookname') + '&title=' + elv('title' + d) + '&price=' + elv('price' + d) + '&option=' + elv('option' + d) + '&type=' + elv('type' + d) + '&mode=' + elv('mode' + d) + '&valid=' + elv('valid' + d).replace('Valid from ', '') + '&province=' + elv('province' + d), bookNowSubmit_r, 'booknowLoading');
	el('myname').value = elv('bookname');
}

function bookNowSubmit_r(r) {
	lBoxSuccess('BookNow');
}

function dealSendToFriend(id) {
	currentDeal = id;
	lBoxOn('lBoxDealSendToFriend')
}

function dealSendToFriendSubmit() {
    if (isEmpty('myname', msg.noName)) return;
    if (isEmpty('friendname', msg.noFName)) return;
    if (isEmpty('friendemail', msg.noFEmail)) return;
	var d = currentDeal;
	xhr('/shotleft/iMail.ashx?req=dealsendtofriend&myname=' + elv('myname') + '&friendemail=' + elv('friendemail') + '&friendname=' + elv('friendname') + '&title=' + elv('title' + d) + '&price=' + elv('price' + d) + '&option=' + elv('option' + d) + '&type=' + elv('type' + d) + '&mode=' + elv('mode' + d) + '&valid=' + elv('valid' + d).replace('Valid from ', '') + '&province=' + elv('province' + d), dealSendToFriendSubmit_r, 'dealsendtofriendLoading');
	el('bookname').value = elv('myname');
}

function dealSendToFriendSubmit_r(r) {
	lBoxSuccess('DealSendToFriend');
}

function dealreferSubmitSpotlight() {
	var axel = Math.random()+"";
	var a = axel * 10000000000000;
	
	document.getElementById('spotlightDealRefFriend').src="http://fls.doubleclick.net/activityi;src=2085640;type=shotl560;cat=consu316;ord=1;num="+ a + "?";
	//document.write('<div style="height:0px;width:0px;padding:0px;margin:0px;"><iframe src="http://fls.doubleclick.net/activityi;src=2085640;type=shotl560;cat=consu316;ord=1;num='+ a + '?"" width="1" height="1" frameborder="0"></iframe></div>');
}

function dealBookSubmitSpotlight() {
	var axel = Math.random()+"";
	var a = axel * 10000000000000;
	
	document.getElementById('spotlightDealBook').src="http://fls.doubleclick.net/activityi;src=2085640;type=shotl560;cat=consu700;ord=1;num=" + a + "?";
	//document.write('<div style="height:0px;width:0px;padding:0px;margin:0px;"><iframe src="http://fls.doubleclick.net/activityi;src=2085640;type=shotl560;cat=consu316;ord=1;num='+ a + '?"" width="1" height="1" frameborder="0"></iframe></div>');
}

function SendToFriendMany() {
    lBoxOn('lBoxSendToFriendMany')
}

function SendToFriendManySubmit() {
    var msg = "";
    if (!el('cbTermsRefer').checked ) msg += "  Terms\n";

    if (msg == "") {
        xhr('/shotleft/iMail.ashx?req=SendToFriendMany&myname=' + elv('myname') + '&myemail=' + elv('myemail') + '&mycell=' + elv('mycell') + '&friendemail1=' + elv('friendemail1') + '&friendname1=' + elv('friendname1') + '&friendemail2=' + elv('friendemail2') + '&friendname2=' + elv('friendname2') + '&friendemail3=' + elv('friendemail3') + '&updateMobile=' + el('updateMobile').checked + '&updateEmail=' + el('updateEmail').checked, SendToFriendManySubmit_r, 'sendtofriendmanyLoading');
    } else {
    alert("Please accept the terms and conditions");
    }
}

function SendToFriendManySubmit_r(r) {
    lBoxSuccess('SendToFriendMany');
}



function SendSubscribeHotDeals() {
    lBoxOn('lBoxSubscribeHotDeals')
}

function SubscribeHotDealsSubmit() {
    var msg = "";
    if (elv('thename') == undefined) msg += "  Your name\n";
    if (elv('thesurname') == undefined) msg += "  Your surname\n";
    if ( (elv('thecell') == undefined)  && (elv('theemail') ) == undefined) msg += "  Mobile and/or email\n";
    if (el('theprovince').selectedIndex==0) msg += "  Province\n";

    if (msg == "") {
        xhr('/shotleft/iMail.ashx?req=SubscribeHotDeals&thename=' + elv('thename') + '&thesurname=' + elv('thesurname') + '&thecell=' + elv('thecell') + '&theemail=' + elv('theemail') + '&theprovince=' + el('theprovince')[el('theprovince').selectedIndex].value + '&cbMobile=' + el('cbMobile').checked + '&cbEmail=' + el('cbEmail').checked + '&cbDeals=' + el('cbDeals').checked + '&cbCompetitions=' + el('cbCompetitions').checked, SubscribeHotDealsSubmit_r, 'subscribehotdealsLoading');
    } else {
        alert("Please complete the following:\n" + msg);
    }
}

function SubscribeHotDealsSubmit_r(r) {
    lBoxSuccess('SubscribeHotDeals');
}