
/******************************* INSTELLINGEN ************************************/

// Let op, deze pre_control ID moet worden aangepast om zo de juiste input-velden te vinden op de orderpagina
var pre_control_id = 'TabContainer1_TabPanel2_';
var url_passdata = '//digizon.nl/tnt_pakjegemak/tnt_files/tnt_passdata.htm'
var url_passdata_www = '//www.digizon.nl/tnt_pakjegemak/tnt_files/tnt_passdata.htm'




/******************************* SCRIPT DEFAULT WEBSITE ************************************/
function Check_TNT_afhaalpunt() {

	// CHECK tbAfleverNaam
	var tbAfleverNaam = document.getElementById('tbAfleverNaam');
	if (!tbAfleverNaam) {
		tbAfleverNaam = document.getElementById(pre_control_id + 'tbAfleverNaam');
	}
	if (!tbAfleverNaam) {
		alert('tnt_popup.js - function Check_TNT_afhaalpunt - input tbAfleverNaam niet gevonden');
		return true;
	}
	
	// CHECK cbTNT
	var cbTNT = document.getElementById('cbTNT');
	if (!cbTNT) {
		cbTNT = document.getElementById(pre_control_id + 'cbTNT');
	}
	if (!cbTNT) {
		alert('tnt_popup.js - function Check_TNT_afhaalpunt - input cbTNT niet gevonden');
		return true;
	}
	// SET CHECKBOX if TNT found in NAAM
	cbTNT.checked = (tbAfleverNaam.value.indexOf('TNT')>=0);
}



/******************************* SCRIPT FOR POPUP ************************************/

function Querystring(qs) { // optionally pass a querystring to parse
	this.params = new Object()
	this.get=Querystring_get

	if (qs == null)
					qs=location.search.substring(1,location.search.length)

	if (qs.length == 0) return

	qs = qs.replace(/\+/g, ' ')
	var args = qs.split('&') // parse out name/value pairs separated via &


	for (var i=0;i<args.length;i++) {
			var value;
			var pair = args[i].split('=')
			var name = unescape(pair[0])

			if (pair.length == 2)
							value = unescape(pair[1])
			else
							value = name

			this.params[name] = value
	}
}

function Querystring_get(key, default_) {
	// This line changes UNDEFINED to NULL
	if (default_ == null) default_ = null;

	var value=this.params[key]
	if (value==null) value=default_;

	return value
}




/***************************** SCRIPT TO FILL FORM FIELDS **************************/

var initialAddress;
var srcUrlAddress;
var srcUrlMode;
var srcUrlProductLabel;
var srcUrl;


function getAddress(){
   try
	{
	   var address = document.getElementById("txtAddressToPass").value;
   }
   catch(e)
   {
	   throw new Error("please fill in Address");
   }
   return address;
}

function initializeUrl()
{
	if (document.URL.indexOf('//www.') > 0) {
		// Yes add www. to passdata-url
	  srcUrl = "//www.locatiekiezer.nl/Default.aspx?apikey=74578603b188924d&productlabel=ZAD&stylesheet=&passdataurl=" + url_passdata_www;
	} else {
		// No, without www. to passdata-url
	  srcUrl = "//www.locatiekiezer.nl/Default.aspx?apikey=74578603b188924d&productlabel=ZAD&stylesheet=&passdataurl=" + url_passdata;
	}
}

function ShowPopup()
{
    initializeUrl();
    var popup = document.getElementById("divPopup");
    popup.style.display = "block";
    popup.style.left = "0px";
    popup.innerHTML = "<iframe id='iFramePopup' name='iFramePopup' src='" + srcUrl + "' frameborder='0' scrolling='no'></iframe>";
}

function ClosePopup()
{
	var popup = document.getElementById("divPopup");
	popup.style.display = "none";
}
