v_browserisIE = (navigator.appName == "Microsoft Internet Explorer");



startupcookie = document.cookie ;



// BASIC COOKIE LIB

function f_cookie_set(n, v)

{

  var date = new Date();

  date.setTime(date.getTime() + 36e5);

  document.cookie = n + "=" + escape(v) + "; expires=" + date.toGMTString() + "; path=/";

}



function f_cookie_get(n)

{

  var a = document.cookie.split("; ");

  for (var i=0; i < a.length; i++)

  {

    var p = a[i].split("=");

    if (n == p[0]) 

      return unescape(p[1]);

  }

  return null;

}



// BASIC CSS LIB

// note: these functions do not alter/check included/external css files



function f_CSS_ruleExists(v_rule) 

{

	v_rule = v_rule.toLowerCase();



	for (var j = 0; j < document.styleSheets.length; j++) 

	{

		var o_sheet=document.styleSheets[j];

		var o_rules=o_sheet.cssRules? o_sheet.cssRules: o_sheet.rules;

		for (var i=0; i<o_rules.length; i++)

		{

			if (o_rules[i].selectorText != null) 

			{

				if (o_rules[i].selectorText.toLowerCase()==v_rule)

				{ 

					if (o_rules[i].selectorText.toLowerCase()==v_rule)

					{ 

						return true;

					}

				}

			}

		} 

	}

}



function f_CSS_removeRule (v_rule)

{

		

	v_rule = v_rule.toLowerCase();

	for (var j = 0; j < document.styleSheets.length; j++)

	{

		var o_sheet=document.styleSheets[j]

		var o_rules=o_sheet.cssRules? o_sheet.cssRules: o_sheet.rules



		for (var i=0; i<o_rules.length; i++)

		{

			if (o_rules[i].selectorText != null)

			{

				if(o_rules[i].selectorText.toLowerCase()==v_rule)

				{ 

					if (o_sheet.deleteRule)

					{

						o_sheet.deleteRule(i);

					}

					else

					{

						o_sheet.removeRule(i);

					}

					return;

				}

			}

		} 

	}	

}



function f_CSS_addRule (v_rule,v_value)

{

	var o_sheet=document.styleSheets[0];

	

	if (o_sheet.addRule)

	{

		o_sheet.addRule(v_rule,v_value);

	}

	else

	{

		if (o_sheet.insertRule) 

		{

			// just to be save determine rules object

			var o_rules=o_sheet.cssRules? o_sheet.cssRules: o_sheet.rules;

			o_sheet.insertRule(v_rule+"{"+v_value+"}",o_rules.length);

		}

	}

}







// GENERIC FUNCTIONS

function gE(i){return document.getElementById(i);}

function gEName(i){return document.getElementsByName(i)[0];}

function cE(i){return document.createElement(i);}

function dW(s){document.write(s);}



// get a unique ID

function gUQID() {

	if (typeof(UQIDCounter) == 'undefined') 

	{

		UQIDCounter = 0;

	}

	while (gE("UQID"+UQIDCounter) != null) {

		UQIDCounter++;

	}

	return "UQID"+UQIDCounter;

}



// get an id (of an element)

// if o is an string it is assumed to be an id

// if o is an object with an id, this id is returned

// if o is an object without an id, a unique ID is created , assigned and returned

function gEID(o) {

	if (typeof(o) == 'string') 

	{

		return o;

	}

	else if (typeof(o) == 'object')

	{

		if ((typeof(o.id) == 'undefined')||(o.id == "")) 

		{

			o.id = gUQID();		

		}

		return o.id		

	}

}





// stop propagation 

function f_stopProp(e) {

	if (typeof(window.event) != 'undefined') {

		window.event.cancelBubble = true;

	} else {

		e.stopPropagation();

	}	

	

}



function object2string(o) {

	var s = "";

	for (i in o) {

		s += " "+i+":"+o[i]+"\n";

	}

	return s;

}



// ERROR HANDLER

o_errorhandler = {

	log : function (err) {

		alert(err);	

	}

}



// DHTML DIALOG



/////////////////////////////////

// THE DRAG LIBRARY START



var Drag = { 

	obj : null, 

	pieces : [],

	init : function(o,r) {

		// o.onmousedown = Drag.start;

		

		o.hmode = true;

		o.vmode = true;

		o.root = (typeof(r) == undefined) ? o : r; 

		

		Drag.pieces[Drag.pieces.length] = o.root;



		o.root.onDragStart = new Function();

		o.root.onDragEnd = new Function();

		o.root.onDrag = new Function(); 

	}, 



	tofront : function (o) {

		piecez = o.root.style.zIndex;

		highestzindex = piecez

		for (var i = 0; i < Drag.pieces.length; i++) {

			highestzindex = highestzindex < Drag.pieces[i].style.zIndex ? Drag.pieces[i].style.zIndex : highestzindex;

			if (Drag.pieces[i].style.zIndex > piecez) {

				Drag.pieces[i].style.zIndex  = Drag.pieces[i].style.zIndex -1;

			}

			

		}

		o.root.style.zIndex = highestzindex; 	

	}, 



	start : function(e) {

		

		var o = Drag.obj = this; //.parentNode;

		Drag.tofront(o);





		e = Drag.fixE(e);

		var y = parseInt(o.root.style.top);

		var x = parseInt(o.root.style.left);

		o.root.onDragStart(x, y); 

		o.lastMouseX = e.clientX;

		o.lastMouseY = e.clientY;

		document.onmousemove	= Drag.drag;

		document.onmouseup	= Drag.end;

         

		

		// e.cancelBubble = true;



		return false; 

	}, 

	drag : function(e){

		

		

			e = Drag.fixE(e);

			var o = Drag.obj;

			

			var ey	= e.clientY;

			var ex	= e.clientX;

			

			var y = parseInt(o.root.style.top);

			var x = parseInt(o.root.style.left);

			var nx, ny;

		

			nx = x + ex - o.lastMouseX;

			ny = y + ey - o.lastMouseY;

		

			

			o.px = nx;o.py = ny;

			

			if((o.offsetWidth + nx) > Geometry.getDocumentWidth()){

				o.root.style["left"] =Geometry.getViewportWidth()/2-200 + "px";

				

			}else if(nx < 1){

			o.root.style["left"] = 1;

			}

			else{

				o.root.style["left"] = nx + "px";

				

			}

			

			maxHeight = Geometry.getViewportHeight() + Geometry.getVerticalScroll();

			if((o.offsetHeight +ny) + 2 > maxHeight){ // must not skip bottom

				o.root.style["top"] = maxHeight - o.offsetHeight - 2 +"px";

			}else if(ny < Geometry.getVerticalScroll() + 2){ // must not skip top

				o.root.style["top"] = Geometry.getVerticalScroll() + 2 +"px";

			}else{

				o.root.style["top"]=ny +"px";

			}

			o.lastMouseX	= ex;

			o.lastMouseY	= ey;

			o.root.onDrag(nx, ny);

			

			return false;

		

	}, 

	end : function() {

		var o = Drag.obj;

		var px = o.px;

		var py = o.py;

		var cc = 0;

		document.onmousemove = null;

		document.onmouseup   = null;

		Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]),

					parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));

		Drag.obj = null;

	},

	fixE : function(e) { 

		if (typeof e == 'undefined') e = window.event;

		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;

		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;

		return e; 

	}

};









///////////////////////////////////////////////////////////

// DHTML DIALOG



// hideAllSelects hides all elements of type select

// to prevent visual errors and or interaction

// note this function is called when the style "hideselects" is set within a f_dhtmldialog_create call

// this automatically undoes this at f_dhtmldialog_remove



var f_hideAllSelects_refcount = 0;

function f_hideAllSelects(v) 

{

	if ((v == null)||(v)) 

	{

		f_hideAllSelects_refcount++;

		if (f_hideAllSelects_refcount == 1)

		{

			f_CSS_addRule("select","visibility:hidden;");

		}

	}

	else

	{

		f_hideAllSelects_refcount--

		if (f_hideAllSelects_refcount <= 0) {

			// TODO: make sure no visibility unrelated styles are removed

			f_CSS_removeRule("select");

			f_hidellSelects_refcount = 0;

		}

	}

}



var v_dhtml_dialogs = [];

var v_dhtml_dialog_idcounter = 0;



function f_dhd_setPosition(wid,x,y) 

{

	debug_trace("f_dhd_setPosition("+wid+","+x+","+y+")")

//	x = 300;

//	y = 300;

	if (x < 0) x = 0;

	if (y < 0) y = 0;

	var o_w = f_dhtmldialog_get_window(wid);

	debug_trace(o_w.style["left"]);

	o_w.style["left"] = x+"px";

	o_w.style["top"] = y+"px";

}



function f_dhd_setWidth(wid,w)

{

	if (w < 100) w = 100;

	if (w > 800) w = 800;



	f_dhtmldialog_get_window(wid).style["width"] = w+"px";

		



}



function f_dhd_forceWidth(wid,w) {

	f_dhd_setWidth(wid,w);

	var o_w = f_dhtmldialog_get_window(wid)

	o_w.curw = w;

	o_w.tgtw = w;

}



function f_dhd_setHeight(wid,h) 

{

	var w = f_dhtmldialog_get_window(wid);

	if (h != "auto") {

		if (h < 100) h = 100;

		h += "px";

		if ((w.tgth) == 'auto') {

			w.style["overflow"] = 'hidden';

		}

		

		

	} else {

		w.style["overflow"].overflow = 'auto';

	}

	w.style["height"] = h

}



// code for animated opening of dhtml windows

function f_dhtmldialog_animateopen(v_wid,v_maxstep,v_interval,v_step) 

{



	var w = f_dhtmldialog_get_window(v_wid);

	if (v_step == null) 

	{

		if (v_maxstep == null) v_maxstep = 6;

		if (v_interval == null) v_interval = 50;

		w.ani_timerid = window.setTimeout("f_dhtmldialog_animateopen('"+v_wid+"',"+v_maxstep+","+v_interval+",0);",v_interval);

	}

	else

	{

		debug_trace('animwindow open'+w.curx);

		v_step++;

		if (v_step < v_maxstep) 

		{



			var v_stepfactor = 1 / (v_maxstep - v_step + 1);

			w.curx += (w.tgtx - w.curx) * v_stepfactor;

			w.cury += (w.tgty - w.cury) * v_stepfactor;

			w.curw += (w.tgtw - w.curw) * v_stepfactor;



			var v_tgth;

			if (w.tgth == "auto")

			{

				v_tgth = 200;

			}

			else

			{

				v_tgth = w.tgth;

			}

			w.curh += (v_tgth - w.curh) * v_stepfactor;





			f_dhd_setPosition(v_wid,w.curx,w.cury)

			f_dhd_setHeight(v_wid,Math.round(w.curh))

			f_dhd_setWidth(v_wid,Math.round(w.curw))

			

			w.ani_timerid = window.setTimeout("f_dhtmldialog_animateopen('"+v_wid+"',"+v_maxstep+","+v_interval+","+v_step+");",v_interval);



		}

		else

		{

			w.curx = w.tgtx;

			w.cury = w.tgty;

			w.curw = w.tgtw;



			f_dhd_setPosition(v_wid,w.curx,w.cury)

			f_dhd_setWidth(v_wid,Math.round(w.curw))

			f_dhd_setHeight(v_wid,w.tgth)

			

			// ready animating, fade page

			if (!w.doNotBlurPage) gE('disable_page').style.display='inline';

			

		}

	}

}



function f_showMessage(message, caption, remotePage)

{

	f_dhtmldialog_create('<div class="notification_message">' + message + '</div>', caption, 'center', 500, 300);

}



function f_showMessageNoIcon(message, caption, remotePage)

{

	f_dhtmldialog_create('<div class="notification_message noicon">' + message + '</div>', caption, 'center', 500, 300);

}



function f_dhtmldialog_create(v_dialogcontent,v_dialogcaption,v_dialogstyle,v_originelement_id,v_width,v_height,v_className, doNotBlurPage)

{

	

	

	v_dhtml_dialog_idcounter++;

	var id = v_dhtml_dialog_idcounter;

	if (typeof(v_dialogstyle) == 'undefined')

	{

		v_dialogstyle = "";

	}

	else

	{

		v_dialogstyle = ";"+v_dialogstyle.toLowerCase().split(' ').join('')+";";

	}



	if (typeof(v_dialogcaption) == 'undefined')

	{

		v_dialogcaption = "";

	}



	if (typeof(v_width) == 'undefined')

	{

		v_width = 300;

	}

	



	// var dhd = true;



	var aapopup = (v_dialogstyle.indexOf(";aapopup;")!=-1)





	// modaldiv in bg

	var m = cE('div');

	m.id = "dhtml_dialog_m_"+id;

	m.style.position = "absolute";

	m.style.zIndex = 100 + id;

	m.style.top = "0px";

	m.style.left = "0px";

	if (typeof(v_className) != 'undefined') {

		m.className = v_className;

	}







	// actual window

	var w = cE('div');

	w.id = f_dhtmldialog_get_windowid(id);

	w.className = 'dhd2';

	

	w.style.width = '300px';

	w.style.position = 'absolute';

	

	w.doNotBlurPage = doNotBlurPage;











	if (v_dialogstyle.indexOf(";center;")!=-1)

	{

		var bw = document.body.clientWidth;

		var bh = document.body.clientHeight;

		w.tgty = ((20 * (id & 7)) + (bh >> 1) -250);

		if (w.tgty < 5) w.tgty = 5;

		w.tgtx = ((15 * (id & 3)) + (bw >> 1) -250);

		if (w.tgtx < 5) w.tgtx = 5;

	}

	else

	{

		w.tgty = ((15 * id) + 8);

		w.tgtx = ((15 * (id & 3)) + 8);

	}



	var animate = false; 

	var animate = (v_dialogstyle.indexOf(";animate;")!=-1); 

	var animatefrommouse = false;



	if (animate)

	{

		animatefrommouse = (v_dialogstyle.indexOf(";frommouse;")!=-1); 

		if (animatefrommouse)

		{

			w.curx = v_body_xmouse-30; 

			w.cury = v_body_ymouse-30; 

		}

		else

		{

			w.curx = 100; 

			w.cury = 100; 

		}

		w.style.top = w.cury  + "px";

		w.style.left = w.curx  + "px";



	}

	else

	{

		// alert(w.tgtx);

		w.curx = w.tgtx;

		w.cury = w.tgty;

		w.style.top =  "0 px";

		w.style.left = "0 px";

	}





	if (v_dialogstyle.indexOf(";hideselects;")!=-1)

	{

		f_hideAllSelects(true);

		w.hidselects = true;

	}

	else

	{

		w.hidselects = false;

	}





	w.tgtw = v_width;

	if (v_height != null)

	{

		w.tgth = v_height + 22;

	}

	else

	{

		w.tgth = "auto";

	}



	if (animate)

	{

		w.curw = 60;

		w.curh = 60;

		w.style.width = w.curw+"px";

		w.style.height = w.curh+"px";



	}

	else

	{

		w.curw = v_width;

		w.style.width = w.tgtw+"px";

	}

	

	var noclose = ( v_dialogstyle.indexOf(";noclose;") != -1);





	var ihtml = "<div class=\"dhdcontainer\"><div class=\"dhdtop\" >";

	ihtml += "	<div class=\"dhdtw\" >";

	ihtml += "	</div>";

	ihtml += "	<div class=\"dhdtr\" >";

	ihtml += "	</div>";

	ihtml += "</div>";



	ihtml += "<div class=\"dhdmid\" >";

	ihtml += "	<div class=\"dhdmw\" >";

	if (!noclose) {

		ihtml += "	<a id=\"closeWindow\" class=\"buttonclose\" href=\"javascript:void(f_dhtmldialog_close('"+id+"'));\" title=\"Close Window\"><img src=\"http://www.eticketbazaar.com/images/close.gif\" border=\"0\"></img></a>";

	}



	ihtml += "		<h2 id=\""+f_dhtmldialog_get_captionid(id)+"\">" + v_dialogcaption + "</h2>";

	ihtml += "		<div id=\""+f_dhtmldialog_get_bodyid(id)+"\">";

	ihtml += 			v_dialogcontent; 

	ihtml += "		</div>";

	ihtml += "		<div class=\"stretch\"></div>";

	ihtml += "	</div>";

	ihtml += "	<div class=\"dhdmr\" >";

	ihtml += "	</div>";

	ihtml += "</div>";







	ihtml += "<div class=\"dhdbot\" >";

	ihtml += "	<div class=\"dhdbw\" >";

	ihtml += "	</div>";

	ihtml += "	<div class=\"dhdbr\" >";

	ihtml += "	</div>";

	ihtml += "</div>";

	ihtml += "</div>";

    

	//var embed=document.getElementsByTagName('embed');

	//if(embed.length==0) 

	

	

	if (v_browserisIE) {

		 ihtml += "<iframe style=\"position:absolute;top:0px;left:0px;width:expression(parentNode.scrollWidth - 6);height:expression(parentNode.scrollHeight-6);z-index:-1;\" source=\"javascript:false\"></iframe>";

	}

	

	w.innerHTML = ihtml;



	

	m.appendChild(w);

	

	



	

	var a = gE('dhtml_dialogs_all');

	if (a == null) {

		// modaldiv in bg

		var a = cE('div');

		a.id = "dhtml_dialogs_all";

		a.style.position = "absolute";

		a.style.zIndex = 10000 ;

		a.style.top = "0px";

		a.style.left = "0px";

		document.body.appendChild(a);

	}





	a.appendChild(m);

	//Drag.init(w,m);





	

	//if(document.getElementById('vplayer_holder')==null)

		w.onmousedown = Drag.start; 

	



	

	if (animate)

	{

		f_dhtmldialog_animateopen(id);

	}

	

	else {

		if (!w.doNotBlurPage) gE('disable_page').style.display='inline';

	}

	

	return id;

}





function f_dhtmldialog_nodrag(e) {

	if (e == undefined) e = window.event;

	e.cancelBubble = true;

	e.returnValue = false;

}



function f_dhtmldialog_get_window(idnumber)

{

	return gE(f_dhtmldialog_get_windowid(idnumber));

}



function f_dhtmldialog_get_windowid(idnumber)

{

	return "dhtml_dialog_w_"+idnumber;

}



function f_dhtmldialog_get_bodyid(idnumber)

{

	return "dhtml_dialog_b_"+idnumber;

}



function f_dhtmldialog_get_body(idnumber)

{

	return gE(f_dhtmldialog_get_bodyid(idnumber));

}



function f_dhtmldialog_get_captionid(idnumber)

{

	return "dhtml_dialog_c_"+idnumber;

}



function f_dhtmldialog_get_caption(idnumber)

{

	return gE(f_dhtmldialog_get_captionid(idnumber));

}



function f_dhtmldialog_tofront(idnumber)

{

	var w = f_dhtmldialog_get_window(idnumber);

	if (w != null) {

		Drag.tofront(w);

		return true;

	} else {

		return false;

	}

}



function f_dhtmldialog_remove(v_dialogid)

{

	var w = gE("dhtml_dialog_w_"+v_dialogid)

	var m = gE("dhtml_dialog_m_"+v_dialogid)

	

	if (w.hidselects) {

		f_hideAllSelects(false);

	}	



	if (m != null) {

		var a = gE('dhtml_dialogs_all');

		if (a != null) {

			a.removeChild(m); 

		}

	}

}



function f_dhtmldialog_close(v_dialogid)

{

	f_dhtmldialog_remove(v_dialogid);

	hide_overlay()

	if(document.getElementById('overlay'))

		document.getElementById('overlay').parentNode.removeChild(document.getElementById('overlay'));

	

	if(document.getElementById('calendarDiv'))

		document.getElementById('calendarDiv').parentNode.removeChild(document.getElementById('calendarDiv'));

	

	

	document.getElementById('dhtml_dialogs_all').parentNode.removeChild(document.getElementById('dhtml_dialogs_all'));

	

}





///////////////////////////////////////////////////////////

// DEBUG COOKIES

function f_showStartUpCookie()

{

	f_dhtmldialog_create("<b>contents:</b><br>"+startupcookie,"COOKIE AT SCRIPT START");

}

function f_showCurrentCookie()

{

	f_dhtmldialog_create("<b>contents:</b><br>"+document.cookie,"CURRENT COOKIE");

}





///////////////////////////////////////////////////////////

// DEBUG TRACE

var trace_string = "";

var trace_window_idnumber = null;

var trace_enabled = 0;

function debug_clear_trace()

{

	trace_string = "";

	if (f_dhtmldialog_get_body(trace_window_idnumber) != null)

	{

		debug_trace("");

		trace_string = "";

	}

}





function debug_trace(a)

{

	if (trace_enabled)

	{

		trace_string += a + "/n";



		if (trace_window_idnumber != null)

		{

			if (f_dhtmldialog_get_body(trace_window_idnumber) == null) 

			{

				trace_window_idnumber = null;

			}

		}



		if (trace_window_idnumber == null)

		{

			trace_window_idnumber = f_dhtmldialog_create("","DEBUG TRACE <a style=\"color:#000000;\" href=\"javascript:void(debug_clear_trace());\"><b>clear</b></a>","resize",undefined,240,360);

		}



		f_dhtmldialog_get_body(trace_window_idnumber).innerHTML = trace_string.split('&').join('&amp;').split('>').join('&gt;').split('<').join('&lt;').split('/n').join('<br />').split('[b]').join('<b>').split('[/b]').join('</b>')

	}

}





function feedbackajaxmetaprocess(o) {

	debug_trace(object2string(o));

}

// 





// SETUP CONFIG





// default to no postprocessing

var postprocessing = false;



// get scriplevel according to cookie

var v_scriptlevel = f_cookie_get('scriptlevel');

	

if (isNaN(parseFloat(v_scriptlevel)) || (parseFloat(v_scriptlevel) == 1 /*correct earlier problems*/)) {

	// if no cookie was set by server

	// server has created scriplevel0 (d)html

	// enable postprocessing to update html after all has loaded

	postprocessing = true;

	// default to scriptlevel 4

	v_scriptlevel = 4;

} 



// init config object

o_config = {scriptlevel:v_scriptlevel}



// fill config with query vars

var lhrefs =  location.href.split('?');

if (typeof(lhrefs[1]) != 'undefined')

{

	var qvars = lhrefs[1].split('&');

	for (var i = 0; i < qvars.length; i++)

	{

		var keyvalpair = qvars[i].split('=');

		if (keyvalpair.length > 1)

		{

			o_config[keyvalpair[0]] = keyvalpair[1];

		}

		else

		{

			o_config[qvars[i]] = true;

		}		

	}

}



// force scriptlevel to numeric

o_config["scriptlevel"] -= 0;



// check if ajax is supported

//alert('about to check ajax support');





// adjust scriptlevel if necessary

//alert(o_config["scriptlevel"]);



//TODO hier kan scriptlevel op 0 worden gezet voor probleembrowsers

//TODO fix de werking van scriptlevel 0 (voornamelijk redirecten van FPR van onclick events)





// remember scriptlevel settings for followup page

f_cookie_set('scriptlevel',o_config["scriptlevel"]);









// SPINNER LIST

o_spinnerlist = {

	i: 0,

	

	addspinner : function () {

		return i++;

	}

}



// CONFIG

v_cartID = "_cart_";





// mark parsing xhtml as 'not done'

v_parsingxhtml_done = false;







// scroll into view

function f_forcevisiblecartitem(id)

{

	var o = gE(id);

	if ((o)&&(typeof(o.scrollIntoView)=='function')) {

		o.scrollIntoView(false);

	} else {

		if (typeof(o.offsetTop)!= 'undefined') {

		 if (o.offsetTop < o.parentNode.scrollTop || o.offsetTop > (o.parentNode.scrollTop + o.parentNode.offsetHeight)) {

			 o.parentNode.scrollTop = o.offsetTop;

		 };

		}

	}

}

// animated highlight blue

function f_fadeBG(id,step, removeatend) {

	

	var c = ['#1597DA','#80C1E2','#B5D5E6','#D1E0E8','#EAEAEA','#FFFFFF']

	

	var o = gE(id);

	if (o != null) {

		o.style.backgroundColor = c[step];



		// see if other items require a bg update as well

		var i = 0;

		while ((o = gE(id+"_bg"+i)) != null) {

			o.style.backgroundColor = c[step];

			i++;

		}

		step++;

		if (typeof(c[step]) == 'undefined') {

		

			if (typeof(removeatend) != 'undefined') gE(id).parentNode.removeChild(gE(id));

			

			

		} else {

			window.setTimeout("f_fadeBG('"+id+"',"+step+", "+removeatend+");",100,"JavaScript");

		}

	}

}





o_onCartUpdate_Server = {

	f_timestamp : function() {

		var d = new Date();

		return d.getTime();

	},



	v_timeoutId : 0,

	v_lastSubmit : 0,

	v_updateTInterval : 500,

	v_updateTMinMargin : 100,

	f_onListChange : function(v_eventname,v_listid,v_productid,v_amount) {

		// check if any data has changed

		switch (v_eventname) {

		case "clearlist":

		case 'amountchange':			// check if timeout is pending

			if (this.v_timeoutId != 0) {

				// update will be submitted automatically within v_updateTInterval

			} else {

				// get current timestamp

				var dt = this.f_timestamp() - this.v_lastSubmit;

				// check if last update is too recent

				if (dt < this.v_updateTInterval) {

					// determine wait

					var v_wait = this.v_updateTInterval - dt; // (t - this.v_lastSubmit);

	

					// make sure some time between this code and processing of timeout

					if (v_wait < this.v_updateTMinMargin){

						v_wait = this.v_updateTMinMargin;

					}

	

					// set timeout

					this.v_timeoutId = window.setTimeout("o_onCartUpdate_Server.f_onTimeout_Update()",v_wait);

					// window.status = "timeout set";

				} else {

					this.f_doUpdate();

				}

			}

			break;

		default:

			break;

		}



	},



	f_doUpdate: function (v_postprocessscript) {

		

		debug_trace("upd");		



		// mark time

		this.v_lastSubmit = this.f_timestamp() ;

		

//		if (v_postprocessscript != null) {

//			window.setTimeout("alert('hello'),2000);",2000); // v_postprocessscript,2000);

//			eval(v_postprocessscript);	

//		}

		//force POST

        //BEGIN TOEVOEGING

        if (navigator.platform.toLowerCase().indexOf("win") == -1)

        {

        	try

        	{

//        		if (navigator.vendor.toLowerCase().indexOf("apple") != -1)

//        		{

//			        //use GET for mac (safari)

//					requestAjaxResponse("/process?action=albert.order.save_cart&order_line="+o_shop_db.getcartitemsdatastring(), v_postprocessscript);

//        		}

//				else

//				{

					requestAjaxResponse("/process?action=albert.order.save_cart", v_postprocessscript, null, null, null, "order_line="+o_shop_db.getcartitemsdatastring());

//				}

        	}

        	catch(e)

        	{

        	    debug_trace("trouble finding browser vendor or userAgent: " + e.message);

				requestAjaxResponse("/process?action=albert.order.save_cart", v_postprocessscript, null, null, null, "order_line="+o_shop_db.getcartitemsdatastring());

        	}

        }

        // EINDE TOEVOEGING

        else

        {

			requestAjaxResponse("/process?action=albert.order.save_cart", v_postprocessscript, null, null, null, "order_line="+o_shop_db.getcartitemsdatastring());

		}

	},



	f_onTimeout_Update: function (v_postprocessscript) {

		// update

		// window.status = "timeout done";

		this.v_timeoutId = 0;

		this.f_doUpdate(v_postprocessscript);

		// set timeoutId to indicate no update is pending

		

		

	},



	



	f_ensureLastUpdateIsProcessed: function() {

		// alert('heihoo');

		if (this.v_timeoutId != 0) {

			

			window.clearTimeout(this.v_timeoutId);

			this.v_timeoutId = 0;



			f_cookie_set('cart_updatepending','true');



			this.f_onTimeout_Update(); 



			

		} else {

			// alert("debug: o_onCartUpdate_Server::f_ensureLastUpdateIsProcessed");

		} 

	}

	

}



function f_check_LastUpdateIsProcessed() {

	o_onCartUpdate_Server.f_ensureLastUpdateIsProcessed();

	debug_trace('ALL CARTS UPDATES DONE!');

}



o_onCartUpdate_Visual = {



	



	f_onListChange : function(v_eventname,v_listid,v_productid,v_amount) {



		var updatetotals = false;

		

	

		switch (v_eventname) {

		case 'beforeclearlist':

			for (var i in o_shop_db.lists[v_listid].items) {

				var o_addtocartimgbuttons = document.getElementsByName("addtocart_"+o_shop_db.lists[v_listid].items[i].v_productid);

				

				for (var j = 0; j < o_addtocartimgbuttons.length; j++) {

					o_addtocartimgbuttons[j].className = "addtocart";

				}

			}

			break;

		case 'clearlist':

			gE("cart_contents").innerHTML = "";

			updatetotals = true;

			break;

		case 'amountchange':

			// check if list is changed based on new xhtml 

			// if that is the case don't insert additional items

			if (v_parsingxhtml_done) {

				// determine unique item id within list

				var li_id = "list_"+v_listid+"_"+v_productid;

	

				if (gE(li_id)) {

					// if it exists just rewrite amount and total value

					// if items should be removed

					if (v_amount <=0) {

						gE(li_id + "_amount").value = 0;

						f_fadeBG(li_id,0,true);

						// gE(li_id).parentNode.removeChild(gE(li_id));

					} else {

						gE(li_id).style.display = 'block';

						if (o_shop_db.lists[v_listid].items[v_productid].v_totaldiscount > 0) {

							gE(li_id + "_total").innerHTML = "<span id=\""+li_id+"_bg0\" class=\"promo\">"+ o_shop_db.lists[v_listid].items[v_productid].v_totalprice + "</span>"; // o_shop_db.f_determine_totalprice(v_productid,v_amount);

						} else {

							gE(li_id + "_total").innerHTML = "<span id=\""+li_id+"_bg0\" class=\"maskbg\">"+ o_shop_db.lists[v_listid].items[v_productid].v_totalprice + "</span>"; // o_shop_db.f_determine_totalprice(v_productid,v_amount);

						}

						gE(li_id + "_amount").value = o_shop_db.lists[v_listid].items[v_productid].v_amount;

					}

				} else {

					// else add 

					var addedelement = document.createElement("div");

					addedelement.id = li_id;

					addedelement.className = "product";

	

					

					var addeditem = ""; 

									

	

				

					

					addeditem += "<div class=\"pa\">";

					addeditem += "<input autocomplete=\"off\"  id=\""+li_id+"_amount\" class=\"addamount\" type=\"text\" value=\""+v_amount+"\" name=\"amount\" size=\"1\"  onblur=\"f_onlistspinner_input(this,'"+v_listid+"',"+v_productid+");\" onkeydown=\"f_onlistspinner_key(this,'"+v_listid+"',"+v_productid+",event);\" onchange=\"f_onlistspinner_input(this,'"+v_listid+"',"+v_productid+");\" />";

					addeditem += "<div class=\"spinner\">";

					addeditem += "	<img class=\"spinner_up\" src=\"/img/spinner_up.gif\" onclick=\"f_onlistspinner_button(this,'"+v_listid+"',"+v_productid+",1)\" "

					if (v_browserisIE) addeditem += "ondblclick=\"f_onlistspinner_button(this,'"+v_listid+"',"+v_productid+",1)\" ";

					addeditem += "/>";

					addeditem += "<img class=\"spinner_down\" src=\"/img/spinner_down.gif\" onclick=\"f_onlistspinner_button(this,'"+v_listid+"',"+v_productid+",-1)\" ";

					if (v_browserisIE) addeditem += "ondblclick=\"f_onlistspinner_button(this,'"+v_listid+"',"+v_productid+",-1)\" ";

					addeditem += "/>";

					addeditem += "</div>";

					addeditem += "</div>";

					

					addeditem += "<div class=\"pn\">";

					addeditem += o_shop_db.map[v_productid].v_desc;

					addeditem += "</div>";

					

					addeditem += "<div class=\"pp\">";

					addeditem += "<div id=\""+li_id + "_total\" class=\"p_total\">"

					addeditem += "<span id=\""+li_id+"_bg0\" class=\"";

					if (o_shop_db.lists[v_listid].items[v_productid].v_totaldiscount > 0) {

						addeditem += "promo";

					} else {

						addeditem += "maskbg";

					}

					addeditem += "\">" + o_shop_db.lists[v_listid].items[v_productid].v_totalprice + "</span>";

					addeditem += "</div>";

					addeditem += "</div>";



					

					addedelement.innerHTML = addeditem;

					

					var beforeelement = gE("cart_contents").firstChild;

					if (typeof(beforeelement) != 'undefined') {

						gE("cart_contents").insertBefore(addedelement,beforeelement);

					} else {

						gE("cart_contents").appendChild(addedelement);

					}

				

				}

	 



				// TODO: only set cart icon when amount changed from or to 0

				// set corect cart icon on buttons

				var v_addtocartimgurl = ((v_amount > 0) ?"addtocart full":"addtocart");

				var o_addtocartimgbuttons = document.getElementsByName("addtocart_"+v_productid)

				for (var i = 0; i < o_addtocartimgbuttons.length; i++) {

					o_addtocartimgbuttons[i].className = v_addtocartimgurl;

				}



				// scroll cartitem into view

				if (v_amount > 0) {

					f_forcevisiblecartitem(li_id)

					f_fadeBG(li_id,0);

				}



			}

			updatetotals = true;

			break;



		}



		if (updatetotals) {

			gE("cart_discounttotal").innerHTML = "&euro;&nbsp;" + o_shop_db.getlisttotaldiscount(v_listid);

			gE("cart_subtotal").innerHTML = "&euro;&nbsp;" + o_shop_db.getlisttotalprice(v_listid);

		}

		

		// check if cart has to scroll, if so, change width of cart

		var obj = gE('cart_contents');

		if (obj) {

			if (obj.clientHeight < obj.scrollHeight) obj.parentNode.className = "white_block scrollbar";

			else obj.parentNode.className = "white_block";

		}

		

	}

	

	



}



function object2string(o,dl) {

	var d = "";

	var s = "";

	for (i in o) {

		s += d +i+":"+o[i];

		if (dl != null) {

			d = dl;

		}

	}

	return s;

}







o_shop_db = {



	// hash map for all products encountered since last full page refresh

	map : {},

	

	// map of lists used in page

	// note: cartname should match v_cartID value

	lists : {_cart_:{name:'winkelwagen',id:v_cartID,items:{},listeners:[o_onCartUpdate_Visual]}},





	f_mapToString: function() {

		var s = "";

		for (i in this.map) {

			s += i + ":\n" + object2string(this.map[i]);

		}

		return s;

	},



	f_priceString: function (v) {

		var cents = " " + Math.round((v + 1)*100);

		return Math.floor(v) + "." + (cents.substr(cents.length-2));

	},



	

	// discount cached for repeated checks if discount is applied 

	// determine total price call this function

	v_last_determine_itemdiscount_result : 0,



	f_determine_itemdiscount : function (v_productid, amount) {

		var discount = 0.00;

		var item = this.map[v_productid];

		if(item.v_promoPrice != 0 || (item.v_promoFlg == 'true'))

		{

			discount += amount * (item.v_price - item.v_promoPrice);

		}

		if ((item.v_discPerUnit > 0) && (amount >= item.v_discUnit))

		{

			var nrofDiscounts = 1;

			if (item.v_discRate > 0)

			{

				nrofDiscounts = amount / item.v_discUnit;

			}

			if (item.v_discRepeats)

			{

				var rest = amount % item.v_discUnit;

				nrofDiscounts = (amount - rest) / item.v_discUnit;

			}

			discount += nrofDiscounts * item.v_discPerUnit;

		}

		else if ((item.v_discPerStructUnit > 0) && (amount >= item.v_structDiscUnit))

		{

			var nrofDiscounts = 1;

			if (item.v_structDiscRate > 0)

			{

				nrofDiscounts = amount / item.v_structDiscUnit;

			}

			if (item.structDiscRepeats)

			{

				var rest = amount % item.v_structDiscUnit;

				var nrofDiscounts = (amount - rest) / item.v_structDiscUnit;

			}

			discount += nrofDiscounts * item.v_discPerStructUnit;

		}

		discount = parseFloat(discount);

		discount *= 100;

		//voorkom javascript afrondingsfout als gevolg van float vermenigvuldiging

		discount += 0.5000001;

		discount = Math.floor(discount);

		discount /= 100;

		

		// discount is cached for repeated checks if discount is applied

		v_last_determine_itemdiscount_result = discount;



		return discount;

//		return 0;

	},

	

	addlist : function (v_listid,v_listname) {

		if (typeof(this.lists[v_listid]) == 'undefined') {

			this.lists[v_listid] = {v_listid:v_listid,name:v_listname,items:[],listeners:[]};

		}

		return this.lists[v_listid];

	},



	addlistenertolist : function (v_listid,o_listener) {

		if (typeof(this.lists[v_listid]) != 'undefined') {

			var i = this.lists[v_listid].listeners.length;

			this.lists[v_listid].listeners[i] = o_listener;

			// if (typeof(o_listener.list_notifiers) == undefined) {

			//	o_listener.list_notifiers = [];

			//}

			//var j = o_listener.list_notifiers.length;

			//o_listener.list_notifier_ids[j] = v_listid;

		}

	},

	

	setlistitemtotalpriceanddiscount : function (v_listid, v_productid) {

		

		var v_amount = this.lists[v_listid].items[v_productid].v_amount;

		this.lists[v_listid].items[v_productid].v_totaldiscount = this.f_determine_itemdiscount(v_productid, v_amount);



		var price = 0.00;

	

		var unitPrice = 0.000; // essential for calculation in jscript





		unitPrice =  this.map[v_productid].v_price;



		price = (parseInt(v_amount) * unitPrice) - this.lists[v_listid].items[v_productid].v_totaldiscount;



		debug_trace("parseInt(v_amount)="+parseInt(v_amount)+ "\nunitPrice:"+ unitPrice + " \n discount: " + this.lists[v_listid].items[v_productid].v_totaldiscount);

				

		price *= 100;

		//voorkom javascript afrondingsfout als gevolg van float vermenigvuldiging

		price += 0.5000001;

		price = Math.floor(price);

		price /= 100;

		this.lists[v_listid].items[v_productid].v_totalprice = this.f_priceString(price);

		debug_trace("price:"+price);

	},





	

	alertMaxAmount : function (v_productid) {

		alert("Van het artikel '"+this.map[v_productid].v_name+"' kunnen maximaal "+this.getMaxAmount(v_productid)+" exemplaren besteld worden");

	},



	getMaxAmount : function(v_productid) {

		// max amount is set

		if ((this.map[v_productid] != null)&&(this.map[v_productid].v_maxAmount != null)) {

			return parseInt(this.map[v_productid].v_maxAmount);

		}

		return 99; 

	},

	



	setlistamount : function (v_listid,v_productid, v_amount, v_origincode) {

		if (typeof(this.lists[v_listid]) == 'undefined') {

			o_errorhandler.log("o_shop_db::setlistamount nonexisting list \'"+v_listid+"\'");

			return;

		}	



		





		var notify = false;



		if (v_amount > 0) {

			// check max amounts if dealing with cart list

			if (v_listid == v_cartID) {

				if (v_amount > this.getMaxAmount(v_productid)) {

					o_shop_db.alertMaxAmount(v_productid);

					v_amount = o_shop_db.getMaxAmount(v_productid);

				}

				this.map[v_productid].v_cartamount = v_amount;	

			}



			// if product is not present within list create it

			if (typeof(this.lists[v_listid].items[v_productid]) == 'undefined') {

				this.lists[v_listid].items[v_productid] = {v_productid:v_productid,v_amount:v_amount};

				

				this.setlistitemtotalpriceanddiscount(v_listid,v_productid);

				notify = true;

			} else {

				if (this.lists[v_listid].items[v_productid].v_amount != v_amount) {

					this.lists[v_listid].items[v_productid].v_amount = v_amount;

					this.setlistitemtotalpriceanddiscount(v_listid,v_productid);

					notify = true;

				}

			}

			if (v_origincode != null) {

				if (typeof(this.lists[v_listid].items[v_productid].v_origincode) == 'undefined') {

					// alert("setlistamount: " +v_origincode );

					this.lists[v_listid].items[v_productid].v_origincode = v_origincode;

				}

			}

		} else {

			v_amount = 0;

			// if product is present within list remove it

			if (typeof(this.lists[v_listid].items[v_productid]) != 'undefined') {

				delete this.lists[v_listid].items[v_productid];

				notify = true;

			} 

		}



		if (v_listid == v_cartID) {

			this.map[v_productid].v_cartamount = v_amount;	

		}



		// notify listeners

		if (notify) {

			for (var i = 0; i < this.lists[v_listid].listeners.length; i++) {

				this.lists[v_listid].listeners[i].f_onListChange('amountchange',v_listid,v_productid,v_amount);

			}

		}

	

	},



	getlistamount : function (v_listid,v_productid) {

		if (typeof(this.lists[v_listid]) == 'undefined') {

			o_errorhandler.log("o_shop_db::addtolist nonexisting list \'"+v_listid+"\'");

			return 0;

		}		

		

		if (typeof(this.lists[v_listid].items[v_productid]) == 'undefined') {

			return 0;

		} else {

			return this.lists[v_listid].items[v_productid].v_amount;

		}

	},



	addtolist : function (v_listid,v_productid, v_amount, v_origincode) {

		if (typeof(this.lists[v_listid]) == 'undefined') {

			o_errorhandler.log("o_shop_db::addtolist nonexisting list \'"+v_listid+"\'");

			return;

		}		

			

		// check something is added

		if (v_amount) {

			// if product is not present within list create it

			if (typeof(this.lists[v_listid].items[v_productid]) == 'undefined') {

				this.setlistamount( v_listid, v_productid, v_amount, v_origincode);

			} else {

				this.setlistamount(v_listid,v_productid,this.lists[v_listid].items[v_productid].v_amount + v_amount, v_origincode);

			}

		}

	},

	

	clearlist : function(v_listid) {

		if (typeof(this.lists[v_listid]) == 'undefined') {

			o_errorhandler.log("o_shop_db::clearlist nonexisting list \'"+v_listid+"\'");

			return;

		}







		// notify listeners before clearlist

		// so all affected gui elements can be updated visually

		for (var i = 0; i < this.lists[v_listid].listeners.length; i++) {

			this.lists[v_listid].listeners[i].f_onListChange('beforeclearlist',v_listid);

		}



		// delete all entries in items

		for (var i in this.lists[v_listid].items) {

			delete this.lists[v_listid].items[i]

		}



		// notify listeners

		for (var i = 0; i < this.lists[v_listid].listeners.length; i++) {

			this.lists[v_listid].listeners[i].f_onListChange('clearlist',v_listid);

		}

			

	},



	listisempty : function (v_listid) {

		if (typeof(this.lists[v_listid]) == 'undefined') return true;

		for (var i in this.lists[v_listid].items) {

			return false;

		}

		return true;

	},



	list2string : function (v_listid,v_delimiter) {

		if (typeof(v_perproductdelimiter) == 'undefined') v_perproductdelimiter = '';

		var s = 'list ' + v_listid;

		for (var i in this.lists[v_listid].items) {

			s += v_delimiter + i + ":" + v_delimiter + "{ "+ object2string(this.lists[v_listid].items[i],"," + v_delimiter) + "},";

		}

		return s;

	},



	// generate data string conform submit string used in albert v1

	getlistitemsdatastring :  function (v_listid,v_perproductdelimiter) {

		if (typeof(this.lists[v_listid]) != 'undefined') {

			if (typeof(v_perproductdelimiter) == 'undefined') v_perproductdelimiter = '';

			var s = "";

			for (var v_productid in this.lists[v_listid].items) {

				

				var oc = this.lists[v_listid].items[v_productid].v_origincode;

				oc = (typeof(oc)=='undefined') ? '??' : oc;

				

				s = "|"+v_productid+"|"+this.lists[v_listid].items[v_productid].v_amount+"|"+this.map[v_productid].v_catalogcode+"|"+ oc +v_perproductdelimiter + s;

			}

			

			return s;

		}

	},



	getlisttotalprice : function (v_listid) {

		var t = 0;

		for (var i in this.lists[v_listid].items) {

			t += parseFloat(this.lists[v_listid].items[i].v_totalprice);

		}

		return this.f_priceString(t);

	},



	getlisttotaldiscount : function (v_listid) {

		var t = 0;

		for (var i in this.lists[v_listid].items) {

			

			t += this.lists[v_listid].items[i].v_totaldiscount;

			

		}

		return this.f_priceString(t);

	},

	





	addtocart : function (v_productid,v_amount,v_confirmhighvalue,v_origincode) {

		if ((v_confirmhighvalue != null)&&(v_confirmhighvalue))	{

			var namount = this.getlistamount(v_cartID,v_productid) + v_amount;

			if (namount >= 15) {

				if (confirm('Weet u zeker dat u '+namount+' stuks van het artikel '+this.map[v_productid].v_name+' wilt bestellen?')) {

				} else {

					return;

				}

			}

		}



		this.addtolist(v_cartID,v_productid,v_amount,v_origincode);

	},



	setcartamount : function (v_productid,v_amount) {

		this.setlistamount(v_cartID,v_productid,v_amount);

	},



	clearcart : function () {

		this.clearlist(v_cartID);

	},	



	cartisempty : function () {

		return this.listisempty(v_cartID)

	},



	getcartitemsdatastring: function (v_perproductdelimiter) {

		return this.getlistitemsdatastring(v_cartID,v_perproductdelimiter);

	},





	parseproductlog:"",

	json_parsefordb : function (o_productdivelement) {

		



//		var subelements = o_productdivelement.childNodes;

		var subelements = o_productdivelement.getElementsByTagName("DIV");

		for (var i = 0; i < subelements.length; i++) {

//			if (subelements[i].nodeType == 1) {

				if (subelements[i].className == 'json') {

					// this.parseproductlog += subelements[i].innerHTML+"\n";

					var o_product = eval("({"+subelements[i].innerHTML+"})");

					if (typeof(o_product.v_cartamount) == 'undefined') {

						o_product.v_cartamount = 0;

					} else {

						// this.parseproductlog += "evalled count: "+o_product.v_cartamount+"\n"

					}

					o_product.v_desc = "<a href=\"#\" title=\""+o_product.v_name+"\" onclick=\"f_showproductinfowindow('"+o_product.v_productid+"');\" >"+o_product.v_name+"</a>";

					return o_product;

				}					



				

					// if element not recognized but does have children (tables in productline for instance..)

					// try to parse these

//				if (subelements[i].childNodes.length > 0) {

//					return this.hierarchical_parsefordb(o_product,subelements[i]);

//				}			

//				} 

//			}

		}



	},



	addtodb : function (o_productdiv) {

	

		var o_product = this.json_parsefordb(o_productdiv);



		

		if (typeof(o_product) == 'undefined') {

			return;

		} 

		

		//this.parseproductlog += "count: " + o_product.v_cartamount+ " " + this.map[o_product.v_productid].v_cartamount + "\n";





		if (typeof(o_product.v_productid) != 'undefined') {

			if (typeof(this.map[o_product.v_productid]) == 'undefined') {

				// this.parseproductlog += "adding product\n";

				// add product to db

				this.map[o_product.v_productid] = o_product;

				// add product to cart if required

				if (o_product.v_cartamount) {

					this.addtocart(o_product.v_productid,o_product.v_cartamount); // .v_productid] = o_product;

					// todo check if update of cart html is required

				}

				

			} else {

				// this.parseproductlog += "updating product "+o_product.v_cartamount+"\n";





				if ((o_product.v_cartamount)&&(o_product.v_cartamount > 0)) {

					

					this.setlistamount(v_cartID,o_product.v_productid,o_product.v_cartamount);

					

					//this.parseproductlog += "count: "+o_product.v_cartamount+"\n"

					

				}

				// TODO: check price changes

			}

			

			// this.parseproductlog += "count: " + o_product.v_cartamount+ " " + this.map[o_product.v_productid].v_cartamount + "\n";

			

			return o_product.v_productid;

		} else {

			alert("(typeof(o_product.v_productid) != 'undefined')\n"+o_productdiv.outerHTML);

		}

	},

	

	show_distillfeedback: 0,



	distillfromhtml : function (id_htmlcontainer) {

		var o_container = gE(id_htmlcontainer);

		

		if (o_container != null) {

			var elements = o_container.getElementsByTagName("div");

			var ss = "";

			for (i = 0; i < elements.length; i++) {

				var cName = elements[i].className;

				if (typeof(cName) != 'undefined' && cName == "product") {

					ss += "<br/>"+ cName + " ";



					var v_productid = this.addtodb(elements[i]);



					if (typeof(v_productid) == 'undefined')

					{

						//element does not contain a parseable product

						debug_trace('element with class ' + cName + ' does not contain a parseable product');

					}

					else

					{

						ss += v_productid + " " + this.map[v_productid].v_desc;

					}

				}

			}

			if (this.show_distillfeedback) {

				f_dhtmldialog_create(ss + String(o_container.innerHTML).split('&').join('&amp;').split('<').join('&lt;').split('>').join('&gt;').split('\n').join('<br/>'),

							'distillfromhtml',"",null,300,300);

			}

		}

		

	}

	





}









/*

function f_iswhitespace(c) {

	return ((c == " ")||(c == "\n")||(c == "\r")||(c == "\t"))

}



function f_strtrim(v) {

	var s = 0;

	while(s < v.length) {

		if (f_iswhitespace(v.charAt(s))) {

			s++;

		} else {

			break;

		}

	}

	if (s < v.length) {

		var e = v.length - 1;

		while(e < v.length) {

			if (f_iswhitespace(v.charAt(e))) {

				e--;

			} else {

				break;

			}

		}

	}

	

} */



var registered_spinners = new Array();



function f_onshopspinner_register_spinner(v_spinnerid, v_articleid, v_catalogid) {

	registered_spinners[v_spinnerid] = v_articleid + '_' + v_catalogid;

}



function f_onshopspinner_get_entered_amount(v_spinnerid) {



	var o_input = gE("amountinput_"+v_spinnerid);



	if (o_input == null || typeof(o_input) == 'undefined' || typeof(o_input.value) == 'undefined') {

		return 0;

	}

	return parseInt(o_input.value);	

}



function f_onshopspinner_complete_orderline(v_origin_code) {

	var orderline = '';

	for (var spinner_id in registered_spinners) {

		var item_identifier = registered_spinners[spinner_id];

		var underscore_pos = item_identifier.indexOf('_');

		var item_id = item_identifier.substring(0, underscore_pos);

		var catalog_id = item_identifier.substring(underscore_pos+1);

		var quantity = f_onshopspinner_get_entered_amount(spinner_id);

		orderline += '|' + item_id  + '|' + quantity + '|' + catalog_id + '|' + v_origin_code;

	}

	return orderline;	

}



function f_onshopspinner_input(o_input,v_spinnerid) {

	if (o_input.value < 1) {

		o_input.value = 1;

	} else {

		var v = Math.round(o_input.value)

		if (v < 0) {

			v = 0;

		}

		if (v != o_input.value) {

			o_input.value = v;

		}

	}

}



function f_onshopspinner_button(o_button,v_spinnerid,v_delta) {

	var o_input = gE("amountinput_"+v_spinnerid);



	v = parseInt(o_input.value) + v_delta;

	// important: allow 0 value to be able to set items in a list to 0 and

	// then add the whole list to the cart

	if (v >= 0)

	{

			o_input.value  = v;

	}

	else

	{

			o_input.value = 0;

	}



	if (gE('savechange_'+v_spinnerid) != null) {

		f_onshopspinner_listcountkeyup(o_input,v_spinnerid);

	}

}



function f_onshopspinner_dblclick(o_button,v_spinnerid,v_delta) 

{

	if (v_browserisIE) 

	{

		f_onshopspinner_button(o_button,v_spinnerid,v_delta);

	}

}





function f_keyeventisenter(v_event) {

	if (window.event) 

	{

		v_event = window.event;

	}

	return (v_event.keyCode == 13) 

}



function f_onlistspinner_key(o_input,v_listid,v_productid,v_event) 

{

	if (f_keyeventisenter(v_event)) {

		f_onlistspinner_input(o_input,v_listid,v_productid);

	}

	

}

/*

function f_onlistspinner_key(o_input,v_listid,v_productid,v_event) 

{

	if (window.event) 

	{

		v_event = window.event;

	}

	if (v_event.keyCode == 13) 

	{

		f_onlistspinner_input(o_input,v_listid,v_productid);

	}

	

}

*/



function f_onlistspinner_input(o_input,v_listid,v_productid)

{

	var v = parseInt(o_input.value);

	if (!isNaN(v))

	{

		if (v > o_shop_db.getMaxAmount(v_productid)) 

		{

			o_input.value = o_shop_db.getMaxAmount(v_productid);

			o_shop_db.alertMaxAmount(v_productid);

			v = o_shop_db.getMaxAmount(v_productid);

		}		

		o_shop_db.setlistamount(v_listid,v_productid,v);

	}

}



function f_onlistspinner_button(o_button,v_listid,v_productid,v_delta)

{

	debug_trace("called: f_onlistspinner_button("+v_listid+","+v_productid+","+v_delta+");");

	o_shop_db.addtolist(v_listid,v_productid,v_delta);

}



function f_onlistspinner_dblclick(o_button,v_listid,v_productid,v_delta)

{

	if (v_browserisIE) { f_onlistspinner_button(o_button,v_listid,v_productid,v_delta); }

}



function f_onAjaxShopUpdate()

{

	// distill product parameters 

	o_shop_db.distillfromhtml('shop_scrollpane');

}



function f_onAjaxFullCartUpdate()

{

	// distill product parameters 

	o_shop_db.distillfromhtml('dock_cart');

}



// order submit pages require full page refreshes for addtocart 

var v_addtocart_force_fullpagerefresh = false;

var v_addtocart_force_fullpagerefresh_url;

function f_addtocart_force_fullpagerefresh(redirectUrl)

{

	v_addtocart_force_fullpagerefresh_url = redirectUrl;

	v_addtocart_force_fullpagerefresh = true;

}



function f_onshopspinner_listcountfocus(o_input,v_spinnerid) {

	if (typeof(o_input.storedvalue) == 'undefined') {

		o_input.storedvalue = o_input.value;

	}

}



function f_onshopspinner_listcountkeyup(o_input,v_spinnerid) {

	var enablesave = false;

	if (o_input.storedvalue != o_input.value) {

		var v = parseInt(o_input.value) 

		if ((!isNaN(v))&&(v >=0 )) {

			enablesave = true;

		}

	}

	

	gE('savechange_'+v_spinnerid).style.display = enablesave ? 'inline' :'none';

	

}



function f_onshopspinner_listcountchange(o_input,v_spinnerid) {

	f_onshopspinner_listcountkeyup();

	f_onlistspinner_input();

}



function f_onshopspinner_listcountsave(o_button,v_spinnerid,v_articleid,v_shoppinglist) {

	var o_input = gE('amountinput_'+v_spinnerid);

	var count = o_input.value;



	requestAjaxResponse("/process?action=albert.list.modify_item_quantity&listno=" + v_shoppinglist + "&itemno=" + v_articleid + "&catacode=" + o_shop_db.map[v_articleid].v_catalogcode + "&quantity=" + count, null, null, null, null, null);





	// set new value as stored value

	o_input.storedvalue = o_input.value;

	f_onshopspinner_listcountkeyup(o_input,v_spinnerid);

}



function f_onshopspinner_addtocart(o_button,v_spinnerid,v_articleid,originCode)

{



	// get amount

	var o_input = gE("amountinput_"+v_spinnerid);

	

	var v = parseInt(o_input.value);





	// check if ajax cart updates are allowed

	if (v_addtocart_force_fullpagerefresh)

	{

		// if non ajax forced:

		switch (o_config["scriptlevel"]-0)

		{

		case 1:

			// use existing form

			gE("addtoorderform_"+v_spinnerid).submit();

			break;

		default:

			// create a temp form to submit using POST

			var tempformdiv = cE("div");

			document.body.appendChild(tempformdiv);

			var uid = "formid_addtocart_force_fullpagerefresh";

			var f = "<form id=\""+uid+"\" action=\"/process\" method=\"GET\">";

			f += "<input type=\"hidden\" name=\"action\" value=\"albert_noscript.list.add_to_cart_or_list\">";

			

			if (v_addtocart_force_fullpagerefresh_url != null) {

				f += "<input type=\"hidden\" name=\"redirectUrl\" value=\"" + v_addtocart_force_fullpagerefresh_url + "\">";

			}

			

			f += "<input type=\"hidden\" name=\"amount\" value=\""+v+"\"/>";

			f += "<input type=\"hidden\" name=\"catalog_code\" value=\""+o_shop_db.map[v_articleid].v_catalogcode+"\" />";

			f += "<input type=\"hidden\" name=\"item_no\" value=\""+v_articleid+"\" />";

			f += "<input type=\"hidden\" name=\"origin_code\" value=\""+originCode+"\" />";

			f += "<input type=\"hidden\" name=\"isForcedFullPageRequest\" value=\"true\" />";

			f += "</form>";

			tempformdiv.innerHTML = f;

			gE(uid).submit();

		}		

	}

	else

	{

		// use ajax if possible

		switch (o_config["scriptlevel"]-0)

		{

		case 1:

			gE("addtoorderform_"+v_spinnerid).submit();

			break;

		case 3:

			var cataCode = o_shop_db.map[v_articleid].v_catalogcode;

			requestAjaxResponse('/process?action=albert.order.add_to_cart&item_no=' + v_articleid + '&catalog_code=' + cataCode + '&amount=' + v + '&origin_code=' + originCode,'f_onAjaxFullCartUpdate();','dock_cart','feedbackajaxmetaprocess');

			break;		

		case 2:

		case 4:

			o_shop_db.addtocart(v_articleid,v,true,originCode);

			break;

		}

	}

}





function f_remove_item_from_shopping_list(shoppingListId, itemId, catalog) {

	requestAjaxResponse('/process?action=albert_noscript.my_webshop.remove_item_from_shopping_list&ajax=true&itemId=' + itemId + '&listId=' + shoppingListId + '&itemShopCode=' + catalog);

}





// called by 'bestel' button

function f_cart_order_contents()

{

	return true;

}



// called by 'alles uit wagen' link

function f_cart_discard_contents()

{

	if (o_shop_db.cartisempty())

	{

		// if nothing to be deleted

		// kill further processing

		return false;

	} 

	if (confirm('Weet u zeker dat u alle artikelen uit de winkelwagen wilt verwijderen?\r\n\r\nLet op, u kunt hiermee niet uw bestelling annuleren!'))

	{



		switch (o_config["scriptlevel"]-0)

		{

		case 4:

			// do an ajax update

			o_shop_db.clearcart();

			// kill further processing

			return false;

			break;

		default:

			// allow default processing

			return true;

		}

		

	} 

	else

	{

		// if confirm returned false

		// kill further processing

		return false;

	}

}









// reference to last animated list button

// needed to reset it back to the default image

// to prevent it running its animation together 

// with last list button

var o_lastlistbuttonclicked;



function f_onshopspinner_addtolist(o_button,v_spinnerid,v_articleid) 

{

	// get amount

	var o_input = gE("amountinput_"+v_spinnerid);

	var v = parseInt(o_input.value);



	// check if cart is selected

	var o_selects = document.getElementsByName("shopping_list_no");

	if (o_selects[0].options[o_selects[0].selectedIndex].value < 0) {

		f_fadeBG('listselect_body',3);

		alert('Om artikelen aan een boodschappenlijstje toe te voegen\ndient u eerst een boodschappenlijstje te selecteren.');

		return;

	}





	switch (o_config["scriptlevel"]-0) {

	case 2:

		alert('cannot add to list at level 2');

		break;

	case 1:

		

			

		gE("addtoorderform_"+v_spinnerid).submit();

		break;

	case 3:

	case 4:

		// use default image for last selected list button

		// to prevent it animating too

		if (o_lastlistbuttonclicked != null)

		{

			o_lastlistbuttonclicked.src = "/img/misc/li.gif";

		}	

		// remember list button

		o_lastlistbuttonclicked = o_button;

		// get catalog code

		var cataCode = o_shop_db.map[v_articleid].v_catalogcode;

		// do ajax request

		requestAjaxResponse('/process?action=albert.list.add_item&item_no=' + v_articleid + '&catalog_code=' + cataCode + '&amount=' + v/*,'f_onAjaxListUpdate();'*/);

		o_button.src = "/img/misc/lif.gif";

		break;

	}

}







function f_event_oncartupdateamountclicked(o_event)

{

	var o_tgtelement;

	if (o_event["target"])

	{ // if non IE

		o_tgtelement = o_event["target"];

	} 

	else

	{ // if IE

		o_tgtelement = o_event["srcElement"];

	}

}





// CREATE SHOPPING LIST 



// window id

var createShoppingList_window_id;





// create window

function f_createShoppinglist_dialogbody(v_name,v_errormsg) {

	var v_prefix = "";

	if (v_name == null) {

		v_name = "";

	}

	if (v_errormsg != null) {

		v_prefix = "<p class=\"errorlabel\">"+v_errormsg+"</p>";

	}

	return "<div style=\"width:auto;padding:8px 12px 12px 12px;\">" + v_prefix + "Voer een naam in voor het nieuwe boodschappenlijstje:<br/><form style=\"margin:0 0 0 0;padding:0 0 0 0;\" action=\"#\" onsubmit=\"return f_event_okClickedCreateShoppingList();\"><input id=\"newListName\" type=\"text\" name=\"newListName\" value=\""+name+"\" onmousedown=\"f_stopProp(event);\"></form><p>Klik op OK om het lijstje te creëren.</p><div class=\"close\"><a style=\"float:left;\" class=\"buttonleft\" href=\"#\" onclick=\"return f_closeinfopopup(this);\">annuleren</a><a class=\"buttonright_aligned\" href=\"#\" onclick=\"f_event_okClickedCreateShoppingList(this);\">OK</a></div></div>";

}





function f_disableShoppingListViewButtons(v) {

	debug_trace("f_disableShoppingListViewButtons("+v.toString()+")");

	if (v == null) v = true;

	var o_viewbuttons = document.getElementsByName("shopping_list_viewbutton");

	for (var i = 0; i < o_viewbuttons.length; i++) {

		o_viewbuttons[i].className = (v? "disabled" :"") ;

		o_viewbuttons[i].disable = v;

		

	}

	

}



function f_metadataprocessor_createShoppingList(metadata) {

	

	if (metadata["addshoppinglistresult"] != null) {

		

		if (metadata["addshoppinglistresult"] == "success") {



			if ((metadata["listid"] != null)&&(metadata["listname"] != null)) {



				if (typeof(createShoppingList_window_id) !=  'undefined') {

					f_dhtmldialog_close(createShoppingList_window_id);

				}

			

				var o_selects = document.getElementsByName("shopping_list_no");

				for (var i = 0 ; i < o_selects.length; i++) {

					debug_trace("o_selects["+i+"]");

					var o_option = document.createElement("option");

					o_selects[i].options.add(o_option, o_selects[i].options.length-2);

					o_option.innerText = metadata["listname"];

					o_option.text = metadata["listname"];

					o_option.value = metadata["listid"];

					o_selects[i].selectedIndex = o_selects[i].options.length-3



				}



				f_disableShoppingListViewButtons(false)



			} else {

				alert('Error: incomplete data')

			}

		} else {

			var o_body = f_dhtmldialog_get_body(createShoppingList_window_id);



			if (o_body != null) {

				var v_name = "";

				if (metadata["listname"] != null) {

					v_name = metadata["listname"];

				}

				var v_errormsg = "Unknown error occurred";

				if (metadata["errormessage"] != null) {

 					v_errormsg = metadata["errormessage"];

				}

				// alert(f_createShoppinglist_dialogbody(v_name,v_errormsg));

				o_body.innerHTML = f_createShoppinglist_dialogbody(v_name,v_errormsg);



				var o = gE('newListName');

				if (o != null) 

				{

					o.focus();

				}

			}

		}

	} else {

	}







}



function f_event_okClickedCreateShoppingList() {

	var newShoppingListName = gE('newListName').value;

	debug_trace("create new shoppinglist: "+newShoppingListName);

//	debug_trace("create new shoppinglist: "+newShoppingListName);

	f_dhtmldialog_get_body(createShoppingList_window_id).innerHTML = "<p>Uw nieuwe boodschappenlijst naam wordt nu toegevoegd.</p>";



	

	requestAjaxResponse('/mijnalbert/addlist.jsp?shopping_list_name=' + newShoppingListName,null,null,'f_metadataprocessor_createShoppingList');

	

	return false;

}





function f_event_selectShoppingList(o_selectelement) {



	var listNo = o_selectelement.options[o_selectelement.selectedIndex].value;

	debug_trace('f_event_selectShoppingList:' + listNo);



	if (listNo == 0)

	{

    	var dialogAvailable = false;

		if ((typeof(createShoppingList_window_id) !=  'undefined')&&(f_dhtmldialog_get_window(createShoppingList_window_id) != null))

		{

			dialogAvailable = f_dhtmldialog_tofront(createShoppingList_window_id);

		}

		if(!dialogAvailable)

		{

			createShoppingList_window_id = f_dhtmldialog_create(f_createShoppinglist_dialogbody(""),

					"Maak een nieuw boodschappenlijstje",

					"center;aapopup;iconlist;animate;frommouse;hideselects",

					o_selectelement.id,

					350);

			var o = gE('newListName');

			if (o != null) 

			{

				o.focus();

			}

		}

		//reset list

		o_selectelement.selectedIndex = 0;

		

	} else {

		requestAjaxResponse('/process?action=albert.list.select&shopping_list_no=' + listNo);



		var o_selectboxes = document.getElementsByName(o_selectelement.name);

		for (var i = 0; i < o_selectboxes.length; i++) {

			if (o_selectboxes[i] != o_selectelement) {

				o_selectboxes[i].selectedIndex = o_selectelement.selectedIndex;

			}

		}



		

	}

	f_disableShoppingListViewButtons(listNo <= 0)



	return true;

}



// VIEW SELECTED SHOPPING LIST

function f_viewSelectedShoppingList() {

	var o_selects = document.getElementsByName("shopping_list_no");

	

	if (o_selects[0] != null) {

		var v = o_selects[0].options[o_selects[0].selectedIndex].value;

		if (v > 0) {

			window.location.href = "/index.jsp?link=shopping_list&list_no="+v;

		}

	}

	return true;

}





function f_matchCheckboxStates(o_checkbox) {

	if (o_checkbox != null) {

		var o_checkboxes = document.getElementsByName(o_checkbox.name);

		for (var i = 0; i < o_checkboxes.length; i++) {

			if (o_checkboxes[i] != o_checkbox) {

				o_checkboxes[i].checked = o_checkbox.checked;

			}

		}

	}

}



function f_displayProductImages(v,o_checkbox) {

	

	if ((v==null)||(v)) {

		f_CSS_removeRule('.toggle_productimage');

		f_cookie_set('hide_productimages','');

	} else {

		if (!f_CSS_ruleExists('.toggle_productimage')) {

			f_CSS_addRule('.toggle_productimage','display:none;');

		}

		f_cookie_set('hide_productimages','true');

	}

	f_matchCheckboxStates(o_checkbox);

	return true;

		

}









// PRODUCT INFO IDS COLLECTION

productinfowindowids = {}





function f_dhd_closethis() {

	f_closeinfopopup(this);

	return false;

}



function f_closeinfopopup(o) {

	debug_trace('f_closeinfopopup')

	while(o!=null) {

		debug_trace('step11')

		if (o.className != null) {

			if (o.id.substr(0,15) == "dhtml_dialog_m_") {

				debug_trace('found for deletion '+o.className)

				var wid = o.id.substr(15);

				f_dhtmldialog_close(wid);

				return false;

			} 

		}

		o = o.parentNode;

		gE('disable_page').style.display='none';

	}

	return false;

}



function f_processproductinfometadata(o_metadata) {

	if (o_metadata.productid != null) {

		

		if (productinfowindowids["w"+o_metadata.productid]) {

			if (o_metadata.caption != null) {

				var c = f_dhtmldialog_get_window(productinfowindowids["w"+o_metadata.productid]);

				if (c) {

					var parray = c.getElementsByTagName('h2');

					parray[0].innerHTML = o_metadata.caption;

				}

			}

		}

	}

}



function f_showproductinfowindow(productid,catalogcode) 

{

	if (o_config["scriptlevel"]>0) 

	{

		if (catalogcode == null) 

		{

			catalogcode = o_shop_db.map[productid].v_catalogcode;

		}

	

		var createNewWindow = false;

		if (typeof(productinfowindowids["w"+productid]) != 'undefined') 

		{

			var w = f_dhtmldialog_get_window(productinfowindowids["w"+productid])

			// bring to front if exists and signal no further processing is req via 'a' tag

			if (f_dhtmldialog_tofront(productinfowindowids["w"+productid])) 

			{

				return false;

			}

		}





		// TODO: check ajax availability

		// create new window

	

		var wid = f_dhtmldialog_create("<div style=\"height:200px\">Productinformatie wordt geladen<br/>"+catalogcode+productid+"</div>","&nbsp;","center;aapopup;iconcart;animate;frommouse",undefined,476, undefined, undefined, true);

		productinfowindowids["w"+productid]  = wid;

	



		requestAjaxResponse('/main/products/product_info.jsp?isDhtmlDialogRequest=true&catacode='+catalogcode+'&itemno='+productid,'o_shop_db.distillfromhtml(\''+f_dhtmldialog_get_bodyid(wid)+'\');',f_dhtmldialog_get_bodyid(wid),'f_processproductinfometadata');



		// kill default link behaviour

		return false;

	}

	// allow default linke behaviour

	return true;



}



// GENERIC POPUP WITH REMOTE CONTENT



// store named popups in hashmap

var v_popup_nametoid = {}



function f_setfocus (v_id) {

	var o = gE(v_id);

	if (o != null) {

		o.focus();

	}

	

}



function f_openPopupRemoteMetaDataProcessor(o_metadata) {

	if (o_metadata.setfocus != null) {

		setTimeout('f_setfocus(\''+o_metadata.setfocus+'\')',50);

	}

	if (o_metadata.popupid != null) 

	{

		if (o_metadata.newwidth != null) {

			debug_trace('newwidth'+o_metadata.newwidth);

			f_dhd_forceWidth(o_metadata.popupid,parseInt(o_metadata.newwidth));

					

		}

//		debug_trace('o_metadata.popupid'+o_metadata.popupid);

		if (o_metadata.caption != null) 

		{

			

			var dialogObj = f_dhtmldialog_get_caption(o_metadata.popupid);

			if (dialogObj) {

				dialogObj.innerHTML =  o_metadata.caption;

			}

		}

	} else {

		debug_trace('no popupremote popupid');

	}



	/* todo add optional other processing */



}



function f_openPopupRemote(v_url,v_tempcontent,v_caption,v_popupname,v_windowstyle,v_width, v_height, v_customMetaDataProcessor, v_className) {







	if (v_customMetaDataProcessor == null) {

		v_customMetaDataProcessor = 'f_openPopupRemoteMetaDataProcessor';

	}



	// the windowid of the popup

	var v_wid = null;









	// if popupname is supplied create popup 

	if (v_popupname == null) 

	{

		// no name specified no existing popup can be popped

	} 

	else

	{

		// if popupname is supplied check if already exists

		if (typeof (v_popup_nametoid[v_popupname]) != 'undefined') 

		{

			v_wid = v_popup_nametoid[v_popupname];



			if (f_dhtmldialog_tofront(v_wid)) {

				if (v_windowstyle != null) {

					if ((";" + v_windowstyle + ";").indexOf(";noreload;") != -1) {

						return;

					}

				}

			} else {

				v_wid = null;

			}

		}

	}



	// if no existing popup should be used

	if (v_wid == null) 

	{

		// create popup

		v_wid = f_dhtmldialog_create(v_tempcontent,v_caption,v_windowstyle,

					null,(v_width == null) ? 300 : v_width,(v_height == null) ? 300 : v_height, v_className);



		if (v_popupname != null)

		{

			v_popup_nametoid[v_popupname] = v_wid;

		}

		

	} 

	else

	{

		if (v_width != null) {

			f_dhd_setWidth(v_wid,v_width);

		}

		f_dhtmldialog_get_body(v_wid).innerHTML = v_tempcontent;

		f_dhtmldialog_get_caption(v_wid).innerHTML = v_caption;

	}



	if(String(v_url).indexOf("?") == -1)

	{

	  v_url+= "?isDhtmlDialogRequest=true";

	}

	else

	{

	  v_url+= "&isDhtmlDialogRequest=true";

	}



	requestAjaxResponse(v_url,"live_correct('"+f_dhtmldialog_get_bodyid(v_wid)+"');",f_dhtmldialog_get_bodyid(v_wid),v_customMetaDataProcessor,"popupid="+v_wid);

	

}



function f_test_openPopupRemote() 

{

	f_openPopupRemote('/popuptest.html','<div style="height:100px;">loading loading loading</div>','caption1','center;iconlist;frommouse;animate')

}











// MOUSE TRACKING

var v_body_xmouse;

var v_body_ymouse;





//determine mouse x

function mouseX(evt)

{

	if (evt.pageX) 

	{

		return evt.pageX;

	}

	

	if (evt.clientX) 

	{

   		return evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);

	}

	return null;

}



// determine mouse y

function mouseY(evt) 

{

	if (evt.pageY)

	{

		return evt.pageY;

	}

	if (evt.clientY) {

	   return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);

	}

	return null;

}



// on mouse move set correct mouse x and y

function f_body_onmousemove (e) 

{

	// get event object in IE

	if (typeof e == 'undefined') e = window.event;



	// set variables

	v_body_xmouse = mouseX(e);

	v_body_ymouse = mouseY(e);

}





// SETUP ADDITIONAL CSS RULES TO SHOW HIDE SCRIPT PRESENCE DEPENDENT HTML ELEMENTS

if (o_config["scriptlevel"]>0) {

	// scripted resize

	

	// show min level 1 rule

	f_CSS_removeRule(".show_if_scriptlevel_min1");



	// hide min level 1 rule

	f_CSS_addRule(".hide_if_scriptlevel_min1","display:none");

}







// FREDHOPPER REEL







function f_animate_height(o,h,w,t) {

	// make sure oid is an id of o

	var oid = gEID(o);



	if (typeof(o) != 'object') {

		o = gE(oid);

	}



	// window.status = oid+", "+h+", "+w+", "+t+" "+ o.className;



	if (w == null)

	{

		// prevent double animation of same element

		if (o.v_animate_height_timerid) {

			window.clearTimeout(o.v_animate_height_timerid);

			o.v_animate_height_timerid = null;

		}

		w = 50;

	}



	if (t == null)

	{

		t = 4;

	}

	

	

	curh = parseInt(o.style.height);

	

	if ((t > 1)&&(h != curh)) {

		o.style.height = (curh + Math.round((h - curh)/t) ) + "px";

		o.v_animate_height_timerid = window.setTimeout("f_animate_height(\""+oid+"\","+h+","+w+","+(t-1)+")",w);

	} else {

		o.style.height = h+ "px";

		// window.status += "done";

	}

}





function f_shrink_listrow(id,step) {



	o = gE(id);

	if (typeof(o) == 'object') {

		if (step == 0) {

			o.parentNode.removeChild(o);

		} else {

	

			var ths = o.getElementsByTagName('th');

			var tds = o.getElementsByTagName('td');

		

			var trh = Math.floor( parseInt(o.style.height) * 0.5 ); // (1.6 - (1.0 / step)) );

			debug_trace('trh'+trh)

			o.style.height=trh+"px";

			

			for (var i = 0; i < ths.length; i++) {

				ths[i].firstChild.style.height = trh+"px";

				ths[i].style.height = trh+"px";

			}

		

			for (var i = 0; i < tds.length; i++) {

				tds[i].firstChild.style.height = trh+"px";

				tds[i].style.height = trh+"px";

			}

			

			step--;

			window.setTimeout("f_shrink_listrow(\""+id+"\","+step+");",100);

		}

	}	

	

}



listrowremovefullpagerefresh = -1;



function f_remove_listrow(v_rowid,v_shoppinglist,v_articleid,v_catcode) {

	o = gE(v_rowid);

	if (listrowremovefullpagerefresh == -1) 

	{

		// count listremove

		listrowremovefullpagerefresh = 0;

		var tables = document.getElementsByTagName('table');

		for (var i = 0; i < tables.length; i ++) 

		{

			if (tables[i].className == 'product_list') {

				var trows = tables[i].getElementsByTagName('tr');

				for (var j = 0; j < trows.length; j++) {

					if (trows[j].getElementsByTagName('td').length > 0) {

						listrowremovefullpagerefresh++;

					}

				}

			}

		}

	}



	// remove one:

	listrowremovefullpagerefresh --



	if (listrowremovefullpagerefresh <= 0) {

		// just do full page refresh

		return true;

	}





	if (typeof(o) == 'object') {

		var ths = o.getElementsByTagName('th');

		var tds = o.getElementsByTagName('td');

		var trh = Math.floor(o.scrollHeight * 0.5);



		o.style.height=trh+"px";



		for (var i = 0; i < ths.length; i++) {

			ths[i].innerHTML = "<div style=\"background:#F2F8FA;overflow:hidden;height:"+trh+"px;\">"+ths[i].innerHTML+"</div>";

			ths[i].style.height = trh+"px";

		}

		for (var i = 0; i < tds.length; i++) {

			tds[i].innerHTML = "<div class=\"hideshopcontrol\" style=\"background:#F2F8FA;overflow:hidden;height:"+trh+"px;\">"+tds[i].innerHTML+"</div>";

			tds[i].style.height = trh+"px";

		}

		

		window.setTimeout("f_shrink_listrow(\""+v_rowid+"\",5);",80);





		if (o_config["scriptlevel"] > 2) {

			if (v_catcode == null) {

				v_catcode = o_shop_db.map[v_articleid].v_catalogcode;

			}

			requestAjaxResponse("/process?action=albert.list.remove_item_from_list&list_no=" + v_shoppinglist + "&selected_item=" + v_articleid + "|0|" + v_catcode + "|??");



		}



		return false;

	}

	return true;



}



// FH



function f_reel_spin(v_id,v_v,v_e,v_hid,v_x,v_t) {

	// init framecounter v_t and start pos v_x 

	if(v_x==null){v_t=0;v_x=Math.random()*900}else{v_t++}

	// alter speed v_v

	// check if endtime v_e has been reached

	if (v_t > v_e) {

		// dec speed

		v_v -= 7;

		// check if speed has dropped below minspeed 40

		if (v_v <= 40) {

			// spinner ani and stop animation		

			gE(v_id).parentNode.style.display = 'none';

			return;

		}

		

	} else {

		// inc speed 

		v_v += (100 -v_v) * 0.1

	}

	// move

	v_x += v_v;

	// stay within range 

	while (v_x > 900) {v_x -= 900;}

	// set position

	var o = gE(v_id)

	o.style.top = -Math.round(v_x)+"px";

	//set height to match height object if so indicated

	if (v_hid != null) {

		o.parentNode.style.height = gE(v_hid).scrollHeight + "px";

		

	}

	// continue animation

	window.setTimeout("f_reel_spin('"+v_id+"',"+v_v+","+v_e+",'"+v_hid+"',"+v_x+","+v_t+");",60,"JavaScript");

}





function f_reel_swappage(v_reelelementid,v_increase,pickrandom)

{

	// get reference to object

	o_reelelement = gE(v_reelelementid);



	// find reel collection

	var o_multireel = o_reelelement;

	while (o_multireel.className != "productreel_container")

	{

		o_multireel = o_multireel.parentNode;

		if (o_multireel == null)

		{

			alert('no reel collection found');

			return false;

		}

	}



	// see if reel inventory has been done

	if (typeof(o_multireel.reelcollection) == 'undefined') 

	{

		// do inventory

		o_multireel.reelcollection = [];

		var o_children = o_multireel.childNodes;

		for (var i = 0; i < o_children.length; i++) 

		{

			if ((o_children[i].nodeType == 1)&&(o_children[i].className == "productreel_frame")) 

			{

				var o_children2 = o_children[i].childNodes;

				for (var j = 0; j < o_children2.length; j++) 

				{

					if ((o_children2[j].nodeType == 1)&&(o_children2[j].className == "productreel_reel")) 

					{

						o_multireel.reelcollection[o_multireel.reelcollection.length] = o_children2[j];

					}

				}

			}

		}

	}



	// see if reel show index has been set

	if (typeof(o_multireel.reelshowindex) == 'undefined') 

	{

		o_multireel.reelshowindex = 0;

	}





	if ((pickrandom != null) && pickrandom)

	{

		v_increase = Math.floor(Math.random()*400);

		var i = 0;

		

		var o_reelspinnerani = gE(v_reelelementid+"_spinani"+i); 

		

		while (o_reelspinnerani != null) 

		{

		

			o_reelspinnerani.parentNode.style.display = "block";

			

			// f_reel_spin(v_reelelementid+"_spinani"+i,45 - (i*4),10 + (i*7),gEID(o_multireel));

			i++;

			

			o_reelspinnerani = gE(v_reelelementid+"_spinani"+i); 

		}

	



	}





	// determine overall shown item index

	o_multireel.reelshowindex += v_increase;









	// iterate through reelcollection

	for (var i = 0 ; i < o_multireel.reelcollection.length; i++) 

	{

		var o_reel = o_multireel.reelcollection[i];



		// check if reel item has product inventory done

		if (typeof(o_reel.productcollection) == 'undefined') 

		{

			

			o_reel.productcollection = [];

			var o_children = o_reel.childNodes;

			for (var j = 0; j < o_children.length; j++) 

			{

				

				if ((o_children[j].nodeType == 1)&&(o_children[j].className == "productreel_product"))

				{

					o_reel.productcollection[o_reel.productcollection.length] = o_children[j];

				}

			}

			

			// from now on use script to set height

			// o_reel.style.height = o_reel.scrollHeight + "px";

			//o_reel.style.overflow = 'hidden';

//			o_reel.style.width = '242px';



		}

		

		// determine item to be shown:

		var showindex = o_multireel.reelshowindex - (Math.floor(o_multireel.reelshowindex / o_reel.productcollection.length) * o_reel.productcollection.length);



		// do spiffy filter stuff		

		/*

		if ((!pickrandom)&&(o_reel.filters)&&(o_reel.filters[0])) {

			o_reel.filters[0].Apply();

		}

		*/



		for (var j = 0; j < o_reel.productcollection.length; j++) {

			var o_product = o_reel.productcollection[j];



			if (j == showindex) {

				o_product.style["display"] = "block";

				// o_product.style["border"] = "5px solid #ff3300";

				// o_product.style["visibility"] = "visible";

				// tgth = o_product.scrollHeight;

			} else {

				o_product.style["display"] = "none";

				// o_product.style["visibility"] = "hidden";

			}

		}

		



		// f_animate_height(o_reel,tgth);

		

		// do spiffy filter stuff		

		/*

		if ((!pickrandom)&&(o_reel.filters)&&(o_reel.filters[0])) {

			// o_reel.filters[0].Motion = (v_increase > 0) ? 'forward' : 'reverse';

			o_reel.filters[0].Play(duration=0.75);

		}

		*/



		

		

	}

	return false;

}





function f_combination_swappage(o_combelement,v_increase)

{

	// find container of all combinations

	var o_combination_container = o_combelement;

	

	while (o_combination_container.className != "module_item_combination_container")

	{

		o_combination_container = o_combination_container.parentNode;

		if (o_combination_container == null)

		{

			alert('no combination container found');

			return false;

		}

	}



	if (typeof(o_combination_container.combcollection) == 'undefined') {

		o_combination_container.combcollection = [];

		

		var o_combs = o_combination_container.childNodes;

		for (var i = 0; i < o_combs.length; i++) {

			

			if ((o_combs[i].nodeType==1)&&(o_combs[i].className == 'module_body round')) {

				o_combination_container.combcollection[o_combination_container.combcollection.length] = o_combs[i];

				// o_combs[i].style["height"] = o_combs[i].scrollHeight + "px";

			}	

		}

		

		// alert(o_combination_container.combcollection.length + " == o_combination_container.combcollection.length");



		//o_combination_container.style["height"] = o_combination_container.scrollHeight + "px";

		//o_combination_container.style["overflow"] = 'hidden';

		

	}

	



	if (typeof(o_combination_container.combshowindex) == 'undefined') {

		o_combination_container.combshowindex = 0;

	}



	o_combination_container.combshowindex += v_increase;

	

	if (o_combination_container.combshowindex < 0)

	{

		o_combination_container.combshowindex = o_combination_container.combcollection.length -1;

	} 

	else if (o_combination_container.combshowindex >= o_combination_container.combcollection.length)

	{

		o_combination_container.combshowindex = 0;

	}



	// setup spiffy filter stuff		

	if ((o_combination_container.filters)&&(o_combination_container.filters[0])) {

		// o_combination_container.filters[0].Apply();

	}





	// check if height is still auto

	// alert(o_combination_container.curh);



	// var v_theight = o_combination_container.style.height;



	if (typeof(o_combination_container.curh) == 'undefined') {

		// alert( "scrollheight: " + o_combination_container.scrollHeight);

		o_combination_container.curh = o_combination_container.scrollHeight;

//		o_container.style.width = "auto";

//		o_container.style.background = "#ff00ff";

		//o_combination_container.style.height = o_combination_container.scrollHeight + "px";

		//o_combination_container.style.overflow = 'hidden';

	}



	// iterate through combcollection

	var tgth = 200;

	for (var i = 0 ; i < o_combination_container.combcollection.length; i++) 

	{

		var o_comb = o_combination_container.combcollection[i];



		if (i == o_combination_container.combshowindex)

		{

			o_comb.style["visibility"] = "visible";

			o_comb.style["display"] = "block";

			tgth = o_comb.scrollHeight;

		}

		else

		{

			o_comb.style["visibility"] = "hidden";

			o_comb.style["display"] = "none";

		}

	}



	// make height changes less sudden

	

	// f_animate_height(o_combination_container,tgth);

		

	// trigger spiffy filter stuff		

	if ((o_combination_container.filters)&&(o_combination_container.filters[0])) 

	{

		// o_combination_container.filters[0].Play(duration=0.75);

	}



	return false;

}



function f_productsmodule_swappage(v_modulepagecontainerid, v_modulepageidprefix, pagecount, v_increase)

{



	//

	var o_container = gE(v_modulepagecontainerid);



	// previous and next page indices

	var prevModulePageIndex = 0;

	var nextModulePageIndex = 0;



	// get previous

	if (typeof (o_container.modulePageIndex) == 'undefined') {

		prevModulePageIndex = 0;

	} else {

		prevModulePageIndex = o_container.modulePageIndex;

	}



	nextModulePageIndex = prevModulePageIndex + v_increase;

	if (nextModulePageIndex < 0) nextModulePageIndex += pagecount;

	if (nextModulePageIndex >= pagecount) nextModulePageIndex -= pagecount;



	// store currentModulePageIndex for future reference

	o_container.modulePageIndex = nextModulePageIndex;



	// setup spiffy filter stuff

	if ((o_container.filters)&&(o_container.filters[0])) {

		o_container.filters[0].Apply();

	}



	// hide currentpage

	gE(v_modulepageidprefix+prevModulePageIndex).style.display = "none";



	// show currentpage

	gE(v_modulepageidprefix+nextModulePageIndex).style.display = "block";



	// do spiffy filter stuff

	if ((o_container.filters)&&(o_container.filters[0])) {

		o_container.filters[0].Apply();

	}



}





function f_productsmodule_gotopage(v_modulepagecontainerid, v_modulepageidprefix, v_modulelinkidprefix, pageindex, pagecount) 

{



	// 

	var o_container = gE(v_modulepagecontainerid);



	// previous and next page indices

	var prevModulePageIndex = 0;

	var nextModulePageIndex = 0;



	// get previous

	if (typeof (o_container.modulePageIndex) == 'undefined') {

		prevModulePageIndex = 0;

	} else {

		prevModulePageIndex = o_container.modulePageIndex;

	}



	

	// determine next

	if (pageindex < 0) {

		nextModulePageIndex =prevModulePageIndex - 1;

	} else if (pageindex >= pagecount) {

		nextModulePageIndex  = prevModulePageIndex + 1;



	} else {

		nextModulePageIndex = pageindex;

	}







	if (nextModulePageIndex < 0) {

		nextModulePageIndex = 0;

	} else if (nextModulePageIndex >= pagecount) {

		nextModulePageIndex = pagecount - 1;

	} 



	// store currentModulePageIndex for future reference

	o_container.modulePageIndex = nextModulePageIndex;





	// unselect previous page number link

	

	gE(v_modulelinkidprefix + prevModulePageIndex).className = "modulePageNumber"

	

	// select next page number link

	gE(v_modulelinkidprefix + nextModulePageIndex).className = "modulePageNumber_selected";











	







	// disable/enable previous arrow if required

	if (nextModulePageIndex == 0) {

		if (gE(v_modulelinkidprefix + "prev").className != "modulePrevPageNumber_disabled") {

			gE(v_modulelinkidprefix + "prev").className = "modulePrevPageNumber_disabled";

		}

	} else {

		if (gE(v_modulelinkidprefix + "prev").className != "modulePrevPageNumber") {

			gE(v_modulelinkidprefix + "prev").className = "modulePrevPageNumber";

		}

	}

	// disable/enable next arrow if required

	if (nextModulePageIndex == (pagecount-1)) {

		if (gE(v_modulelinkidprefix + "next").className != "moduleNextPageNumber_disabled") {

			gE(v_modulelinkidprefix + "next").className = "moduleNextPageNumber_disabled";

		}

	} else {

		if (gE(v_modulelinkidprefix + "next").className != "moduleNextPageNumber") {

			gE(v_modulelinkidprefix + "next").className = "moduleNextPageNumber";

		}

	}



	// setup spiffy filter stuff		

	if ((o_container.filters)&&(o_container.filters[0])) {

		o_container.filters[0].Apply();

	}



	// alert("style.height:" + o_container.style.height + "\nscrollHeight " + o_container.scrollHeight);



//	if (o_container.style.overflow != 'hidden') {

//		o_container.curh = o_container.scrollHeight;

//		o_container.style.width = "auto";

//		o_container.style.background = "#ff00ff";

//		alert(o_container.scrollHeight);

//		o_container.style.height = o_container.scrollHeight+"px";

//		o_container.style.overflow = 'hidden';

//	}



	// hide currentpage

	gE(v_modulepageidprefix+prevModulePageIndex).style.display = "none";



	// show currentpage

	gE(v_modulepageidprefix+nextModulePageIndex).style.display = "block";



	// make height changes less sudden

//	f_animate_height(v_modulepagecontainerid,o_container.scrollHeight);



	// do spiffy filter stuff		

	if ((o_container.filters)&&(o_container.filters[0])) {

		o_container.filters[0].Apply();

	}	

	

}



function f_recipe_pagecount(v_id) {

	var o_body = gE(v_id + "_body");

	if (o_body == null) {

		return 0;

	}



	// see if reel inventory has been done

	if (typeof(o_body.recipeindex) == 'undefined') 

	{

		// do inventory

		o_body.recipeindex = 0;

		o_body.recipecount = 0;



		while (gE(v_id+"_"+o_body.recipecount)!= null) {

			o_body.recipecount ++;

		}

	} 

	return o_body.recipecount;

}



function f_open_recipe_ingredients(v_id,v_open) 

{

	

	if (f_recipe_pagecount(v_id)) 

	{

		var o_body = gE(v_id + "_body");

		// alert('open ingredients \"'+v_id+"\"");

		for (var i = 0; i < o_body.recipecount; i++) 

		{

			var o_ingredients = gE(v_id+"_"+i+'_ingredients')

			o_ingredients.style.display=v_open?"inline":"none";



			// hide/show open links

			gE(v_id+'_'+i+'_ingredients_text_show').style.display=v_open?"none":"inline";



			// show/hide open links

			gE(v_id+'_'+i+'_ingredients_text_hide').style.display=v_open?"inline":"none";



		}



		// make sure that coded positioning of bottom bar is done ok.		

		// f_page_layout();



		// scroll into view if visible

		if (v_open) {

			gE(v_id+"_"+o_body.recipeindex+'_ingredients').scrollIntoView(false)

		}

	}

	return false;	

}	







function f_open_recipe_preparation(v_id) {

	f_openPopupRemote('/modules_page/recipes/recipe_view_popup.jsp?recipe_id='+v_id,'<div style="height:100px;">De bereidings informatie over het recept wordt geladen</div>','','recipeprep_'+v_id,'noreload;center;frommouse;animate',500)

	return false;

}



function f_recipe_swappage(v_id,v_delta) {





	// do spiffy filter stuff		



	

	// see if reel inventory has been done

	if (f_recipe_pagecount(v_id)) {



		var o_body = gE(v_id + "_body");

	

		if (o_body == null) {

			return false;

		}



		if ((o_body.filters)&&(o_body.filters[0])) {

			o_body.filters[0].Apply();

		}		

		o_page = gE(v_id+"_"+o_body.recipeindex);



	

//	o_body.style.height = o_page.scrollHeight;

		o_page.style.display = "none";





		o_body.recipeindex += Math.round(v_delta);

		while (o_body.recipeindex < 0) {

			o_body.recipeindex += o_body.recipecount;

		}

		while (o_body.recipeindex >= o_body.recipecount) {

			o_body.recipeindex -= o_body.recipecount;

		}



		o_page = gE(v_id+"_"+o_body.recipeindex);

		o_page.style.display = "block";

//	tgth = o_product.scrollHeight;



	// do spiffy filter stuff		

		if ((o_body.filters)&&(o_body.filters[0])) {

			o_body.filters[0].play(duration=0.75);

		}

	}

	return false;

	

}



function f_open_attribute_alllinks(v_id,v_url) {

	f_openPopupRemote(v_url,'<div style="height:100px;"><b>'+v_id+'</b><p style="color:#808080;">Lijst wordt geladen...</p></div>','','subcat_'+v_id,'noreload;center;frommouse;animate',250)

	return false;

}



//function library

//in case this section gets too big we might have to consider

//  runtime page-specific loading of JavaScript code



function submitPasswordForgottenForm()

{

	var v_login = gE('password_forgotten_form_login').value;

	f_openPopupRemote('/process?action=albert.password_forgotten.mail_password&login=' + v_login,'Uw verzoek wordt verwerkt...','','password_forgotten_popup','center')

}



function submitPostalcodeCheckForm()

{

	var pcode = gE('postalcodecheck_form_zipcode');

	f_openPopupRemote('/process?action=albert.check_postalcode&postalcode=' + pcode.value,'Uw postcode wordt gecontroleerd...','','postalcode_check_popup','center',468)

	return false;

}



function checkPromoCode()

{

	var promocode_form = document.getElementById('promocode_form');

	requestAjaxResponse('/process?action=albert.promocode.check&promocode=' + promocode_form.promocode.value, null, null, 'afterCheckPromoCode');

}



function afterCheckPromoCode(o_metadata)

{

	if (o_metadata.trg != null)

	{

		f_openPromocodePopup();

    }

	else if (o_metadata.message != null)

	{

		alert(o_metadata.message);

	}

}







function f_openPromocodePopup() {



	// the windowid of the popup

	var v_wid = null;



	// if popupname is supplied check if already exists

	if (typeof (v_popup_nametoid['actioncode_check_popup']) != 'undefined')

	{

		v_wid = v_popup_nametoid['actioncode_check_popup'];



		if (!f_dhtmldialog_tofront(v_wid)) {

			v_wid = null;

		}

	}



	// if no existing popup should be used

	if (v_wid == null)

	{

		// create popup

		v_wid = f_dhtmldialog_create('De ingevoerde actiecode wordt gecontroleerd...','','center', null, 560, 300);

		v_popup_nametoid['actioncode_check_popup'] = v_wid;

	}

	else

	{

		if (v_width != null) {

			f_dhd_setWidth(v_wid,v_width);

		}

		f_dhtmldialog_get_body(v_wid).innerHTML = 'De ingevoerde actiecode wordt gecontroleerd...';

		f_dhtmldialog_get_caption(v_wid).innerHTML = '';

	}



	requestAjaxResponse('/main/home/promocode_result_ajax.jsp?isDhtmlDialogRequest=true',

			'o_shop_db.distillfromhtml(\''+f_dhtmldialog_get_bodyid(v_wid)+'\');',

			f_dhtmldialog_get_bodyid(v_wid),'f_openPopupRemoteMetaDataProcessor',"popupid="+v_wid);

}





function openFolderWindow()

{

	window.open("/folder/folder-1024/magazine.html", "_blank",

			"location=no,toolbar=no,status=no,left=0,top=0,directories=no,scrollbars=yes,resizable=yes,width=1016,height=681");

}



function displayShoppingListPopup(spinnerId, itemId, cataCode) {

	// get amount

	var o_input = gE("amountinput_"+spinnerId);

	var amount = parseInt(o_input.value);



	f_openPopupRemote('/process?action=albert_noscript.list.add_to_cart_or_list&addtolist=true&selected_item=' + itemId + '|' + amount + '|' + cataCode, 'Uw boodschappenlijst worden geladen...','Producten toevoegen aan boodschappenlijstje','shopping_list_popup','center',468,300,'','addtolistPopup');

}



function displayShoppingListPopupMultipleItems(selectedItemCheckboxesName) {

	var selectedItemCheckboxes = document.getElementsByName(selectedItemCheckboxesName);

	var url = '/process?action=albert_noscript.list.add_to_cart_or_list&addtolist=true';



	var count = 0;

	for (var i = 0; i < selectedItemCheckboxes.length; i++) {

		if (selectedItemCheckboxes[i].checked) {

			url += '&selected_item=' + selectedItemCheckboxes[i].value;

			count++;

		}

	}

		

	if (count > 0) {

		f_openPopupRemote(url, 'Uw boodschappenlijst worden geladen...','Producten toevoegen aan boodschappenlijstje','shopping_list_popup','center',468,300,'','addtolistPopup');

	}

}



function addItemsToShoppingList(selectedItemsName, shoppingListSelectionId, newShoppingListId) {

	var shoppingListId = document.getElementById(shoppingListSelectionId).value;

	var newShoppingList = document.getElementById(newShoppingListId).value;

	var selectedItems = document.getElementsByName(selectedItemsName);

	

	var url = '/process?action=albert.list.add_item&shoppingListId=' + shoppingListId + '&newShoppingList=' + newShoppingList;

	

	for (i = 0; i < selectedItems.length; i++) {

		url += '&selected_item=' + selectedItems[i].value;

	}

	

	requestAjaxResponse(url);

}