////////////////////////////////////////////////////////////////////////////////////////////////////
// manager.js: zorg voor de communicatie tussen hoofdwebsite en webshop
//
bOk = true;
strArgs = window.location.search.substring(1);
//alert('Webshop wordt gestart');
if (strArgs != '') {
	if (/dealercode/i.test(strArgs)) {
		bKeepArgs = false;
		if (/bestnr/i.test(strArgs)) {
			bKeepArgs = true;
		}
		sidval = Get_Cookie('sidval');
		if (sidval && sidval != '') {
			if (bKeepArgs) {
				strArgs = strArgs + '&PHPSESSID='+sidval;
			}else{
				strArgs = 'PHPSESSID='+sidval;
			}
		}
		
		// Start de webshop!
		arrDomain = document.domain.split('.');
		iLen = arrDomain.length;
		if (iLen > 0 && arrDomain[iLen - 1] == 'dev') {
			location = 'http://www.webshop2008.dev/?' + strArgs + '&nocookie=true';
		}else{
			location = 'http://webshop.unisoftware.nl/?' + strArgs + '&nocookie=true';
		}
		if (iLen > 0 && document.domain == 'www.kassapunt.dev') { 
			location = 'http://webshop.unisoftware.nl/?' + strArgs + '&nocookie=true';
		}
		
	}else if (/resizeframe/i.test(strArgs)) {
		sidval = '';
		arrArgs = strArgs.split('&');
		if (arrArgs.length > 1) {
			// Mogelijk sidval (sessionid) opgegeven
			if (/sidval/i.test(arrArgs[0])) {
				arrSidval = arrArgs[0].split('=');
				sidval = arrSidval[1];
				Set_Cookie('sidval', sidval, 120, '/', document.domain);
			}
			strArgs = arrArgs[1];
		}
		arrResize = strArgs.split('=');
		if (!isNaN(arrResize[1])) {
			iNewHeight = arrResize[1];
			if (iNewHeight < 500) { iNewHeight = 500; }
			if (parent && parent.parent && parent.parent != self) {
				// Tja niet echt mooi, maar het is niet anders
				parent.parent.document.getElementById('idWebshop').style.height = iNewHeight + 'px';
			}
		}else{
			bOk = false;
		}
	}else{
		bOk = false;
	}
}
if (!bOk) {
	alert('Script is fout aangeroepen');
}
