﻿		/* -- Dutch Image JavaScript Library */		
		
		
		/*--------------------------------------------------------------------------------
		set Cookie
		----------------------------------------------------------------------------------
		name - name of the cookie
		value - value of the cookie
		
		[expires] - expiration date of the cookie
		  (defaults to end of current session)
		  
		[path] - path for which the cookie is valid
		  (defaults to path of calling document)
		  
		[domain] - domain for which the cookie is valid
		  (defaults to domain of calling document)
		  
		[secure] - Boolean value indicating if the cookie transmission requires
		  a secure transmission
		  
		* an argument defaults when it is assigned null as a placeholder
		* a null placeholder is not required for trailing omitted arguments
		--------------------------------------------------------------------------------*/
		function setSCCookie(name, value, expires, path, domain, secure) {
			
			var curCookie = name + "=" + escape(value) +
			((expires) ? "; expires=" + expires.toGMTString() : "") +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			((secure) ? "; secure" : "");
			document.cookie = curCookie;
		}
		
		
		
		/*--------------------------------------------------------------------------------
		get Cookie
		----------------------------------------------------------------------------------
		name - name of the desired cookie return string containing value of specified
		cookie or null if cookie does not exist
		--------------------------------------------------------------------------------*/
		function getSCCookie(name) {
		  var dc = document.cookie;
		  
		  var prefix = name + "=";
		  var begin = dc.indexOf("; " + prefix);
		  
		  if (begin == -1) {
		    begin = dc.indexOf(prefix);
		    if (begin != 0) return null;
		    
		  } else
		    begin += 2;
		  var end = document.cookie.indexOf(";", begin);
		  if (end == -1)
		    end = dc.length;
		  return unescape(dc.substring(begin + prefix.length, end));
		}
		
		
		
		/*--------------------------------------------------------------------------------
		delete Cookie
		----------------------------------------------------------------------------------
		name - name of the cookie
		[path] - path of the cookie (must be same as path used to create cookie)
		[domain] - domain of the cookie (must be same as domain used to create cookie) path
		and domain default if assigned null or omitted if no explicit argument proceeds
		--------------------------------------------------------------------------------*/
		function deleteSCCookie(name, path, domain) {
		  if (getSCCookie(name)) {
		    document.cookie = name + "=" + 
		    	((path) ? "; path=" + path : "") + 
		    	((domain) ? "; domain=" + domain : "") + 
		    	"; expires=Thu, 01-Jan-70 00:00:01 GMT";
		  }
		}
		
		
		
		/*--------------------------------------------------------------------------------
		één of andere functie voor Navigator op de mac .. ach .. ;)
		--------------------------------------------------------------------------------*/
		// date - any instance of the Date object
		// * hand all instances of the Date object to this function for "repairs"
		
		function fixDate(date) {
		  var base = new Date(0);
		  var skew = base.getTime();
		  if (skew > 0)
		    date.setTime(date.getTime() - skew);
		}
		
		
		/*--------------------------------------------------------------------------------
		?
		--------------------------------------------------------------------------------*/
		function chQTT(cID,qtt2) {
			
			/*--------------------------------------------------------------------------------
			Part A // COOKIE INLEZEN
			--------------------------------------------------------------------------------*/
			//create an instance of the Date object
			var now = new Date();
			
			//fix the bug in Navigator 2.0, Macintosh
			fixDate(now);
			
			/*--------------------------------------------------------------------------------
			cookie expires in one year (actually, 365 days)
			365 days in a year
			24 hours in a day
			60 minutes in an hour
			60 seconds in a minute
			1000 milliseconds in a second
			--------------------------------------------------------------------------------*/
			now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
			var cookies = getSCCookie('scart');
			
			/*--------------------------------------------------------------------------------
			Part A // EINDE
			--------------------------------------------------------------------------------*/
			/*--------------------------------------------------------------------------------
			Part B // VERVOLG
			--------------------------------------------------------------------------------*/
			//cookies omzetten naar array
			cookie_array = cookies.split("+");
			
			//cookies resetten
			cookies = '';
			
			//voor elke cookie
			for (key in cookie_array) {
				
				var obj = cookie_array[key].substr(0,4);
				var qtt = cookie_array[key].substr(4);
				
				//alle cookies verzamelen
				if (obj == cID) {
					//quantity wijzigen
					cookies = cookies + obj + qtt2 + '+';
				} else if (obj != '') {
					cookies = cookies + obj + qtt + '+';
				}
			}
			
			//cookies bakken
			setSCCookie('scart', cookies, now, '/');
			
			//reload shoppingcart
			//window.location.reload();
		}
		
		
		
		/*--------------------------------------------------------------------------------
		methode om een image aan de lightbox toe te voegen
		--------------------------------------------------------------------------------*/
		function add2Cart(cID) {
			
			switch (cID) {
				case 'SH11':
				var english = confirm('Would you like to order the English edition?');
			
				if (english == false) {
					var dutch = confirm('The Dutch edition perhaps?');
					
					if (dutch == true) {
						cID = 'SH12';
					} else { return; }
				}
				break;
				
				
				case 'VN03':
				var english = confirm('Would you like to order the English edition?');
			
				if (english == false) {
					var dutch = confirm('The Dutch edition perhaps?');
					
					if (dutch == true) {
						cID = 'VN04';
					} else { return; }
				} 
				break;
				
				
				case 'RG09':
				var english = confirm('Would you like to order the English edition?');
			
				if (english == false) {
					var dutch = confirm('The Dutch edition perhaps?');
					
					if (dutch == true) {
						cID = 'RG10';
					} else { return; }
				}
				break;
				
				
				case 'HB13':
				var english = confirm('Would you like to order the English edition?');
			
				if (english == false) {
					var dutch = confirm('The Dutch edition perhaps?');
					
					if (dutch == true) {
						cID = 'HB14';
					} else { return; }
				}
				break;
				
				
				case 'KW15':
				var english = confirm('Would you like to order the English edition?');
			
				if (english == false) {
					var dutch = confirm('The Dutch edition perhaps?');
					
					if (dutch == true) {
						cID = 'KW16';
					} else { return; }
				}
				break;
				
				
				//bestellingen die van buitenaf komen (via dutchimage)
				case 'KW15-ext':
				cID = 'KW15';
				break;
			}
			
			
			/*--------------------------------------------------------------------------------
			Part A // COOKIE INLEZEN
			--------------------------------------------------------------------------------*/
			//create an instance of the Date object
			var now = new Date();
			
			//fix the bug in Navigator 2.0, Macintosh
			fixDate(now);
			
			/*--------------------------------------------------------------------------------
			cookie expires in one year (actually, 365 days)
			365 days in a year
			24 hours in a day
			60 minutes in an hour
			60 seconds in a minute
			1000 milliseconds in a second
			--------------------------------------------------------------------------------*/
			now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
			var cookies = getSCCookie('scart');
			
			/*--------------------------------------------------------------------------------
			Part A // EINDE
			--------------------------------------------------------------------------------*/
			/*--------------------------------------------------------------------------------
			Part B // VERVOLG
			--------------------------------------------------------------------------------*/
			//var presetten
			var present = false;
			
			//geen cookies aanwezig?
			if (!cookies) {
				
				//eerste cookies bakken
				cookies = cID + '1+';
			  	
			} else {
				
				//cookies omzetten naar array
				cookie_array = cookies.split("+");
				
				//cookies resetten
				cookies = '';
				
				//voor elke cookie
				for (key in cookie_array) {
					
					var obj = cookie_array[key].substr(0,4);
					var qtt = cookie_array[key].substr(4);
					
					//ééntje toevoegen
					if (obj == cID) {
						
						//quantity wijzigen
						cookies = cookies + obj + (parseInt(qtt)+1) + '+';
						
						//marker
						present = true;
						
					//aantallen laten voor wat het is
					} else if (obj != '') {
						cookies = cookies + obj + qtt + '+';
					}
				}
				
				
				//geen cookie  aanwezig?
				if (!present) {
					
					//cookie toevoegen
					cookies = cookies + cID + '1+';
					
					//melding is toegevoegd
					
				} else {
					
					//melding is (al) toegevoegd
				}
			}
			
			//nieuwe cookies bakken
			setSCCookie('scart', cookies, now, '/');
			
			//toon shoppingcart
			window.location.href = '../order/order_shoppingcart.php';
		}
		
		
		
		/*--------------------------------------------------------------------------------
		methode om een image uit de lighbox te verwijderen
		--------------------------------------------------------------------------------*/
		function removeFromCart (cID) {
			
			/*--------------------------------------------------------------------------------
			Part A // COOKIE INLEZEN
			--------------------------------------------------------------------------------*/
			//create an instance of the Date object
			var now = new Date();
			
			//fix the bug in Navigator 2.0, Macintosh
			fixDate(now);
			
			/*--------------------------------------------------------------------------------
			cookie expires in one year (actually, 365 days)
			365 days in a year
			24 hours in a day
			60 minutes in an hour
			60 seconds in a minute
			1000 milliseconds in a second
			--------------------------------------------------------------------------------*/
			now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
			var cookies = getSCCookie('scart');
			
			/*--------------------------------------------------------------------------------
			Part A // EINDE
			--------------------------------------------------------------------------------*/
			/*--------------------------------------------------------------------------------
			Part B // VERVOLG
			--------------------------------------------------------------------------------*/
			//cookies omzetten naar array
			cookie_array = cookies.split("+");
			
			//cookies resetten
			cookies = '';
			
			//voor elke cookie
			for (key in cookie_array) {
				
				var obj = cookie_array[key].substr(0,4);
				var qtt = cookie_array[key].substr(4);
				
				//alleen benodigde cookies verzamelen
				if (obj != cID && obj != '') {
					cookies = cookies + obj + qtt + '+';
				}
			}
			
			//cookies bakken
			setSCCookie('scart', cookies, now, '/');
			
			//reload shoppingcart
			window.location.reload();
		}
		
		
		
		/*--------------------------------------------------------------------------------
		methode om de lightbox te legen
		--------------------------------------------------------------------------------*/
		function emptyLB () {
			/*
			//zekor weten?
			var pleasedo = confirm('Are you sure you want to empty your shopping bag?');
			
			if (pleasedo == true) {
				
				deleteCookie('scart');
				document.location = 'lightbox.fwx';
				
				//info voor popup
				w = window.outerWidth;
				h = window.outerHeight;
				
				var popW = 400, popH = 100;
				var leftPos = this.window.screenX + ((w - popW) / 2);
				var topPos  = this.window.screenY + ((h - popH) / 2);
				
				//melding shopping bag is leeg
				window.open('prompts/SB_emptied.html','SB_Prompt','width='+popW+',height='+popH+',screenY='+topPos+',screenX='+leftPos+',scrollbars=no,status=no');
			}*/
		}
		
		
		