tijdsinterval = 100;
textarray = new Array();

textarray.push("Makita Web");

var i = 0;
var current_picture = 2;

function WindowStatus (text)
{
	window.status=text;
}

function changeWindowStatus()
{
	WindowStatus(textarray[i]);
	if(i == (textarray.length - 1))
	{
		i = 0;
	}
	else
	{
		i++;
	} 
	setTimeout("this.changeWindowStatus();", tijdsinterval); 
}

function showFilterInfo(id){
	if (document.getElementById(id)){
		document.getElementById(id).style.display = '';
	}
}

function hideFilterInfo(id){
	if (document.getElementById(id)){
		document.getElementById(id).style.display = 'none';
	}}

function rotatePictures(p1,l1,p2,l2,interval){
	
	div = document.getElementById('picture_right');
	
	if (current_picture == 1){
		picture = p2;
		link = l2;
		current_picture = 2;
	}else{
		picture = p1;
		link = l1;
		current_picture = 1;
	}
	

	if (link != '') txtStr = '<a href="' + link + '">';
	txtStr = txtStr + '<img src="' + picture + '" border="0" align="right">';
	if (link != '') txtStr = txtStr + '</a>';

	div.innerHTML = txtStr;
	
	
	setTimeout("rotatePictures('" + p1 + "','" + l1 + "','" + p2 + "','" + l2 + "','" + interval + "');",interval);
}


function imgRollOver(obj, img){
	obj.src = img;
}

function getallenonly(){
 if ((event.keyCode<48&&event.keyCode!=44&&event.keyCode!=45)||event.keyCode>57)
  return false
}

function numbersonly(){
	if ((event.keyCode<48&&event.keyCode!=45)||event.keyCode>57)
	return false
}

function checkTrillingsForm(){
	a = document.trillingsForm.waarde;
	if (a.value == '' || a.value.charAt(0) == ','){
	 alert('U dient een geldige waarde op te geven');
	 a.focus();
	 return;
	}
	
	document.trillingsForm.action	= 'page.asp';
	document.trillingsForm.submit();
}

function setResultCounter(result){
	if (document.getElementById('spanResult')){
		if (result == '') result = '0';
		document.getElementById('spanResult').innerHTML = result;
	}
}

function getItem(id, klasse){
 document.getElementById('div_item_1').style.display = 'none';
 document.getElementById('div_item_2').style.display = 'none';
 document.getElementById('td_item_1').className = 'left_producten_left_0';
 document.getElementById('td_item_2').className = 'left_producten_right_0';
 document.getElementById('link_item_1').className = 'left_producten_link';
 document.getElementById('link_item_2').className = 'left_producten_link';

 document.getElementById('div_item_' + id).style.display = '';
 document.getElementById('td_item_' + id).className = klasse;
 document.getElementById('link_item_' + id).className = 'left_producten_link_active';
}

function resizeSpacerImage(){
 if (document.getElementById('itemInfoTable')){
  if (document.getElementById('spacerImage')){
   img = document.getElementById('spacerImage');
   img.style.pixelHeight = document.getElementById('itemInfoTable').offsetHeight+100;
  }
 }
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function formDealerSubmit(){
 
 a = document.Upload.dealerlocator_picture;
 if (a.value != ''){
	 if ((Right(a.value,4) != '.jpg') && (Right(a.value,4) != 'jpeg')){
	 	alert('U dient een geldig formaat afbeelding te kiezen (jpg, jpeg)');
	 	a.focus;
	 	return;
	 }
 }

 document.Upload.action = 'dealerinfo_save.asp?dealer=1';
 document.Upload.submit();
}

function getInfo(title, content){
 info_div = document.getElementById('div_symbol_info');
 if (title == '' && content == ''){
 	info_div.innerHTML = '';
	info_div.style.display = 'none';
 }else{
	info_div.style.display = '';
	info_div.innerHTML = '<div class="symbol_info_title">' + title + '</div><div class="symbol_info_text">' + content + '</div>';
 }
}

function getMachineFilter(){
	document.forms['frmFilter'].submit();
}

function changeClass(id,klasse){
 element = document.getElementById(id);
 element.className = klasse;
}

function getBeroepsgroep(id){
 location.href = 'beroepsgroep_aanmeld.asp?id=' + id;
}

function changemenuitem(id,picture){
 img = document.getElementById(id);
 img.src = picture;
}

function changeSearchField(status){
 field = document.getElementById('input_searchfield');
 if (status == 'focus'){
  field.value = '';
 }
}

function changeSearchFieldGroups(status){
	field = document.getElementById('input_searchfield_groups');
	if (status == 'focus'){
		field.value = '';
	}
}

function changeSearchFieldGroupsMaktec(status){
	field = document.getElementById('input_searchfield_groups_maktec');
	if (status == 'focus'){
		field.value = '';
	}
}

function changeSearchFieldGroupsAcc(status){
	field = document.getElementById('input_searchfield_groups_acc');
	if (status == 'focus'){
		field.value = '';
	}
}

function changeSearchFieldIke(status){
 field = document.getElementById('input_searchfield_ike');
 if (status == 'focus'){
  field.value = '';
 }
}

function changeSearchField2(status){
 field = document.getElementById('input_searchfield_2');
 if (status == 'focus'){
  field.value = '';
 }
}

function changeDealerField(status){
 field = document.getElementById('postcode');
 if (status == 'focus'){
  field.className = 'inputfield_search_focus';
  field.value = '';
 }
}

function getSlim(id){
	URLPage = "/get_slim.asp";
	URLarg = "q=" + id
	ResponseText = AsyncHttpRequest(URLPage, URLarg, "POST", false);
	if (ResponseText != "500") {
		document.getElementById('div_slim').innerHTML = ResponseText
	}
}

function calculateLease(id){
	URLPage = "/get_lease.asp";
	URLarg = "q=" + id
	ResponseText = AsyncHttpRequest(URLPage, URLarg, "POST", false);
	if (ResponseText != "500") {
		textStr = ResponseText.split(";")
		document.getElementById('factor').innerHTML = textStr[1];
		document.getElementById('totaal').innerHTML = textStr[2];
	}
}

function changeDealerField2(status){
 field = document.getElementById('postcode2');
 if (status == 'focus'){
  field.className = 'inputfield_search_focus';
  field.value = '';
 }
}

function getSearchResults(result){
 div = document.getElementById('search_result');
 if (result == '') result = '0';
 div.innerHTML = result;
}

function checkSearch(){
 //searchfield = document.search.s1.value
 //strOrderByField = document.search.s2.value
 //strTable = document.search.s3.value
 zoekwoord = document.search.SValue.value
 if (zoekwoord == '' || zoekwoord == 'trefwoord/modelnummer'){
  alert('U dient een zoekcriteria op te geven');
 }else{
//  document.search.action = '/page.asp';
  document.search.action = '/page.asp';
  document.search.submit();
 }
}

function advSearchcheck() {
	zoekwoord = document.search.svalue.value
	if (zoekwoord == '' || zoekwoord == 'trefwoord/modelnummer'){
		alert('U dient een zoekcriteria op te geven');
		return false;
	} 
	return true;
}



function checkSearch2() {
 searchfield = document.search2.s1.value
 strOrderByField = document.search2.s2.value
 strTable = document.search2.s3.value
 zoekwoord = document.search2.SValue.value
 if (zoekwoord == '' || zoekwoord == 'trefwoord/modelnummer'){
  alert('U dient een zoekcriteria op te geven');
 }else{
  document.search2.action = '/page.asp';
  document.search2.submit();
 }
}

function setLocation(url) {
 window.top.location.href = url;
}

function checkSearchGroups() {
	searchfield = document.searchgroups.s1.value
	strOrderByField = document.searchgroups.s2.value
	strTable = document.searchgroups.s3.value
	zoekwoord = document.searchgroups.SValue.value
	if (zoekwoord == '' || zoekwoord == 'trefwoord/modelnummer') {
		alert('U dient een zoekcriteria op te geven');
	} else {
		document.searchgroups.action = '/page.asp';
		document.searchgroups.submit();
	}
}

function checkSearchGroupsMaktec() {
	searchfield = document.searchgroups_maktec.s1.value
	strOrderByField = document.searchgroups_maktec.s2.value
	strTable = document.searchgroups_maktec.s3.value
	zoekwoord = document.searchgroups_maktec.SValue.value
	if (zoekwoord == '' || zoekwoord == 'trefwoord/modelnummer') {
		alert('U dient een zoekcriteria op te geven');
	} else {
		document.searchgroups_maktec.action = '/page.asp';
		document.searchgroups_maktec.submit();
	}
}

function checkSearchSpecials() {
	zoekwoord = document.searchspecials.SValue.value
	if (zoekwoord == '' || zoekwoord == 'trefwoord/modelnummer') {
		alert('U dient een zoekcriteria op te geven');
	} else {
		document.searchspecials.action = '/page.asp';
		document.searchspecials.submit();
	}
}

function checkSearchMaktec() {
	zoekwoord = document.searchmaktec.SValue.value
	if (zoekwoord == '' || zoekwoord == 'trefwoord/modelnummer') {
		alert('U dient een zoekcriteria op te geven');
	} else {
		document.searchmaktec.action = '/page.asp';
		document.searchmaktec.submit();
	}
}

function checkSearchGroups_acc() {
	searchfield = document.searchgroups_acc.s1.value
	strOrderByField = document.searchgroups_acc.s2.value
	strTable = document.searchgroups_acc.s3.value
	zoekwoord = document.searchgroups_acc.SValue.value
	if (zoekwoord == '' || zoekwoord == 'trefwoord/modelnummer') {
		alert('U dient een zoekcriteria op te geven');
	} else {
		document.searchgroups_acc.action = '/page.asp';
		document.searchgroups_acc.submit();
	}
}

function checkSearchGroupsac() {
	searchfield = document.searchgroups.s1.value
	strOrderByField = document.searchgroups.s2.value
	strTable = document.searchgroups.s3.value
	zoekwoord = document.searchgroups.SValue.value
	if (zoekwoord == '' || zoekwoord == 'trefwoord/modelnummer'){
		alert('U dient een zoekcriteria op te geven');
	}else{
		document.searchgroups.action = '/page.asp?ac=1';
		document.searchgroups.submit();
	}
}

function checkSearchGroupsonder() {
 searchfield = document.searchgroups.s1.value
 strOrderByField = document.searchgroups.s2.value
 strTable = document.searchgroups.s3.value
 zoekwoord = document.searchgroups.SValue.value
 if (zoekwoord == '' || zoekwoord == 'trefwoord/modelnummer'){
  alert('U dient een zoekcriteria op te geven');
 }else{
  document.searchgroups.action = '/page.asp?onder=1';
  document.searchgroups.submit();
 }
}

function getVergelijking(id){
	elms = document.getElementsByName('vergelijk_artikel');
	items = '';
	if (elms.length != -1){
		elmchecked = false;
		for (i=0;i<elms.length;i++){
			if (elms[i].checked){
				elmchecked = true;
				if (items != '') items += ', ';
					items = items.replace(elms[i].value+', ','')
				items += elms[i].value;
			}
		}
		
		if (elmchecked) {
			window.open('/vergelijk/get_vergelijking.asp?vergelijk_items=' + items,'Vergelijking','width=800, height=800, scrollbars=yes');	 
			return;
		} else {
			jAlert('Selecteer de te vergelijken machines door het vakje rechtsonder aan te klikken.\n\nU kunt maximaal 4 machines per keer vergelijken.');
		}
	}
}

function openVergelijking(id){
	window.open('/vergelijk/item_select.asp?id=' + id,'Vergelijking','width=800, height=800, scrollbars=yes');
	return;	
}

function openVergelijkingOudModel(id){
	window.open('/vergelijk/item_select_oud_model.asp?id=' + id,'Vergelijking','width=800, height=800, scrollbars=yes');
	return;	
}

function SetVergelijkAjax ( e ) {
	model 	= e.value;
	checked = e.checked;
	$j.ajax({
	    type: "POST",
	    url: "/system/AjaxAddVergelijk.asp",
	    data: "model="+model +"&checked="+checked
	});
}

 
function setVergelijk(){
	elms = document.getElementsByName('vergelijk_artikel');

	check_teller = 0;
	showVergelijk = 'none';
	if (elms.length != -1){
		 for (i=0;i<elms.length;i++)
		 	if (elms[i].checked){
		 		showVergelijk = '';
				check_teller++;
		 	}
	}
	
	lnkVergelijk = document.getElementById("vergelijk_link");
	if (lnkVergelijk) {
		if (check_teller > 4) {
			lnkVergelijk.onclick = "";
			document.getElementById("error_vergelijking").style.display = '';
		} else {
			lnkVergelijk.onclick = getVergelijking;
			document.getElementById("error_vergelijking").style.display = 'none';
		}
	}
	
	//document.getElementById('div_vergelijk').style.display = showVergelijk;
}


function ChangeFieldValue(fieldname, value) {
	document.getElementsByName(fieldname).item(0).value = value;
}

function checkImage(id) {
	URLPage = "http://85.17.11.180/makita/check_file.asp";
	URLarg = "q=" + id;
	ResponseText = AsyncHttpRequest(URLPage, URLarg, "POST", false);
	alert(ResponseText);
}

function getPosition(e) {
    e = e || window.Event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
		cursor.x = e.pageX;
		cursor.y = e.pageY;
    } else {
		var de = document.documentElement;
		var b = document.body;
		cursor.x = e.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
		cursor.y = e.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    return cursor;
}

function getPictureInfo(actie, path, defaultpath) {
	cursor = getPosition();
	
	if (actie == 'show') {		
		contentpos = document.getElementById('content_pos');
			
		pos = findPos(contentpos);
		if (pos) {
			offsetx = pos[0];
		} else {
			offsetx = 500;
		}
		
		box = document.getElementById('picture_info_box');
		content = document.getElementById('iframecontent');
		box.style.left = cursor.x - offsetx + 'px';
		box.style.top = cursor.y - 225 + 'px';
		content.src = defaultpath + '/getfileinfo.asp?path=' + path;
		box.style.display = "block";		
	}

	if (actie == 'hide') {
		box = document.getElementById('picture_info_box');
		box.style.display = 'none';
	}
	
}

function priceonly() {
 if ((event.keyCode<48&&event.keyCode!=44&&event.keyCode!=45)||event.keyCode>57)
  return false
}


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}




function openMailing(url) {
	winstyle = '';
	document.location.href = url;
}


function LoadDealerFinder(frm, actie, message){
	span = document.getElementById('LoadingMsgBox');
	span.innerHTML = message;
	
	div = document.getElementById('LoadingScreen');
	div.style.display = '';
	
	document[frm].action = actie;
	document[frm].submit();
}

function Convertvaluta(v, veld)
{ 
	var Myarray = (v.split(","));
	if (Myarray[1] == undefined)
	{
		Myarray[1] = '00';
	}
	replaceChars(Myarray[0]);
	veld.value = FormatEuro(Euro, "3", Euro.length)+","+FormatCenten(Myarray[1]);
}

function replaceChars(entry) {
out = "."; // replace this
add = ""; // with this
temp = "" + entry; // temporary holder

while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add + 
temp.substring((pos + out.length), temp.length));
}
Euro = temp;
}

function FormatEuro(f_BedragIn, f_Positie, f_Rest)
{
	if (f_Rest >= "4")
	{
		var Rechts = Right(f_BedragIn, f_Positie);
		var f_Rest = Len(f_BedragIn) - f_Positie;
		var Links	 = Left(f_BedragIn, f_Rest);
		var f_BedragOut = Links+"."+Rechts;
		return FormatEuro(f_BedragOut, parseInt(f_Positie)+4, f_Rest)
	} else {
		return (f_BedragIn);
	}
}

function FormatCenten(f_Bedrag)
{	
	var Centen	= f_Bedrag;
	
	if (Len(Centen) == 1){Centen = Centen+"0"}
	if (Len(Centen) == 2){Centen = Centen}
	if (Len(Centen) > 2) {Centen = Left(Centen, 2)}
	return (Centen);
}

function Len(str)
{
  return String(str).length;
}

function numbersonly(){
 if (event.keyCode<48||event.keyCode>57)
  return false
}

function insert404Error(f_Url, f_reffer)
{			
			var FormFields = '';
			FormFields += 'a=1';
	
			var httpRequest = createHttpRequest()
	  	httpRequest.open('post', f_Url+'?Tijd='+getTimeString()+'&reffer='+f_reffer+'&target='+document.location.href); 
	  	httpRequest.onreadystatechange = function() {handleResponse_insert404Error(httpRequest); };
	    httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	    httpRequest.send(FormFields);
}

function handleResponse_insert404Error(httpRequest) { 
  if(httpRequest.readyState == 4) { 
		if (httpRequest.status == 200) {

			}
      else {
        //alert('Fout opgetreden. Neem contact op met de webmaster.')
      }
      
  }
}

function createHttpRequest()
{
    if (window.XMLHttpRequest)
    {
      var httpRequest = new XMLHttpRequest()
    }
    else if (window.ActiveXObject)
    {
      var httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
    }    
    return httpRequest;
}

function getTimeString()
{
    var today=new Date();		//	We geven de datum/tijd mee zodat er altijd een 
    var h=today.getHours();		//	andere url is waardoor de pagina niet uit
    var m=today.getMinutes();	//	de cache zal worden gehaald.
    var s=today.getSeconds();
    return h+':'+m+':'+s;
}


function getSubTemplates(f_Url)
{			
			var FormFields = '';
			FormFields += 'a=1';
	
			var httpRequest = createHttpRequest()
			var templateID 	= document.getElementById('headTemplate').options[document.getElementById('headTemplate').options.selectedIndex].value
	  	httpRequest.open('post', '/advertising_campaign/getSubTemplates.asp?Tijd='+getTimeString()+'&templateID='+templateID); 
	  	httpRequest.onreadystatechange = function() {handleResponse_getSubTemplates(httpRequest); };
	    httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	    httpRequest.send(FormFields);
}

function handleResponse_getSubTemplates(httpRequest) { 
  if(httpRequest.readyState == 4) { 
		if (httpRequest.status == 200) {
				if (httpRequest.responseXML.getElementsByTagName('templateStr')[0] != null){
	    		var templateStr = httpRequest.responseXML.getElementsByTagName('templateStr')[0].firstChild.nodeValue;
	    		if (document.getElementById('templateStr') != null) {
				  	document.getElementById('templateStr').innerHTML = templateStr;
				  	document.getElementById('subTr').style.display = 'block';
				  }
	    	} else {
	    		document.getElementById('subTr').style.display = 'none';
	    		document.getElementById('templateStr').innerHTML = '';
	    	}
			}
      else {
        //alert('Fout opgetreden. Neem contact op met de webmaster.')
      }
      
  }
}


function checkStap0() {
	if (document.getElementById('headTemplate')) {
		var templateID = document.getElementById('headTemplate').options[document.getElementById('headTemplate').options.selectedIndex].value
		if (templateID == '') {
			alert('Kies een uiting');
			return false;	
		}
	}
	if (document.getElementById('subTemplate')) {
		var subtemplateID = document.getElementById('subTemplate').options[document.getElementById('subTemplate').options.selectedIndex].value
		if (subtemplateID == '') {
			alert('Kies een opzet');
			return false;	
		}		
	}
}

function priceonlyNew(input, e){
	var keycode;
	if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
	if ( ( keycode<48 && keycode != 44 && keycode != 46 && ekeycode != 45 ) || keycode > 57)
	return false;
		
}


function insertVoordeel(f_recordID,f_productteller,f_rowteller,f_getrowclass,f_voordeelvalue)
{			
			var FormFields = '';
			FormFields += 'a=1';
	
			var httpRequest = createHttpRequest()
	  	httpRequest.open('post', '/advertising_campaign/steps/gebruikersvoordelen_save.asp?Tijd='+getTimeString()+'&voordeelId='+f_voordeelvalue+'&recordID='+f_recordID); 
	  	httpRequest.onreadystatechange = function() {handleResponse_insertVoordeel(httpRequest,f_productteller,f_rowteller,f_getrowclass); };
	    httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	    httpRequest.send(FormFields);
}

function handleResponse_insertVoordeel(httpRequest,f_productteller,f_rowteller,f_getrowclass) { 
  if(httpRequest.readyState == 4) { 
		if (httpRequest.status == 200) {
				if (httpRequest.responseXML.getElementsByTagName('reachMax')[0] != null){
					alert('U kunt maximaal 3 gebruiksvoordelen per artikel kiezen');
					return false;
				}
				if (httpRequest.responseXML.getElementsByTagName('titel')[0] != null){
	    		var titel 		= httpRequest.responseXML.getElementsByTagName('titel')[0].firstChild.nodeValue;
	    		var recordID 	= httpRequest.responseXML.getElementsByTagName('recordID')[0].firstChild.nodeValue;
					var dataTable	=	document.getElementById("gebruikersvoordeelTable_"+f_productteller).getElementsByTagName('tbody')[0];
					var row 			= document.createElement("TR");
					var td1 			= document.createElement("TD");
					var td2				= document.createElement("TD");
					var td3				= document.createElement("TD");

					row.setAttribute('id',recordID);
					row.setAttribute('className',f_getrowclass);
					row.setAttribute('class',f_getrowclass);

					voordeelLength = titel.length
					
					if (voordeelLength > 35) {
						var extraStyle = "color:red;"	
					}	else {
						var extraStyle = ""
					}
						

					td1.innerHTML	=	'<textarea name="voordel_'+recordID+'" id="voordel_'+recordID+'" style="width:588px; height:50px; '+extraStyle+'" onkeyup="checkSigns(\''+recordID+'\', \'35\');" onblur="saveVoordeel(\''+recordID+'\')">'+titel+'</textarea>';
					td2.innerHTML	=	'<img src="/advertising_campaign/images/icons/icon_delete.gif" style="cursor:pointer; margin-top:3px;" onclick="deleteRow(\''+recordID+'\',\''+f_productteller+'\',\''+recordID+'\')">';
					td3.innerHTML	=	'<img src="/advertising_campaign/images/icons/icon_prio.gif" style="cursor:move;" alt="Verplaatsen">';
					td3.setAttribute('className','dragHandle');
					td3.setAttribute('class','dragHandle');
					td3.setAttribute('id','dragHandle');

					dataTable.appendChild(row);

					row.appendChild(td1);
					row.appendChild(td2);
					row.appendChild(td3);

					jQuery('#gebruikersvoordeelTable_'+f_productteller).tableDnD({
			    onDrop: function(table, row) {
			            var rows = table.tBodies[0].rows;
			            var debugStr = '';
			            for (var i=0; i<rows.length; i++) {
			                debugStr += rows[i].id+'|';
			            }
				        savePriority(debugStr);
				    },
					onDragClass: 'myDragClass',
			    dragHandle: 'dragHandle'
			});
	    	}
			}
      else {
        
      }
      
  }
}

function saveVoordeel(f_record) {
		var FormFields = '';
		FormFields += 'a=1';
		var voordeelValue = escape(document.getElementById('voordel_'+f_record).value)
		var httpRequest = createHttpRequest()
  	httpRequest.open('post', '/advertising_campaign/steps/gebruikersvoordelen_save_item.asp?Tijd='+getTimeString()+'&recordID='+f_record +'&voordeelValue='+voordeelValue);
  	httpRequest.onreadystatechange = function() {handleResponse_saveVoordeel(); };
    httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
    httpRequest.send(FormFields);
}

function handleResponse_saveVoordeel() {
	
}

function insertProudct(f_rowteller,f_getrowclass,f_modelnumber,f_page,f_enable_headings, f_showheading, f_quantity_machinesShow,f_ma_page_max_chars, f_ma_page_max_lines)

{		
			var FormFields = '';
			FormFields += 'a=1';
	
			var httpRequest = createHttpRequest()
	  	httpRequest.open('post', '/advertising_campaign/steps/machines_selecteren_add.asp?Tijd='+getTimeString()+'&modelnumber='+f_modelnumber+'&page='+f_page); 
	  	httpRequest.onreadystatechange = function() {handleResponse_insertProudct(httpRequest,f_rowteller,f_getrowclass,f_modelnumber,f_page,f_enable_headings,f_showheading, f_quantity_machinesShow,f_ma_page_max_chars, f_ma_page_max_lines); };
	    httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	    httpRequest.send(FormFields);
}

function handleResponse_insertProudct(httpRequest,f_rowteller,f_getrowclass,f_modelnumber,f_page,f_enable_headings,f_showheading, f_quantity_machinesShow,f_ma_page_max_chars, f_ma_page_max_lines) { 

  if(httpRequest.readyState == 4) { 
		if (httpRequest.status == 200) {
				if (httpRequest.responseXML.getElementsByTagName('reachMax')[0] != null){
					alert('Het maximale aantal machines voor deze pagina is overschreden');
					return false;
				}
				if (httpRequest.responseXML.getElementsByTagName('titel')[0] != null){
	    		var titel = httpRequest.responseXML.getElementsByTagName('titel')[0].firstChild.nodeValue;
	    		var recordID = httpRequest.responseXML.getElementsByTagName('recordID')[0].firstChild.nodeValue;
	    		var headingtitle = httpRequest.responseXML.getElementsByTagName('headingtitle')[0].firstChild.nodeValue;
	    		var description = httpRequest.responseXML.getElementsByTagName('description')[0].firstChild.nodeValue;
	    		
					var dataTable	=	document.getElementById("artikelTable"+f_page).getElementsByTagName('tbody')[0];
					var row 			= document.createElement("TR");
					var td1 			= document.createElement("TD");
					var td2 			= document.createElement("TD");
					if (f_enable_headings == '1') {
						var td4 			= document.createElement("TD");
					}
					var td5 			= document.createElement("TD");
					if (f_quantity_machinesShow > 1) {
						var td6 			= document.createElement("TD");
					}
					row.setAttribute('id',recordID);
					row.setAttribute('className',getRowClass);
					row.setAttribute('class',getRowClass);
					
					td1.innerHTML	=	f_modelnumber;
					if (f_showheading == '1' ) {
						td2.innerHTML	=	titel+'<br/>Heading: '+headingtitle;
					} else {
						td2.innerHTML	=	titel;
					}
					if (f_enable_headings == '1') {
						if (f_showheading == '1' ) {
							td2.innerHTML	=	titel+'<br/>Heading: '+headingtitle;
						} else {
							td2.innerHTML	=	titel;
						}
						td4.innerHTML	=	'<textarea name="description_'+recordID+'" id="description_'+recordID+'" style="width:200px; height:100px;">'+description+'</textarea><div id="description_'+recordID+'_status"></div>';
	
					}
					td5.innerHTML	=	'<img src="/advertising_campaign/images/icons/icon_delete.gif" style="cursor:pointer; margin-top:3px;" onclick="deleteRow(\''+recordID+'\')">';
					if (f_quantity_machinesShow > 1) {
						td6.innerHTML	=	'<img src="/advertising_campaign/images/icons/icon_prio.gif" style="cursor:move;" alt="Verplaatsen">';
					}


					
					if (f_quantity_machinesShow > 1) {
						
						td6.setAttribute('id','dragHandle');
						td6.setAttribute('className','dragHandle');
						td6.setAttribute('class','dragHandle');
					}
					
					dataTable.appendChild(row);
					
					row.appendChild(td1);
					row.appendChild(td2);
					if (f_enable_headings == '1') {
						row.appendChild(td4);
					}
					row.appendChild(td5);  
					if (f_quantity_machinesShow > 1) {
						row.appendChild(td6);
					}
					
					jQuery('#artikelTable'+f_page).tableDnD({
					    onDrop: function(table, row) {
					            var rows = table.tBodies[0].rows;
					            var debugStr = '';
					            for (var i=0; i<rows.length; i++) {
					                debugStr += rows[i].id+'|';
					            }
						        savePriorityMA(debugStr, f_page);
						    },
							onDragClass: 'myDragClass',
					    dragHandle: 'dragHandle'
					});
					
					//  Text editor limiter
					if (!f_ma_page_max_chars == '') {
						new Textarea_Limiter('description_' + recordID, {
							char_limit: Number(f_ma_page_max_chars),
							line_limit: Number(f_ma_page_max_lines),
							statusdiv: 'description_' + recordID + '_status'
						});		
					}
					

	    	}
			}
      else {
        
      }
      
  }
}




function insertProudctActie(f_modelnumber,f_recordID)

{		
			var FormFields = '';
			FormFields += 'a=1';
	
			var httpRequest = createHttpRequest()
	  	httpRequest.open('post', '/advertising_campaign/steps/actie_selecteren_add.asp?Tijd='+getTimeString()+'&modelnumber='+f_modelnumber+'&recordID='+f_recordID); 
	  	httpRequest.onreadystatechange = function() {handleResponse_insertProudctActie(httpRequest,f_modelnumber,f_recordID); };
	    httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	    httpRequest.send(FormFields);
}

function handleResponse_insertProudctActie(httpRequest,f_modelnumber,f_recordID) { 

  if(httpRequest.readyState == 4) { 
		if (httpRequest.status == 200) {
				if (httpRequest.responseXML.getElementsByTagName('artikeltitle')[0] != null){
	    		var artikeltitle = httpRequest.responseXML.getElementsByTagName('artikeltitle')[0].firstChild.nodeValue;
	    		var selectStr = httpRequest.responseXML.getElementsByTagName('selectStr')[0].firstChild.nodeValue;
	    		
	    	if (httpRequest.responseXML.getElementsByTagName('artikelPrice')[0] != null){	
	    		var artikelPrice = httpRequest.responseXML.getElementsByTagName('artikelPrice')[0].firstChild.nodeValue;
				} else {
					var artikelPrice = '';
				}
				
					var existingModellnumer = ''
					if(document.getElementById('modelnummer_'+f_recordID)) {
						existingModellnumer = document.getElementById('modelnummer_'+f_recordID).value;
					}
					document.getElementById('modelnummer_'+f_recordID).value = f_modelnumber;
					if (existingModellnumer != '') {
							document.getElementById('modelnummerShow_'+f_recordID).innerHTML = f_modelnumber;
							document.getElementById('description_'+f_recordID).innerHTML = artikeltitle;
							document.getElementById('price_'+f_recordID).value = artikelPrice;
					} else {
					
						var dataTable	=	document.getElementById("artikelTable"+f_recordID).getElementsByTagName('tbody')[0];
						var row 			= document.createElement("TR");
						var td1 			= document.createElement("TD");
						var td2				= document.createElement("TD");
	
						row.setAttribute('id',f_recordID);
						row.setAttribute('className','actieClass');
						row.setAttribute('class','actieClass');
						td1.innerHTML	=	'Modelnummer';
						td1.setAttribute('class','actieFirst');
						td1.setAttribute('className','actieFirst');
						td2.innerHTML	=	'<span id="modelnummerShow_'+f_recordID+'">'+f_modelnumber+'</span>';
	
						dataTable.appendChild(row);	
						row.appendChild(td1);
						row.appendChild(td2);
	
						var dataTable	=	document.getElementById("artikelTable"+f_recordID).getElementsByTagName('tbody')[0];
						var row 			= document.createElement("TR");
						var td1 			= document.createElement("TD");
						td1.setAttribute('class','actieFirst');
						td1.setAttribute('className','actieFirst');
						var td2 			= document.createElement("TD");
	
						row.setAttribute('id',f_recordID);
						row.setAttribute('className','actieClass');
						row.setAttribute('class','actieClass');
						td1.innerHTML	=	'Titel';
						td2.innerHTML	=	selectStr;
	
						dataTable.appendChild(row);	
						row.appendChild(td1);
						row.appendChild(td2);
	    		
						var dataTable	=	document.getElementById("artikelTable"+f_recordID).getElementsByTagName('tbody')[0];
						var row 			= document.createElement("TR");
						var td1 			= document.createElement("TD");
						td1.setAttribute('class','actieFirst');
						td1.setAttribute('className','actieFirst');
						var td2 			= document.createElement("TD");
	
						row.setAttribute('id',f_recordID);
						row.setAttribute('className','actieClass');
						row.setAttribute('class','actieClass');
						td1.innerHTML	=	'Omschrijving';
						td2.innerHTML	=	'<textarea name="actieOmschrijving_'+f_recordID+'" id="description_'+f_recordID+'" style="width:200px; height:100px;">'+artikeltitle+'</textarea><div id="description_'+f_recordID+'_status"></div>';
						
						dataTable.appendChild(row);	
						row.appendChild(td1);
						row.appendChild(td2);
						
						var dataTable	=	document.getElementById("artikelTable"+f_recordID).getElementsByTagName('tbody')[0];
						var row 			= document.createElement("TR");
						var td1 			= document.createElement("TD");
						td1.setAttribute('class','actieFirst');
						td1.setAttribute('className','actieFirst');
						var td2 			= document.createElement("TD");
	
						row.setAttribute('id',f_recordID);
						row.setAttribute('className','actieClass');
						row.setAttribute('class','actieClass');
						td1.innerHTML	=	'Prijs';
						td2.innerHTML	=	'<input type="text" style="width:199px;" name="actiePrice_'+f_recordID+'" value="'+artikelPrice+'" id="price_'+f_recordID+'">';
	
						dataTable.appendChild(row);	
						row.appendChild(td1);
						row.appendChild(td2);		
						
						var dataTable	=	document.getElementById("artikelTable"+f_recordID).getElementsByTagName('tbody')[0];
						var row 			= document.createElement("TR");
						var td1 			= document.createElement("TD");
						td1.setAttribute('class','actieFirst');
						td1.setAttribute('className','actieFirst');
						var td2 			= document.createElement("TD");
	
						row.setAttribute('id',f_recordID);
						row.setAttribute('className','actieClass');
						row.setAttribute('class','actieClass');
						td1.innerHTML	=	'Prijs weergave';
						td2.innerHTML	=	'<select name="actiePrijsWeergave_'+f_recordID+'" id="actiePrijsWeergave_'+f_recordID+'">'+
											'<option value="1">Achter omschrijving plaatsen</option>'+
											'<option value="2">Op nieuwe regel plaatsen</option>'+
											'</select>';
						dataTable.appendChild(row);	
						row.appendChild(td1);
						row.appendChild(td2);	
						
						
						// Voeg limieter in textarea zetten
						if ((document.getElementById("char_limit_" + f_recordID).value > 0) && (!document.getElementById("char_limit_" + f_recordID).value == '')) {
							new Textarea_Limiter('description_' + f_recordID, {
								char_limit: parseInt(document.getElementById("char_limit_" + f_recordID).value),
								line_limit: parseInt(document.getElementById("line_limit_" + f_recordID).value),
								statusdiv: 'description_' + f_recordID + '_status'
							});					
						}
						
					}				
	    	}
	} else {
        
      }
  }
}
// Lease calculator window openen.
function leasingaufruf() {
	window.open('http://www.grenkeleasing.com/cgi-bin/shop-index.pl?userid=108-02305','LEASING','width=550,height=470,resizable=no,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,location=no');
}

var last_iframe_width = 0;
var last_iframe_height = 0;

function hide_iframe_overlay() {
	$("iframe_window_overlay").fade({ duration: 0.25 });
	$("iframe_window").fade({ duration: 0.25 });
}

function open_iframe_overlay(inUrl, inTitle, inWidth, inHeight) {
	var windowDimensions = document.viewport.getDimensions();
	var windowOffset = document.viewport.getScrollOffsets();

	var overlayHeight = (document.body.clientHeight < windowDimensions.height) ? windowDimensions.height : document.body.clientHeight;
	
	var windowLeft = windowOffset.left + (windowDimensions.width - inWidth) / 2;
	var windowTop = windowOffset.top + (windowDimensions.height - inHeight) / 2;
	
	var iframe_overlay = $("iframe_window");		
	
	$("iframe_window_title").update(inTitle);
	$("iframe_window_iframe").setAttribute("src", inUrl);
	$("iframe_window_iframe").setAttribute("width", inWidth);
	$("iframe_window_iframe").setAttribute("height", (inHeight - 20));
	
	
	
	$("iframe_window_overlay").setStyle({ height: overlayHeight + "px" });
	$("iframe_window").setStyle({ left: windowLeft + "px", top: windowTop + "px", width: inWidth + "px", height: inHeight + "px" });	
		
	$("iframe_window_overlay").appear({ to: 0.25, duration: 1.0 });
	$("iframe_window").appear({ duration: 1.0 });	
	
	last_iframe_width = inWidth;
	last_iframe_height = inHeight;
	
	
	$("iframe_window_overlay").observe("click", hide_iframe_overlay);
	Event.observe(window, "scroll", position_iframe_overlay);
	Event.observe(document, "scroll", position_iframe_overlay);
	
}

function position_iframe_overlay() {
	var windowDimensions = document.viewport.getDimensions();
	var windowOffset = document.viewport.getScrollOffsets();

	var windowLeft = windowOffset.left + (windowDimensions.width - last_iframe_width) / 2;
	var windowTop = windowOffset.top + (windowDimensions.height - last_iframe_height) / 2;

	$("iframe_window").setStyle({ left: windowLeft + "px", top: windowTop + "px" });	
	
	var overlayHeight = (document.body.clientHeight < windowDimensions.height) ? windowDimensions.height : document.body.clientHeight;
	$("iframe_window_overlay").setStyle({ height: overlayHeight + "px" });
}


function checkSigns(f_recordID, f_max) {
	var checkColor = 0
	var areaValue = document.getElementById('voordel_'+f_recordID).value
	var arrValue 	= areaValue.split("\n");
	
	for(var i=0; i<arrValue.length; i++) {
	var value = arrValue[i];
		var areaLength = value.length
		if (f_max < areaLength) {
			document.getElementById('voordel_'+f_recordID).style.color = 'red';
			checkColor = 1
		} else {
			if (checkColor == 0) {
				document.getElementById('voordel_'+f_recordID).style.color = 'black';
			}
		}		
	}
	

}


