/*

*/

var prevImg = 'mm_promo_img_1';
var prevRndNr = -1;

function mobilemoneysale(ordernumber, pos) {
	mmrefname = 'msn_nl_mxp_messenger';
	mmlanguage = mxplang;
	mmpskin = 'mxp_messenger';

    if (pos == undefined || pos == '') {
        pos = mxppos;
    }

	window.open('http://www.mobilemoney.com/salespopup.asp?country=31&pos='+pos+'&ordernumber='+escape(ordernumber)+'&refname='+escape(mmrefname)+'&language='+escape(mmlanguage)+'&popupskin='+escape(mmpskin),'popup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=468,height=550,left='+eval((screen.availWidth/2)-234)+',top=50');
}

function listenwindow(listenurl) {
	window.open(listenurl, 'Listen', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=150,height=150,left='+eval((screen.availWidth/2)-75)+',top=50');
}

function helpform(country, language) {
	mmrefname = 'msn_nl_mxp_messenger';
	mmlanguage = language;
	mmpskin = 'mxp_messenger';
//	mmpskin = '';
    window.open('http://www.mobilemoney.com/salespopup.asp?country='+country+'&cat=30,42,43&refname='+mmrefname+'&language='+mmlanguage+'&action=help&popupskin='+mmpskin,'popup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=468,height=550,left='+eval((screen.availWidth/2)-234)+',top=50');
//	window.open('http://www.mobilemoney.com/salespopup.asp?refname='+mmrefname+'&language='+mmlanguage+'&action=help&popupskin='+mmpskin,'helppopup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=468,height=550,left='+eval((screen.availWidth/2)-234)+',top=50');
}

function getElementValue(elementname, elementattribute){
    return document.getElementById(elementname).getAttribute(elementattribute);
}

function seriousrequest() {
	window.open('http://www.mobilemoney.com/partners/3fm/3fm.asp','seriousrequest_popup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=468,height=400,left='+eval((screen.availWidth/2)-234)+',top='+eval((screen.availHeight/2)-(400/1.5)));
}

function getparam (lookfor) {
    var st  = new String(document.location);
    var start  = st.indexOf (lookfor);
    if (start != -1) {
        st = st.substring (start);
        start = st.indexOf ('=');
        st = st.substring (start+1);
        eind = st.indexOf ('&');
        if (eind == -1) {
            eind = st.length;
        }
        st = st.replace (/\+/g, ' ');
        var st = unescape (st.substring (0, eind));
    } else {
        st = ""
    }
    return st;
}

function preview_winksitem(productid) {
	wink_container = document.getElementById('mm_wink_preview_container');

	if (!wink_container) {
		mobilemoneysale(productid, '');
		return;
	}
	
	var h = 160;
	var w = 160;
	
	str = 
		'<div id="mm_wink_ie"><object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=6,0,0,0 width='+w+' height='+h+' id=obj align=center>' + 
		'  <param name=movie value=http://www.mobilemoney.com/partners/msnmessenger/webshop/wrapper.swf?ContentWidth=400&ContentHeight=400&MovieUrl=http://www.mobilemoney.com/content/winks/preview/' + productid + '.swf&ClickUrl=javascript:show_winkstaticpreview(' + productid + ')&EndUrl=javascript:show_winkstaticpreview(' + productid + ')>' +
		'  <param name=quality value=best>' + 
		'  <param name=bgcolor value=#ffffff>' +
		'  <embed src=http://www.mobilemoney.com/partners/msnmessenger/webshop/wrapper.swf?ContentWidth=400&ContentHeight=400&MovieUrl=http://www.mobilemoney.com/content/winks/preview/' + productid + '.swf&ClickUrl=javascript:show_winkstaticpreview(' + productid + ');&EndUrl=javascript:show_winkstaticpreview(' + productid + '); quality=best width='+h+' height='+w+' name=emb type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer/></embed>' + 
		'</object></div>';
	str = str + '<br /><br /><br /><br /><br /><a href="javascript:show_winkstaticpreview(' + productid + ');mobilemoneysale(' + productid + ');"><img src="images/' + mxplang + '/bestel_nu.gif" width="85" height="17" border="0" alt="" style="width:85px !important;height:17px !important;border:0 !important;"/></a>';

	wink_container.innerHTML = str;
}

function show_winkstaticpreview(productid, lang, translation) {
	wink_container = document.getElementById('mm_wink_preview_container');
	if (!wink_container) return;
	if (lang == '' || lang == undefined) {lang=mxplang;}
	str = 
		'<div id="mm_wink_ie"><a href="javascript:mobilemoneysale(' + productid + ');"><img src="http://www.mobilemoney.com/content/winks/preview/180x180/' + productid + '.jpg" /></a></div>';
	str = str + '<br /><br /><br /><br /><br /><a href="javascript:mobilemoneysale(' + productid + ');"><img src="images/' + lang + '/bestel_nu.gif" width="85" height="17" border="0" alt="' + translation + '" style="width:85px !important;height:17px !important;border:0 !important;"/></a>';

	wink_container.innerHTML = str;
}

function preview_ddpitem(productid) {
	ddp_container = document.getElementById('mm_ddp_preview_container');

	if (!ddp_container) {
		mobilemoneysale(productid, '');
		return;
	}
	str = 
		'<iframe src="preview_ddp_new.asp?productid=' + productid + '&language=nl" frameborder="0"></iframe>';

	ddp_container.innerHTML = str;
}


function randomAd(iType, country) {
    var newURL = '';
    var oldURL = '';

    if (prevImg == 'mm_promo_img_type_1_1') { 
        prevImg = 'mm_promo_img_type_' + iType.toString() + '_2';
        newURL = 'mm_promo_link_type_' + iType.toString() + '_2';
        oldURL = 'mm_promo_link_type_' + iType.toString() + '_1';
    } else {
        prevImg = 'mm_promo_img_type_' + iType.toString() + '_1';
        newURL = 'mm_promo_link_type_' + iType.toString() + '_1';
        oldURL = 'mm_promo_link_type_' + iType.toString() + '_2';
    }

    var rnd_no = Math.round((aImgs1.length-1)*Math.random());

	// Check to make sure both images don't show the same promo.
    var url1 = document.getElementById('mm_promo_link_type_' + iType.toString() + '_1').href;
    var url2 = document.getElementById('mm_promo_link_type_' + iType.toString() + '_2').href;

	switch (iType) {
	case 1:
		while (url1.indexOf(aImgs1[rnd_no][1]) > -1 || url2.indexOf(aImgs1[rnd_no][1]) > -1) {
 			rnd_no = Math.round((aImgs1.length-1)*Math.random());
		}
	break;
	case 2:
		while (url1.indexOf(aImgs2[rnd_no][1]) > -1) {
 			rnd_no = Math.round((aImgs2.length-1)*Math.random());
		}
	break;
	case 3:
		while (url1.indexOf(aImgs3[rnd_no][1]) > -1) {
 			rnd_no = Math.round((aImgs3.length-1)*Math.random());
		}
	break;
	}

    if (document.getElementById(prevImg)) {
	    document.getElementById(prevImg).src = 'images/promo/' + country + '/' + aImgs[rnd_no][0];
	    document.getElementById(prevImg).alt = aImgs[rnd_no][2];
	    document.getElementById(newURL).href = aImgs[rnd_no][1];
    }
}

function startRndAds (iType, country) {
    var id = setInterval('randomAd(' + iType.toString() + ',"' + country + '")', 5000);
}


function checkEmail(id) {
	el = document.getElementById(id);
	if(!el) return false;
	
	var exp = new RegExp("^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$");

	if (!exp.test(el.value)) {
		alert('Het opgegeven e-mailadres bevat een fout.');
		el.focus();
		el.select();
		return false;
	}
	
	return true;
}