function addPoses(posID_arr){
	for(var i in posID_arr){
		addPos('pos'+posID_arr[i]);
	}
}

function saveLegendPiece(oldID, saveID, catUniqueName){
	// get all legend elements for this search, and rename them to the new name
	var currentLegendItems_arr = getElementsByClassName('legend'+oldID, 'DIV', document.body);
	for(var i=0;i<currentLegendItems_arr.length;i++){
		removeClassName(currentLegendItems_arr[i], 'legend'+oldID);
		addClassName(currentLegendItems_arr[i], 'legend'+saveID);
	}
	
	document.getElementById('legend'+oldID).id = 'legend'+saveID;

	// show the delete link for the cat
	document.getElementById('delcatlink'+catUniqueName).style.display = 'block';
	document.getElementById('delcatlink'+catUniqueName).id = 'delcatlink'+saveID;

	// change name etc. for the catUniqueName
	var tmp = activeLegendItems_arr[catUniqueName];
	activeLegendItems_arr[saveID] = {'color':tmp.color, 'descr':tmp.descr, 'catUniqueName':saveID, 'saved':true};
	delete activeLegendItems_arr[catUniqueName];
}

function rememberAllSelections(){
	for(var w in highlighted_arr){
		rememberSel(w.substr(w.length-36));
	}
	// now remove save-link
	showHideSaveCatLink();
}

function rememberSel(mainCatID){
	var txtSrchFld = document.getElementById('Y'+mainCatID);
	var selSrchFld = document.getElementById('X'+mainCatID);
	
	if(txtSrchFld && highlighted_arr['search'+mainCatID] != null){
		// add the highlighted poses
		addPoses(highlighted_arr['search'+mainCatID]);

		// remember the legend piece
		// to do this, we copy the current active-legend arr to a new arr with the ID of serached cat, or the searched text
		var saveID = 'srch' + txtSrchFld.value;
		var oldID = 'search' + mainCatID;
		
		// copy the temp legend for the search to a new one which will remain
		saveLegendPiece(oldID, saveID, 'search' + mainCatID);
		
		// reset the field
		txtSrchFld.value = '';
		txtSrchFld.onblur();
		
		// reset the highlights
		delete highlighted_arr['search'+mainCatID];
	}
	
	if(highlighted_arr[selSrchFld.id] != null){
		// add the highlighted poses
		addPoses(highlighted_arr[selSrchFld.id]);

		// remember the legend piece
		// to do this, we copy the current active-legend arr to a new arr with the ID of serached cat, or the searched text
		var saveID = selSrchFld.options[selSrchFld.selectedIndex].value;
		var oldID = 'X'+mainCatID;
		
		// copy the temp legend for the search to a new one which will remain
		saveLegendPiece(oldID, saveID, oldID);
		
		// reset the field
		selSrchFld.selectedIndex = 0;
		// reset the highlights
		delete highlighted_arr[selSrchFld.id];
	}
}

function showHideSaveCatLink(){
	for(var i in highlighted_arr){
		document.getElementById('saveallbutton').disabled = false;
		return;
	};
	document.getElementById('saveallbutton').disabled = true;
}

var tmouts_arr = [];
function searchText(text, mainCatID, donow){
	var srchArr = categoriesSearchData_arr[mainCatID];
	var foundIDs_arr = [];
		
	if(tmouts_arr[mainCatID])
		clearTimeout(tmouts_arr[mainCatID]);
	if(!donow){
		tmouts_arr[mainCatID] = setTimeout("searchText('"+text.replace(/([\\\'])/i, '\$1')+"','"+mainCatID+"',true)", 400);
		return;
	}
	
	text=text.toLowerCase();
	text=text.replace(/(^ +| +$)/g, "");
	
	// show/hide 
	// min. 4 lang
	if(text.length < 4){
		showPositions(foundIDs_arr, 'search'+mainCatID, mainCatID, 'Text \'<em>'+text+'<\/em>\' too short (min. 4 characters)');
	} else {
		for(var i in srchArr){
			if(srchArr[i][1].indexOf(text) > -1){
				foundIDs_arr.push(srchArr[i][0]);
			}
		}
		showPositions(foundIDs_arr, 'search'+mainCatID, mainCatID, categoriesSearchData_arr[mainCatID][0][0] + ': search results for <em>'+text+'<\/em>');
	}
	
	// show or hide the link to save the search
	showHideSaveCatLink();
}

var highlighted_arr = new Array();

function showPositionsByCategory(catid, catUniqueName, mainCatID){
	var removeOnly = (catid && catid.length) ? false:true;
	var catid_arr = catid ? new Array(catid) : new Array();
	
	var mainCatText = categoriesSearchData_arr[mainCatID][0][0];
	var legendDescription = (mainCatText=='Extra search options'?'':mainCatText + ': <em>')  + (rel_arr[catid] ? rel_arr[catid][0] : 'no results') + '<\/em>';
	showPositions(catid_arr, catUniqueName, mainCatID, legendDescription, removeOnly);

	// show or hide the link to save the search
	showHideSaveCatLink();
}

function showPositions(catID_arr, catUniqueName, mainCatID, legendDescription, removeOnly){
	var removeOnly = (removeOnly==null)?false:removeOnly;
	var legendData_obj = initLegend(catUniqueName, legendDescription);
	var allHighlightedPoses_arr = new Array();
	var sliced_arr;

	// previous choice must become un-highlighted
	if(highlighted_arr[catUniqueName] != null){
		unHighlight(highlighted_arr[catUniqueName]);
		delete highlighted_arr[catUniqueName];
	}
	
	// highlight the pos'es if available
	for(var i in catID_arr){
		if(rel_arr[catID_arr[i]] != null && rel_arr[catID_arr[i]].length > 1){
			sliced_arr = rel_arr[catID_arr[i]].slice(1);
			// ontdubbelen: er zijn nogal wat dubbelen, en dan gaat et fouwt
			var newPoses_arr = [];
			for(var s in sliced_arr){
				if(allHighlightedPoses_arr.join('|').indexOf(sliced_arr[s])==-1){
					newPoses_arr[newPoses_arr.length] = sliced_arr[s];
				}
			}
			allHighlightedPoses_arr = allHighlightedPoses_arr.concat(newPoses_arr);
			highlight(newPoses_arr);
		}
	}
	
	if(allHighlightedPoses_arr.length || !removeOnly){
		highlighted_arr[catUniqueName] = allHighlightedPoses_arr;
		// now set legend color into highlighted thingies
		setLegend(allHighlightedPoses_arr, legendData_obj);
	} else if(removeOnly) {
		removeLegend(catUniqueName);
	}
}


var origcolors_arr = '#330000,#660000,#990000,#CC0000,#FF0000,#000033,#330033,#660033,#990033,#CC0033,#FF0033,#000066,#330066,#660066,#990066,#CC0066,#FF0066,#000099,#330099,#660099,#990099,#CC0099,#FF0099,#0000CC,#3300CC,#6600CC,#9900CC,#CC00CC,#FF00CC,#0000FF,#3300FF,#6600FF,#9900FF,#CC00FF,#FF00FF,#003300,#333300,#663300,#993300,#CC3300,#FF3300,#003333,#333333,#663333,#993333,#CC3333,#FF3333,#003366,#333366,#663366,#993366,#CC3366,#FF3366,#003399,#333399,#663399,#993399,#CC3399,#FF3399,#0033CC,#3333CC,#6633CC,#9933CC,#CC33CC,#FF33CC,#0033FF,#3333FF,#6633FF,#9933FF,#CC33FF,#FF33FF,#006600,#336600,#666600,#996600,#CC6600,#FF6600,#006633,#336633,#666633,#996633,#CC6633,#FF6633,#006666,#336666,#666666,#996666,#CC6666,#FF6666,#006699,#336699,#666699,#996699,#CC6699,#FF6699,#0066CC,#3366CC,#6666CC,#9966CC,#CC66CC,#FF66CC,#0066FF,#3366FF,#6666FF,#9966FF,#CC66FF,#FF66FF,#009900,#339900,#669900,#777900,#CC9900,#FF9900,#009933,#339933,#669933,#777933,#CC9933,#FF9933,#009966,#339966,#669966,#777966,#CC9966,#FF9966,#007779,#337779,#667779,#777777,#CC7779,#FF7779,#0099CC,#3399CC,#6699CC,#7779CC,#CC99CC,#FF99CC,#0099FF,#3399FF,#6699FF,#7779FF,#CC99FF,#FF99FF,#00CC00,#33CC00,#66CC00,#99CC00,#CCCC00,#FFCC00,#00CC33,#33CC33,#66CC33,#99CC33,#CCCC33,#FFCC33,#00CC66,#33CC66,#66CC66,#99CC66,#CCCC66,#FFCC66,#00CC99,#33CC99,#66CC99,#99CC99,#CCCC99,#FFCC99,#00CCCC,#33CCCC,#66CCCC,#99CCCC,#CCCCCC,#FFCCCC,#00CCFF,#33CCFF,#66CCFF,#99CCFF,#CCCCFF,#FFCCFF,#00FF00,#33FF00,#66FF00,#99FF00,#CCFF00,#FFFF00,#00FF33,#33FF33,#66FF33,#99FF33,#CCFF33,#FFFF33,#00FF66,#33FF66,#66FF66,#99FF66,#CCFF66,#FFFF66,#00FF99,#33FF99,#66FF99,#99FF99,#CCFF99,#FFFF99,#00FFCC,#33FFCC,#66FFCC,#99FFCC,#CCFFCC,#FFFFCC,#00FFFF,#33FFFF,#66FFFF,#99FFFF,#CCFFFF'.split(',');
var unusedcolors_arr = origcolors_arr.slice(0);
function getNextColor(){
	if(unusedcolors_arr.length < 2)
		unusedcolors_arr = origcolors_arr.slice(0);
	unusedcolors_arr.shift();
	return unusedcolors_arr.shift();
}
function setNextColor(clr){
	unusedcolors_arr.unshift(clr);
}


// this arr holds id's of all remembered search options
var activeLegendItems_arr = new Array();
function removeLegend(catUniqueName){
	if(activeLegendItems_arr[catUniqueName]){
		var legendData_obj = activeLegendItems_arr[catUniqueName];
		var currentLegendItems_arr = getElementsByClassName('legend'+catUniqueName, 'DIV');
		for(var i=0;i<currentLegendItems_arr.length;i++){
			removeEl(currentLegendItems_arr[i]);
		}
		// return color to array
		setNextColor(legendData_obj.color);
		// reset to nothing
		delete activeLegendItems_arr[catUniqueName];
	}
}

function initLegend(catUniqueName, legendDescription, save){
	var save = save==null?false:save;
	// if cat was not yet saved/available, delete everything for this mainCat (the temp. showed search)
	if(!activeLegendItems_arr[catUniqueName] || activeLegendItems_arr[catUniqueName]==null || !activeLegendItems_arr[catUniqueName].saved){
		// make sure we delete all legend waste
		removeLegend(catUniqueName);

		// get new color for this legend thing, and put it int he arr
		var legendColor_str = getNextColor();
		var legendData_obj = {'color':legendColor_str, 'descr':legendDescription, 'catUniqueName':catUniqueName, 'saved':save};
		// add cat to saved legend things array
		activeLegendItems_arr[catUniqueName] = legendData_obj;

		// set html str for legend piece
		var divEl = document.createElement("div");
		divEl.id = 'legend'+catUniqueName;
		divEl.className = 'legenditem legend'+catUniqueName;
		divEl.innerHTML = '<a href="#" onclick="deleteCategory(this.parentNode.className.split(\' \')[1].substr(6))" id="delcatlink'+catUniqueName+'" class="delcatlink legend'+catUniqueName+'" title="remove this category" style="display:none"> X <\/a>'+
			'<div class="legendcolor" style="background-color:'+legendColor_str+'">&nbsp;<\/div>'+
			' &nbsp;' + legendDescription;
		// add to legend
		document.getElementById('legendHolder').appendChild(divEl);
	} else {
		var legendData_obj = activeLegendItems_arr[catUniqueName];
	}
	return legendData_obj;
}

function setLegend(catID_arr, legendData_obj){
	if(!catID_arr.length){
		document.getElementById('legend'+legendData_obj.catUniqueName).innerHTML += ' (no results)';
		return;
	}

	var currEl, i, legendColorHTML_str;
	var classToFind = 'legend'+legendData_obj.catUniqueName;
	
	for(i in catID_arr){
		// check if class already set, and if not, add the color thing
		currEl = positions_arr['pos'+catID_arr[i]].el;
		if(currEl.innerHTML.indexOf(classToFind) == -1){
				// create el
			legendColorHTML_str = document.createElement("div");
			legendColorHTML_str.className = 'legendcolor legend'+legendData_obj.catUniqueName;
			legendColorHTML_str.style.backgroundColor = legendData_obj.color;
			legendColorHTML_str.innerHTML = '&nbsp;';
				// add to pos
			currEl.appendChild(legendColorHTML_str);
		}

		// check if company is already in legend. if so, add to div with colors
		if(positions_arr['pos'+catID_arr[i]].inLegend){
			document.getElementById('legendcolors'+catID_arr[i]).appendChild(legendColorHTML_str);
		}
	}
}


function highlight(pos_arr){
	var currEl;
	for(var i in pos_arr){
		currEl = positions_arr['pos'+pos_arr[i]].el;
		addClassName(currEl, 'highlighted');
		currEl.ref = isNaN(currEl.ref) ? 1 : parseInt(currEl.ref)+1;
	}
}
function unHighlight(pos_arr){
	var currEl;
	for(var i in pos_arr){
		currEl = positions_arr['pos'+pos_arr[i]].el;
		if(currEl.ref)
			currEl.ref = parseInt(currEl.ref)-1;
		if(!currEl.ref || currEl.ref==0)
			removeClassName(currEl, 'highlighted');
	}
}

function addClassName(el, clname){
	var clsnms = el.className.replace(/[\r\n\t ]+/g, " ");
	var regex_str = new RegExp("(^| )" + clname + "( |$)");
	if(clsnms.match(regex_str) == null)
		el.className += ' ' + clname;
}

function removeClassName(el, clname){
	var clsnms = el.className.replace(/[\r\n\t ]+/g, " ");
	var regex_str = new RegExp("(^| )" + clname + "($| .*)");
	el.className = clsnms.replace(regex_str, "$2");
}

function regexEscape(s) {
	return s.replace(/[\\\^\$\*\+\?\(\)\|\{\}\[\]\.]/g, "\\$&");
}

function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^| )" + className + "( |$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}

var savedPoses_arr = new Array();
function addPos(posid){
	var posid_id = posid.substr(3);
	var thepos = positions_arr[posid].el;
	// UNhighlight
	unHighlight([posid_id]);
	// check if already saved
	var reg = new RegExp(posid_id+"($|,)");
	
	if(!savedPoses_arr.join(',').match(reg)){
		// remember
		savedPoses_arr.push(posid_id);
		foundpos = savedPoses_arr.length;
		// set border
		addClassName(thepos, "savedpos");
		removeClassName(thepos, "pos");

		// create positioning style for number
		var contheight = parseFloat(thepos.style.height);
		var contwidth = parseFloat(thepos.style.width);
		
		// put number into div
		var newdiv = document.createElement("div");
		newdiv.id= 'number'+posid_id;
		newdiv.className = "posnumber";
		newdiv.style.top = thepos.style.top;
		newdiv.style.left = thepos.style.left;
		newdiv.style.width = (parseFloat(thepos.style.width)+2) + 'px';
		newdiv.style.height = (parseFloat(thepos.style.height)+2) + 'px';

		// if fromtop==0, check if we have to make the font smaller
		newdiv.style.fontSize = (contwidth > 17) ? '12px' : (contwidth > 13) ? '11px' : (contwidth < 9 || contwidth < 13 && savedPoses_arr.length > 9) ? '9px' : '10px';
		if(contheight < (parseFloat(newdiv.style.fontSize)-1)){
			newdiv.style.fontSize = (contheight+1) + 'px';
		}
		// how far should the text be from top
		var fromtop = contheight > parseInt(newdiv.style.fontSize) ? Math.ceil((contheight - parseInt(newdiv.style.fontSize))/2) : 0;//-15=height of normal text

		newdiv.innerHTML = '<div class="nr" id="nr'+posid_id+'" style="padding-top:'+fromtop+'px">' + savedPoses_arr.length + '</div><div class="delposX" onclick="delpos(\''+posid_id+'\')" title="remove this stand">X<\/div>';
		document.getElementById('map1').appendChild(newdiv);
		// add actions: actions of underlying layer don't propagate somehow
		newdiv.onmouseover = function(e){posmouseover(e,thepos,this)};
		newdiv.onmouseout = function(e){posmouseout(false)};

		// add to 2nd legend
		setCompanyInLegend(posid_id, foundpos);
	}
}

function delpos(posid, doRearrange){
	// if prev. saved
	if(savedPoses_arr.join('|').indexOf(posid) > -1){
		var theEl = positions_arr['pos'+posid].el;

		// get it's categories
		var cats_arr = getElementsByClassName("legendcolor", "DIV", theEl);
		for(var d=0;d<cats_arr.length;d++){
			var IDToFind = cats_arr[d].className.split(' ')[1];
			var isSaved = !!(activeLegendItems_arr[IDToFind.substr(6)]!=null);
			var numfound = getElementsByClassName(IDToFind, "DIV").length;
			// if only used for the el we are going to delete
			if((isSaved && numfound<4) || (!isSaved && numfound<3)){
				removeLegend(IDToFind.substr(6));
			}
			// remove the color thingie
			removeEl(cats_arr[d]);
		}
		
		//remove number div
		removeEl(document.getElementById('number'+posid));
		
		// remove class
		addClassName(theEl, "pos");
		removeClassName(theEl, "savedpos");
		
		// remove from legend
		removeEl(document.getElementById('legend'+posid));
		positions_arr['pos'+posid].inLegend = false;

		
		// remove el from saved posses
		var theRegExp = new RegExp("(^"+posid+"(,|$)|,"+posid+"(,|$))");
		savedPoses_arr = savedPoses_arr.join(',').replace(theRegExp, "$3").split(',');
		if(savedPoses_arr.length==1 && savedPoses_arr[0]==''){
			savedPoses_arr.length=0;
		}
		if(doRearrange==null||doRearrange){
			for(var x=0;x<savedPoses_arr.length;x++){
				// reset the number in the map
				document.getElementById('nr'+savedPoses_arr[x]).innerHTML = x+1;
				// reset the number in the legend
				document.getElementById('legendnr'+savedPoses_arr[x]).innerHTML = x+1;
			}
		}
	}
}
function removeEl(el){
	if(el){
		// firefox, when adding content by .innerHTML, the elements are not attached to a parent :-/
		// luckily they can de deleted by delete statement, because of that same reason.
		if(!el.parentNode){
			//console.log(el);
			//console.log("has no parent");
			delete el;
		} else {
			el.parentNode.removeChild(el);
		}
	}
}
function setCompanyInLegend(posid, nr){
	var pos_obj = positions_arr['pos'+posid];
	// find company name(s) if available
	var descr = pos_obj.title;
	var standnr = pos_obj.stand;

	// get the colors
	var colorsHTML = document.createElement("div");
	var posHTMLDivs = getElementsByClassName("legendcolor", "DIV", pos_obj.el);

	for (var i=0;i<posHTMLDivs.length;i++){
		colorsHTML.appendChild(posHTMLDivs[i]);
	}
	colorsHTML=colorsHTML.innerHTML;
	if(colorsHTML=='') colorsHTML = '&nbsp;';
	
	// set html str for legend piece
	var divEl = document.createElement("div");
	divEl.id = 'legend'+posid;
	divEl.className = 'legend'+posid;
	divEl.style.clear='both';
	divEl.style.borderTop = '1px solid silver';
	divEl.innerHTML = '<a href="javascript:delpos(\''+posid+'\')" class="delcatlink" title="remove this company"> X <\/a>'+
		'<div class="legendposnr" id="legendnr'+posid+'">'+nr+'<\/div>'+
		'<div class="standnr">'+ standnr + '<\/div>'+
		'<div class="description">'+ descr + '<\/div>'+
		'<div class="colors" id="legendcolors'+posid+'">'+colorsHTML+'<\/div>';
	// add to legend
	document.getElementById('legendHolder2').appendChild(divEl);
	
	positions_arr['pos'+posid].inLegend=true;
}

function deleteCategory(catUniqueName){
	removeLegend(catUniqueName);
	var colorHolders_arr = getElementsByClassName("colors", "DIV");
	for(var w=0;w<colorHolders_arr.length;w++){
		if(colorHolders_arr[w].innerHTML==''){
			delpos(colorHolders_arr[w].id.substr(12), !!(w+1==colorHolders_arr.length));
		}
	}
}

function doPoslinkPopup(lnk){
	var name = 'win'+Math.floor(100000000000*Math.random());
	var thewin = window.open(lnk, name, 'width=790,height=550,resizable=1,scrollbars=1,top=0,left=0');
	thewin.focus();
}
var currHoverPos = null;
var currNumHoverPos = null;
function posmouseover(evt,ref,posnumdiv){
	// cleanup
	posmouseout(true);
	
	evt=evt?evt:event;
	doTooltip(evt, document.getElementById(ref.id+'txt').innerHTML);

	// set active item
	addClassName(ref, 'poshover');

	// remember active item
	currHoverPos=ref;
	
	if(posnumdiv) {
		addClassName(posnumdiv, 'posnumberhover');
		currNumHoverPos = posnumdiv;
	} else {
		removeClassName(ref, 'pos');
	}
}
function posmouseout(leavetip){
	if(currHoverPos){
		if(!leavetip)hideTip();
		if(currHoverPos.className.indexOf('savedpos') == -1){
			addClassName(currHoverPos, 'pos');
		}
		removeClassName(currHoverPos, 'poshover');
		currHoverPos=null;
	}
	if(currNumHoverPos){
		removeClassName(currNumHoverPos, 'posnumberhover');
		currNumHoverPos = null;
	}
}


function pdfNow(){
	var frm = document.forms['pdfform'];
	// positions (stands)
	var tmp_arr = [];
	for(var q in savedPoses_arr){tmp_arr[tmp_arr.length] = ids_obj[savedPoses_arr[q]]}
	frm.mappositions_id.value = tmp_arr.join(',');
	// subcats (legend)
	tmp_arr = [];
	for(q in activeLegendItems_arr){tmp_arr[tmp_arr.length] = ids_obj[q]}
	frm.mapsubcategories_id.value = tmp_arr.join(',');
	// legend html
	frm.legendHTML.value = document.getElementById('legendHolder').innerHTML;
	// legend html 2
	frm.legendHTML2.value = document.getElementById('legendHolder2').innerHTML;
	if(typeof(isIE) != 'undefined'){
		frm.target = '_blank';
/*		var thewin = window.open('', 'thewin', 'width=400,height=400,top=0,left=0,resizable=1');
		thewin.focus();
		frm.target = 'thewin';
*/	}
	frm.submit();
}

function resetPlan(){
	var allPositions, w;
	// the poses
	allPositions = getElementsByClassName('savedpos', 'div', document.body);
	for(w in allPositions){
		if(allPositions[w])
			delpos(allPositions[w].id.substr(3), false);
	}
	allPositions = getElementsByClassName('highlighted', 'div', document.body);
	for(w in allPositions){
		if(allPositions[w])
			unHighlight([allPositions[w].id.substr(3)]);
	}
	
	// the legend
	allPositions = getElementsByClassName('legenditem', 'div', document.body);
	for(w in allPositions){
		if(allPositions[w])
			removeEl(allPositions[w]);
	}

	// the form itself
	document.getElementById('searchfrm').reset();
	// actions for text search fields
	var allPositions = getElementsByClassName('srchfld', 'input', document.getElementById('search'));
	for(var i=0;i<allPositions.length;i++){
		allPositions[i].onblur();
		allPositions[i].onkeyup();
	}
	// actions for select fields
	allPositions = document.getElementsByTagName("select");
	for(i=0;i<allPositions.length;i++){
		allPositions[i].onchange();
	}
}


		function showhideExpl(){
			var thediv = document.getElementById('explanation');
			var topdiv = document.getElementById('explanationTxt');
			var dohide = (thediv.style.display=='block');
			
			self.location.href = '#top';
	
			thediv.style.display = topdiv.style.display = dohide ? 'none' : 'block';
			
			if(dohide)
				removeClassName(document.getElementsByTagName("html")[0], "overlay");
			else
				addClassName(document.getElementsByTagName("html")[0], "overlay");
		}
		function cancell(){}

