Array.prototype.indexOf=function(item,from){
	if(from !=null && from>=length) return -1;
	for(var i=(from!=null? from : 0);i<this.length;i++){
		if(this[i]==item) return i;
	}
	return -1;
};
Array.prototype.indexOfJQ=function($item,from){
	if(from !=null && from>=length) return -1;
	for(var i=(from!=null? from : 0);i<this.length;i++){
		if(this[i].selector==$item.selector && this[i].context==$item.context) return i;
	}
	return -1;
};
Util = {		
	date:{
		parse : function(date) {
			if (date == null)
				return null;
			else if (date instanceof String || date.toLowerCase!=null) {
				var dObj = date.replace(/\D/g, " ").split(" ");
				if(dObj.length==3){
					return new Date(dObj[0], (dObj[1] - 1), dObj[2], 0, 0, 0).getTime();
				}else{
					return new Date(dObj[0], (dObj[1] - 1), dObj[2], dObj[3], dObj[4], dObj[5]).getTime();
				}
			} else if (date instanceof Number || date.toPrecision!=null) {
				return date;
			} else if (date instanceof Date || date.getTime()) {
				return date.getTime();
			}
			//give up
			return null;
		},
		getLabel : function(timeStampMillis) {
			if(timeStampMillis==null) return '';
			var date = new Date(timeStampMillis);
			var days = [ 'Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag' ];
			var months = [ 'januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december' ];
			return days[date.getDay()] + ' ' + date.getDate() + ' '	+ months[date.getMonth()] + ', ' + date.getHours() + ':' + ((date.getMinutes() < 10 ? "0" : "") + date.getMinutes()) + ' uur';
		},
		toJewelLabsString : function(date){
			if(date==null) return '';
			var timeStr = date.toTimeString(); 
			return this.toJewelLabsDateString(date)+'T'+timeStr.substring(0,9)+timeStr.substring(12,15)+':'+timeStr.substring(15,17);
		},
		toJewelLabsDateString : function(date){
			if(date==null) return '';
			return this.getYearStr(date)+'-'+this.getMonthStr(date)+'-'+this.getDayStr(date);
		},
		getYearStr: function(date){
			if(date==null) return '';
			var year = date.getFullYear();
			return ''+year;
		},
		getMonthStr: function(date){
			if(date==null) return '';
			var month = (date.getMonth()+1);
			return ''+(month<10? '0':'')+month;
		},
		getDayStr: function(date){
			if(date==null) return '';
			var day = date.getDate();
			return ''+(day<10? '0':'')+day;
		},
		isValid:function (year,month,day){
			var date = new Date(year,month,day);
			var y=date.getFullYear();
			var m=date.getMonth();
			var d=date.getDate();
			return (y==year && m==month && d==day);
		}
	},
	json:{
		toJSON : function(obj, includeFunctions) {
			var json = '';
			var i = 0;
			for (var key in obj) {
				var val = obj[key];
				if (!(val instanceof Function) || includeFunctions) {
					json += (i++ > 0 ? ',' : '') + '"' + key + '":'
					+ this.toJSONValue(val, includeFunctions);
				}
			}
			return '{' + json + '}';
		},
		toJSONArray : function(array, includeFunctions) {
			var json = '';
			var i = 0;
			for (var index = 0; index < array.length; index++) {
				var val = array[index];
				if (!(val instanceof Function) || includeFunctions)
					json += (i++ > 0 ? ',' : '')
					+ this.toJSONValue(val, includeFunctions);
			}
			return '[' + json + ']';
		},
		toJSONValue : function(val, includeFunctions) {
			if (val == null) {
				return 'null';
			}else{
				var type = typeof val; 
				if(type=='object'){
					if(val instanceof String){
						return '"' + val + '"';
					}else if(val instanceof Number){
						return val;
					}else if(val instanceof Boolean){
						return val;
					}else if(val instanceof Date){
						return 'new Date(' + val.getTime() + ')';
					}else if(val instanceof RegExp){
						return '/' + val.source + '/' + (val.ignoreCase ? 'i' : '')	+ (val.global ? 'g' : '') + (val.multiline ? 'm' : '');
					}else if(val instanceof Array){
						return this.toJSONArray(val, includeFunctions);
					}else{
						return this.toJSON(val, includeFunctions);
					}
				}else if(type=='function'){
					return val;
				}else if(type=='string'){
					return '"' + val + '"';
				}else if(type=='number'){
					return val;
				}else if(type=='boolean'){
					return val;
				}
			}
		}
	},
	cookie: {
		create: function(name,value,days){
			if (days){
				var date = new Date();
				date.setTime(date.getTime()+(days*24*60*60*1000));
				var expires = "; expires="+date.toGMTString();
			}else var expires = "";
			document.cookie = name+"="+value+expires+"; path=/";
		},
		read: function(name){
			var nameEQ = name + "=";
			var ca = document.cookie.split(';');
			for(var i=0;i < ca.length;i++) {
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
			return null;
		},
		erase: function(name){
			this.create(name,"",-1);
		}
	},
	number: {
		format: function(number, decimals, dec_point, thousands_sep) {
		    var n = number, prec = decimals;
		    
		    var toFixedFix = function (n,prec) {
		        var k = Math.pow(10,prec);
		        return (Math.round(n*k)/k).toString();
		    };
		 
		    n = !isFinite(+n) ? 0 : +n;
		    prec = !isFinite(+prec) ? 0 : Math.abs(prec);
		    var sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep;
		    var dec = (typeof dec_point === 'undefined') ? '.' : dec_point;
		 
		    var s = (prec > 0) ? toFixedFix(n, prec) : toFixedFix(Math.round(n), prec); //fix for IE parseFloat(0.55).toFixed(0) = 0;
		 
		    var abs = toFixedFix(Math.abs(n), prec);
		    var _, i;
		 
		    if (abs >= 1000) {
		        _ = abs.split(/\D/);
		        i = _[0].length % 3 || 3;
		 
		        _[0] = s.slice(0,i + (n < 0)) +
		              _[0].slice(i).replace(/(\d{3})/g, sep+'$1');
		        s = _.join(dec);
		    } else {
		        s = s.replace('.', dec);
		    }
		 
		    var decPos = s.indexOf(dec);
		    if (prec >= 1 && decPos !== -1 && (s.length-decPos-1) < prec) {
		        s += new Array(prec-(s.length-decPos-1)).join(0)+'0';
		    }
		    else if (prec >= 1 && decPos === -1) {
		        s += dec+new Array(prec).join(0)+'0';
		    }
		    return s;
		}
	},
	positioning:{
		getScrollXY: function() { 
			var scrOfX = 0, scrOfY = 0; 
			if( typeof( window.pageYOffset ) == 'number' ) { 
				//Netscape compliant
				scrOfY = window.pageYOffset;
				scrOfX = window.pageXOffset;
			} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { 
				//DOM compliant
				scrOfY = document.body.scrollTop; 
				scrOfX = document.body.scrollLeft; 
			} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { 
				//IE6 standards compliant mode
				scrOfY = document.documentElement.scrollTop; 
				scrOfX = document.documentElement.scrollLeft; 
			} 
			return {x:scrOfX, y:scrOfY}; 
		},
		getWindowSize: function() { 
			 var myWidth = 0, myHeight = 0; 
			 if( typeof( window.innerWidth ) == 'number' ) { 
			   //Non-IE 
			   myWidth = window.innerWidth; 
			   myHeight = window.innerHeight; 
			 } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { 
			   //IE 6+ in 'standards compliant mode' 
			   myWidth = document.documentElement.clientWidth; 
			   myHeight = document.documentElement.clientHeight; 
			 } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { 
			   //IE 4 compatible 
			   myWidth = document.body.clientWidth; 
			   myHeight = document.body.clientHeight; 
			 } 
			 return{x:myWidth, y:myHeight};
		},
		center: function($element,$takeSizeFrom){
			this.resize();
			var windowSize = this.getWindowSize(); 
			var scroll = this.getScrollXY();
			var width= ($takeSizeFrom!=null ? $takeSizeFrom.width(): $element.width());
			var height= ($takeSizeFrom!=null ? $takeSizeFrom.height(): $element.height());
			$element.css({ 
				"position": "absolute", 
				"top": windowSize.y/2-height/2 + scroll.y-15,
				"left": windowSize.x/2-width/2 + scroll.x-15
			}); 
		},
		alignTop:function(){
			var $orderingPopup = $('#ticketing_popup');
			var windowSize = this.getWindowSize(); 
			var scroll = this.getScrollXY();
			var width= $orderingPopup.width();
			$orderingPopup.css({ 
				"position": "absolute", 
				"top": scroll.y+100,
				"left": windowSize.x/2-width/2 + scroll.x-15
			}); 
//			$('ticketing_popup').scrollTop(100);
//		    if ($('#ticketing_popup').offset().top + $('#ticketing_popup').height() + 100 > $('.grid').height()){
		},
		resize: function() {
		    // this function checks if the height of the grid is enough to host the popup
		    if ($('#ticketing_popup').offset().top + $('#ticketing_popup').height() + 100 > $('.grid').height()){
			    $('.grid').height($('#ticketing_popup').offset().top + $('#ticketing_popup').height() + 100);
		    }
		}
	},
	country:{
		getId: function(isoCode){ return this.toId[isoCode]; },
		getIso: function(dbId){ return this.toIso[''+dbId]; },
		toId:{'AF':  1,'AL':  2,'DZ':  3,'AS':  4,'AD':  5,'AO':  6,'AI':  7,'AG':  8,'AR':  9,'AM': 10,
			 'AW': 11,'AU': 12,'AT': 13,'AZ': 14,'BS': 15,'BH': 16,'BD': 17,'BB': 18,'BY': 19,'BE': 20,
			 'BZ': 21,'BJ': 22,'BM': 23,'BT': 24,'BO': 25,'BA': 26,'BW': 27,'BR': 28,'BN': 29,'BG': 30,
			 'BF': 31,'BI': 32,'KH': 33,'CM': 34,'CA': 35,'CV': 36,'KY': 37,'CF': 38,'TD': 39,'CL': 40,
			 'CN': 41,'CO': 42,'KM': 43,'CG': 44,'CD': 45,'CK': 46,'CR': 47,'CI': 48,'HR': 49,'CU': 50,
			 'CY': 51,'CZ': 52,'DK': 53,'DJ': 54,'DM': 55,'DO': 56,'EC': 57,'EG': 58,'SV': 59,'GQ': 60,
			 'ER': 61,'EE': 62,'ET': 63,'FK': 64,'FO': 65,'FJ': 66,'FI': 67,'FR': 68,'GF': 69,'PF': 70,
			 'GA': 71,'GM': 72,'GE': 73,'DE': 74,'GH': 75,'GI': 76,'GR': 77,'GL': 78,'GD': 79,'GP': 80,
			 'GU': 81,'GT': 82,'GN': 83,'GW': 84,'GY': 85,'HT': 86,'VA': 87,'HN': 88,'HK': 89,'HU': 90,
			 'IS': 91,'IN': 92,'ID': 93,'IR': 94,'IQ': 95,'IE': 96,'IL': 97,'IT': 98,'JM': 99,'JP':100,
			 'JO':101,'KZ':102,'KE':103,'KI':104,'KP':105,'KR':106,'KW':107,'KG':108,'LA':109,'LV':110,
			 'LB':111,'LS':112,'LR':113,'LY':114,'LI':115,'LT':116,'LU':117,'MO':118,'MK':119,'MG':120,
			 'MW':121,'MY':122,'MV':123,'ML':124,'MT':125,'MH':126,'MQ':127,'MR':128,'MU':129,'MX':130,
			 'FM':131,'MD':132,'MC':133,'MN':134,'MS':135,'MA':136,'MZ':137,'MM':138,'NA':139,'NR':140,
			 'NP':141,'NL':142,'AN':143,'NC':144,'NZ':145,'NI':146,'NE':147,'NG':148,'NU':149,'NF':150,
			 'MP':151,'NO':152,'OM':153,'PK':154,'PW':155,'PA':156,'PG':157,'PY':158,'PE':159,'PH':160,
			 'PN':161,'PL':162,'PT':163,'PR':164,'QA':165,'RE':166,'RO':167,'RU':168,'RW':169,'SH':170,
			 'KN':171,'LC':172,'PM':173,'VC':174,'WS':175,'SM':176,'ST':177,'SA':178,'SN':179,'SC':180,
			 'SL':181,'SG':182,'SK':183,'SI':184,'SB':185,'SO':186,'ZA':187,'ES':188,'LK':189,'SD':190,
			 'SR':191,'SJ':192,'SZ':193,'SE':194,'CH':195,'SY':196,'TW':197,'TJ':198,'TZ':199,'TH':200,
			 'TG':201,'TK':202,'TO':203,'TT':204,'TN':205,'TR':206,'TM':207,'TC':208,'TV':209,'UG':210,
			 'UA':211,'AE':212,'GB':213,'US':214,'UY':215,'UZ':216,'VU':217,'VE':218,'VN':219,'VG':220,
			 'VI':221,'WF':222,'EH':223,'YE':224,'ZM':225,'ZW':226},
		toIso:{'1'  :'AF','2'  :'AL','3'  :'DZ','4'  :'AS','5'  :'AD','6'  :'AO','7'  :'AI','8'  :'AG','9'  :'AR','10' :'AM',
			'11' :'AW','12' :'AU','13' :'AT','14' :'AZ','15' :'BS','16' :'BH','17' :'BD','18' :'BB','19' :'BY','20' :'BE',
			'21' :'BZ','22' :'BJ','23' :'BM','24' :'BT','25' :'BO','26' :'BA','27' :'BW','28' :'BR','29' :'BN','30' :'BG',
			'31' :'BF','32' :'BI','33' :'KH','34' :'CM','35' :'CA','36' :'CV','37' :'KY','38' :'CF','39' :'TD','40' :'CL',
			'41' :'CN','42' :'CO','43' :'KM','44' :'CG','45' :'CD','46' :'CK','47' :'CR','48' :'CI','49' :'HR','50' :'CU',
			'51' :'CY','52' :'CZ','53' :'DK','54' :'DJ','55' :'DM','56' :'DO','57' :'EC','58' :'EG','59' :'SV','60' :'GQ',
			'61' :'ER','62' :'EE','63' :'ET','64' :'FK','65' :'FO','66' :'FJ','67' :'FI','68' :'FR','69' :'GF','70' :'PF',
			'71' :'GA','72' :'GM','73' :'GE','74' :'DE','75' :'GH','76' :'GI','77' :'GR','78' :'GL','79' :'GD','80' :'GP',
			'81' :'GU','82' :'GT','83' :'GN','84' :'GW','85' :'GY','86' :'HT','87' :'VA','88' :'HN','89' :'HK','90' :'HU',
			'91' :'IS','92' :'IN','93' :'ID','94' :'IR','95' :'IQ','96' :'IE','97' :'IL','98' :'IT','99' :'JM','100':'JP',
			'101':'JO','102':'KZ','103':'KE','104':'KI','105':'KP','106':'KR','107':'KW','108':'KG','109':'LA','110':'LV',
			'111':'LB','112':'LS','113':'LR','114':'LY','115':'LI','116':'LT','117':'LU','118':'MO','119':'MK','120':'MG',
			'121':'MW','122':'MY','123':'MV','124':'ML','125':'MT','126':'MH','127':'MQ','128':'MR','129':'MU','130':'MX',
			'131':'FM','132':'MD','133':'MC','134':'MN','135':'MS','136':'MA','137':'MZ','138':'MM','139':'NA','140':'NR',
			'141':'NP','142':'NL','143':'AN','144':'NC','145':'NZ','146':'NI','147':'NE','148':'NG','149':'NU','150':'NF',
			'151':'MP','152':'NO','153':'OM','154':'PK','155':'PW','156':'PA','157':'PG','158':'PY','159':'PE','160':'PH',
			'161':'PN','162':'PL','163':'PT','164':'PR','165':'QA','166':'RE','167':'RO','168':'RU','169':'RW','170':'SH',
			'171':'KN','172':'LC','173':'PM','174':'VC','175':'WS','176':'SM','177':'ST','178':'SA','179':'SN','180':'SC',
			'181':'SL','182':'SG','183':'SK','184':'SI','185':'SB','186':'SO','187':'ZA','188':'ES','189':'LK','190':'SD',
			'191':'SR','192':'SJ','193':'SZ','194':'SE','195':'CH','196':'SY','197':'TW','198':'TJ','199':'TZ','200':'TH',
			'201':'TG','202':'TK','203':'TO','204':'TT','205':'TN','206':'TR','207':'TM','208':'TC','209':'TV','210':'UG',
			'211':'UA','212':'AE','213':'GB','214':'US','215':'UY','216':'UZ','217':'VU','218':'VE','219':'VN','220':'VG',
			'221':'VI','222':'WF','223':'EH','224':'YE','225':'ZM','ZW':'226'}    
	}
};

MCE={
	TriggerManager:{
		TRIG_LOGGED_IN: 'mc.session.logged_in',
		TRIG_LOGGED_OUT: 'mc.session.logged_out',
		TRIG_ANONYMOUS_CREATED: 'mc.session.anonymous_created',
		TRIG_CUSTOMER_CHANGED: 'mc.session.customer_changed',
		TRIG_PASSWORD_CHANGED: 'mc.session.password_changed',
		handlers : {},
		bind: function($set,eventType,data,handler) {
			if(this.handlers[eventType]==null) this.handlers[eventType] = [ ];
			for(var i=0;i<$set.size();i++){
				$elem = $set.eq(i);
				if(this.handlers[eventType].indexOfJQ($elem)==-1) this.handlers[eventType].push($elem);
			}
			return $set.bind(eventType,data,handler);
		},
		unbind: function($set,eventType,listener) {
			return $set.unbind(eventType,listener);
		},
		trigger: function(eventType,data){
			if(this.handlers[eventType]!=null){
				for(var i=0;i<this.handlers[eventType].length;i++){
					this.handlers[eventType][i].trigger(eventType,data);
				}
			}
		}
	},	
	JewelLabs:{
		login: function(credentialsMap,anonymousCustomerId,succesCallback,noSuccesCallback,errorCallback,callbackContext){
			var url = 'login.xql?call=login&'+this.serializeMap(credentialsMap)+(anonymousCustomerId!=null ? ('&anon_customer_id='+anonymousCustomerId) : '');
			this.fireRequest(url,'customer',succesCallback,noSuccesCallback,errorCallback,callbackContext);
		},
		logout: function(succesCallback,noSuccesCallback,errorCallback,callbackContext){
			var url = 'login.xql?call=logout';
			this.fireRequest(url,'message',succesCallback,noSuccesCallback,errorCallback,callbackContext);
		},
		createAnonymousCustomer: function(succesCallback,noSuccesCallback,errorCallback,callbackContext){
			var url = 'login.xql?call=anonymous';
			this.fireRequest(url,'customer',succesCallback,noSuccesCallback,errorCallback,callbackContext);
		},
		insertCustomer: function(customerMap,succesCallback,noSuccesCallback,errorCallback,callbackContext){
			var interests = (customerMap.interests!=null && customerMap.interests.length>0 ? customerMap.interests : '0');
			delete customerMap.interests;
			var url = 'login.xql?call=new&interests='+interests+'&data='+encodeURIComponent(this.serializeCustomerToXML(customerMap));
			this.fireRequest(url,'customer',succesCallback,noSuccesCallback,errorCallback,callbackContext);
		},
		updateCustomer: function(customerId,customerMap,succesCallback,noSuccesCallback,errorCallback,callbackContext){
			var interests = (customerMap.interests!=null && customerMap.interests.length>0 ? customerMap.interests : '0');
			delete customerMap.interests;
			var url = 'login.xql?call=update&customer_id='+customerId+'&interests='+interests+'&data='+encodeURIComponent(this.serializeCustomerToXML(customerMap));
			this.fireRequest(url,'customer',succesCallback,noSuccesCallback,errorCallback,callbackContext);
		},
		getCustomerInterests: function(customerId,succesCallback,noSuccesCallback,errorCallback,callbackContext){
			var url = 'login.xql?call=get_interests&customer_id='+customerId+'&data='+encodeURIComponent(this.serializeCustomerToXML(customerMap));
			this.fireRequest(url,'crm_interests',succesCallback,noSuccesCallback,errorCallback,callbackContext);
		},
		setCustomerInterests: function(customerId,interests,succesCallback,noSuccesCallback,errorCallback,callbackContext){
			var url = 'login.xql?call=set_interests&customer_id='+customerId+'&interests='+encodeURIComponent(interests);
			this.fireRequest(url,'crm_interests',succesCallback,noSuccesCallback,errorCallback,callbackContext);
		},
		requestNewPassword: function(email,password,customerId,succesCallback,noSuccesCallback,errorCallback,callbackContext){
			var url = '';
			if(customerId!=null){
				url = 'login.xql?call=password_in&customer_id='+customerId+(password!=null && password.length>0 ? '&password='+password:'');
			}else{
				url = 'login.xql?call=password_out&email='+email;
			}
			this.fireRequest(url,'message',succesCallback,noSuccesCallback,errorCallback,callbackContext);
		},
		loadInvoice : function(customerId, succesCallback, noSuccesCallback, errorCallback, callbackContext) {
			var url = '../tickets/ticketing.xql?call=invoice&customer='+customerId;
			this.fireRequest(url,'invoice',succesCallback,noSuccesCallback,errorCallback,callbackContext);
		},
		loadBadgeTypes : function(customerId, itemId,itemType, succesCallback,noSuccesCallback, errorCallback, callbackContext) {
			url = '../tickets/ticketing.xql?call=badges&customer='+customerId+ '&type='+itemType+'&item='+itemId;
			this.fireRequest(url,'badge-types',succesCallback,noSuccesCallback,errorCallback,callbackContext);
		},
		loadItem : function(itemId,itemType, succesCallback, noSuccesCallback, errorCallback, callbackContext) {
			var url = '../tickets/ticketing.xql?call=item&type='+itemType+'&item='+itemId;
			this.fireRequest(url,itemType,succesCallback,noSuccesCallback,errorCallback,callbackContext);
		},
		addItemInstance : function(customerId, itemId, itemType, badgeTypeId, succesCallback, noSuccesCallback, errorCallback, callbackContext) {
			var url = '../tickets/ticketing.xql?call=add&customer='+customerId+'&type='+itemType+'&item='+itemId+'&badge_type='+badgeTypeId;
			this.fireRequest(url,'invoice',succesCallback,noSuccesCallback,errorCallback,callbackContext);
		},
		removeItemInstance : function(customerId, itemInstanceId,itemType, succesCallback, noSuccesCallback, errorCallback, callbackContext) {
			var url = '../tickets/ticketing.xql?call=remove&customer='+customerId+'&rtype='+itemType+'&instance='+itemInstanceId;
			this.fireRequest(url,'invoice',succesCallback,noSuccesCallback,errorCallback,callbackContext);
		},
		loadPaymentTypes : function(succesCallback, noSuccesCallback, errorCallback, callbackContext) {
			var url = '../tickets/ticketing.xql?call=payment-types';
			this.fireRequest(url,'payment-types',succesCallback,noSuccesCallback,errorCallback,callbackContext);
		},

		serializeMap:function(map){
			var serializedMap = '';
			for(var key in map){
				serializedMap+=(serializedMap.length>0 ? '&' : '')+encodeURIComponent(key)+'='+encodeURIComponent(map[key]);
			}
			return serializedMap;
		},
		customerFields: ['id','is_anonymous','email_address','first_name','last_name','date_of_birth','address_1','address_number',
		                 'zip_code','city','country_id','day_phone','mobile_phone','gender','is_send_notifications'],
		serializeCustomerToXML:function(customerMap){
			var data = '<customer>'+
			this.getXMLField(customerMap,'login',null,'email_address')+
			this.getXMLField(customerMap,'password')+
			this.getXMLField(customerMap,'password_confirmation',null,'password')+
			this.getXMLField(customerMap,'email_address')+
			this.getXMLField(customerMap,'email_address_confirmation',null,'email_address')+
			this.getXMLField(customerMap,'first_name')+
			this.getXMLField(customerMap,'last_name')+
			this.getXMLField(customerMap,'date_of_birth','date')+
			this.getXMLField(customerMap,'address_1')+
			this.getXMLField(customerMap,'address_number')+
			this.getXMLField(customerMap,'zip_code')+
			this.getXMLField(customerMap,'city')+
			this.getXMLField(customerMap,'country_id','integer')+
			this.getXMLField(customerMap,'day_phone')+
			this.getXMLField(customerMap,'gender')+
			this.getXMLField(customerMap,'is_send_notifications','boolean')+
			'</customer>';
			return data;
		},
		getXMLField: function(map,fieldName, type, alternativeKey,useNullValues){
			var val = map[(alternativeKey==null?fieldName:alternativeKey)];
			if(val!=null){
				return '<'+fieldName+(type!=null ? ' type="'+type+'"' : '')+'>'+val+'</'+fieldName+'>';
			}else{
				return (useNullValues!=null && useNullValues==true ? '<'+fieldName+(type!=null ? ' type="'+type+'"' : '')+' nil="true"/>' : '');
			}
		},
		fireRequest: function(url,responseName,succesCallback,noSuccesCallback,errorCallback,callbackContext){
			JewelLabs = this;
			$.ajax({
				url: url,
				dataType: 'json',
				async: true,
				success: function(json) {
					
					if(typeof(json) !== 'undefined' && typeof(json.error) !== 'undefined' && json.error && json.error!=null){
						if(noSuccesCallback!=null) noSuccesCallback.call((callbackContext!=null ? callbackContext : window),json.error);
					
					}else{
						eval('var response=json["'+responseName+'"];');
						if(succesCallback!=null) succesCallback.call((callbackContext!=null ? callbackContext : window),response);
					}
				},
				error:function() {
					if(errorCallback!=null) errorCallback.call((callbackContext!=null ? callbackContext : window));
				}
			});
		}
	}
};
