/*deleteCache-description:*/
/*deleteCache-minimizeJS:false*/
tzO=tzD='';
var mAjax = {
	async:true,
	cache:false,
	data:'',
	dataType:'json',
	error: function(reqObj, tos){$(".p_w").css("display","none");slideDivs(3);},
	success:function(rsp){processResponse(rsp);},
	timeout:5000,
	type:'POST',
	url:'/ajax/merchants/air.json.php'
};
var response;
var sel;
var airports;
var lastParams="";
function processResponse(rsp){
	response=rsp;
	$(".p_w").css("display","none");
	var m = response.merchants;
	airports = response.airports;
	if (airports) {
		var df = document.forms.ExpressBkFltonly;
		if (airports.fromAir.length==1) df.inp_dep_arp_cd_1.value=airports.fromAir[0].city+" ("+airports.fromAir[0].code+")";
		if (airports.toAir.length==1) df.inp_arr_arp_cd_1.value=airports.toAir[0].city+" ("+airports.toAir[0].code+")";
		if (airports.fromAir.length<1) {
			alert("We did not find any departure airports matching your search criteria. Please refine your search.");
			return;
		}
		else if (airports.toAir.length<1) {
			alert("We did not find any arrival airports matching your search criteria. Please refine your search.");
			return
		}
		else if (airports.fromAir.length>1 || airports.toAir.length>1) {
			displaySearchRefine();
			return
		}
		airports=window.undefined;
	};
	if(response.trackPxlUrl) {
			var d = new Date();
			trPxl = response.trackPxlUrl+"&impId="+queryCode+"&"+d.getTime();
			$.ajax({url:trPxl, type:"HEAD"});
	}
	sel=new Array();
	var i=0;
	$(".mSel, .mSelSmall").each(function(){
		sel[i] = this.id;
		this.onclick();
		i++;
	});
	$("#mCont div").remove();
	for (i=0;i<m.length;i++)
		if (i<3){
			$("#mCont").append("<div onclick='selectBoxWithImg(\""+i+"\");' id=\"m"+m[i].code+"\"> "+
						"<input type=\"checkbox\" class=\""+m[i].code+"\" alt=\"check prices from "+m[i].name+"\" onclick='return selectBox("+m[i].code+", \""+m[i].name+"\", \""+m[i].url+"\", this);' id=\"selectBox"+i+"\" name=\"selectBox"+i+"\"/> "+
						"<img height=\"35\" width=\"140\" longdesc=\""+m[i].url+"\" alt=\""+m[i].name+"\" src=\"/images/merchants/"+m[i].logo+"\"/> "+
					"</div>");
		} else {
			$("#mCont").append("<div onclick='selectBoxWithImg(\""+i+"\");' class=\"mSmall\" id=\"m"+m[i].code+"\"> "+
						"<input type=\"checkbox\" class=\""+m[i].code+"\" alt=\"check prices from "+m[i].name+"\" onclick='return selectBox("+m[i].code+", \""+m[i].name+"\", \""+m[i].url+"\", this);' id=\"selectBox"+i+"\" name=\"selectBox"+i+"\"/>"+
						"<img height=\"25\" width=\"100\" longdesc=\""+m[i].url+"\" alt=\""+m[i].name+"\" src=\"/images/merchants_small/"+m[i].logo+"\"/> "+
					"</div>");
		};
	for(j=0;sel[j];j++) if ($("#"+sel[j])[0]) {$("#"+sel[j])[0].onclick();};
	/*if (nrSelMer==0) $('#mCont div:lt(2)').each(function() {this.onclick()});*/
	if(response.ads340x45 && response.ads340x45.length) {
		$("#mCont p").remove();
		$("#mCont").append(
		"<p>"+
			"<a href='#' onclick='jump(\""+response.ads340x45[0].code+"\",\""+response.ads340x45[0].name+"\", \"41\");return  false;'>"+
				response.ads340x45[0].name+"<br>"+
				"<img width='340' height='45' alt='"+response.ads340x45[0].url+"' src='/images/merchants340x45/"+response.ads340x45[0].logo+"'>"+
			"</a>"+
		"</p>");
	}
	lastParams = $(document.forms.ExpressBkFltonly).serialize();
	updateTzoo();
	$('img[@alt=cFares]:eq(0)').parent().not(".mSel, .mSelSmall").click();
	slideDivs(3);
};

function updateTzoo() {
	var patt = new RegExp(".*\\((.{3})\\).*");
	var fa = $("#fromAir").val() ? $("#fromAir").val() : "";
	var ta = $("#toAir").val() ? $("#toAir").val() : "";
	var tmp;
	if (fa) {tmp = patt.exec(fa);fa = (tmp && tmp[1]) ? tmp[1] : fa;};
	if (ta) {tmp = patt.exec(ta);ta = (tmp && tmp[1]) ? tmp[1] : ta;};
	$("#tzoo").fadeOut(200,function(){
		$("#tzoo").attr("src","http://oascentral.travelzoo.com/RealMedia/ads/adstream_sx.ads/Faredetective.com/@Top?O="+fa+"&D="+ta).load(function(){
			$("#tzoo").fadeIn(200);
		});
	});
};

function refreshMerchants() {
	var Params = $(document.forms.ExpressBkFltonly).serialize();
	if (Params==lastParams) {
		slideDivs(3);
		return 1;
	};
	$(".p_w").css("display","block");
	mAjax.data=Params;
	$.ajax(mAjax);
	lastParams = Params;
	return 1;
};
function selectContent(obj, txt) {
	return (obj.value == txt) ? obj.value='' : obj.select();
}

function createRequestObject() {
	var xmlHttp;
	try{xmlHttp=new XMLHttpRequest();}catch(e){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){return false;}}}
	return xmlHttp;
}

function slideDivs(targetDiv) {
	$('#selMerDiv, .bcY').height("");
	$("#screen2").slideDown(400,function(){
		$("#screen1, #screen3, #screen4").css("display","none");
		$("#screen"+targetDiv).css("display","block");
		$("#screen2").slideUp(400,function(){
			if (targetDiv==1) {
				$("#steps").css("background-position","left top").text(step1);
				$("#go").text(nextStep);
				$("#back").css("visibility","hidden");
				document.getElementById('go').onclick = function() {validateAndRefresh(document.ExpressBkFltonly.inp_dep_arp_cd_1, document.ExpressBkFltonly.inp_arr_arp_cd_1,coap, searchSys); }
			}
			if (targetDiv==3) {
				if ($('#selMerDiv div.sMer').length>4) $('#selMerDiv, .bcY').height("auto");
				$("#steps").css("background-position","left bottom").text(step2);
				document.getElementById('go').onclick = function() { compare(cmpMsg); }
				if(nrSelMer>1) $("#go").text(cmpText);
				$("#back").css("visibility","visible");
			};
			if (targetDiv==4) {
				$("#steps").css("background-position","left bottom").text(step2);
				$("#back").css("visibility","visible");
				var gobttn = $("#go").text("Select")[0];
				gobttn.onclick=function() {selectandcompare(true);};
				$("#back")[0].onclick=function() {
					slideDivs(1);
				};
			};
		});
	});
	return false;
}

function selectBox(id, merchant, merchantUrl, chBox) {
	var mDiv = chBox.parentNode;
	if(chBox.checked == false) {
        	nrSelMer--;
		if(nrSelMer==1) $("#go").text(nextStep);
		$(mDiv).removeClass("mSelSmall mSel")
		popSelMer(id, merchant);
		popMerchantUrlVer9(chBox);
        	return true;
        }
	if(nrSelMer>=40) {
		showMaxAlert();
		return false;
	}
	nrSelMer++;
	pushSelMer(id, merchant);
	pushMerchantUrlVer9(chBox);
	if(nrSelMer==2) {$("#go").text(cmpText);}
	$(mDiv).addClass((($(mDiv).hasClass("mSmall")) ? "mSelSmall" : "mSel"));
	return true;
}

function showBlDiv() {
	if(document.getElementById('msgDiv').style.display == 'block') {
		$('#msgDiv').css("display",'none');
		$('#slt2').css("display",'block');
	}
	$('#ppDiv').css("display","block");
	$('#slideCont').slideUp(400);
	if(document.images["ppSmall"].src.indexOf("images_v9/turnoff_small.gif")==-1)
		document.images["ppSmall"].src = "/images_v9/turnoff_small.gif";
	return;
}

function updTzoo(fAir, tAir) {
	tzo=$('#tzoo').get(0);
	if(tzo == undefined) return false;
	var nSrc=tzo.src;
	if(fAir) nSrc = nSrc.replace(/O=(.*)&/, 'O='+fAir+'&');
	if(tAir) nSrc = nSrc.replace(/D=(.*)/, 'D='+tAir);
	if(tzo.src==nSrc) return false;
	$('#tzoo').fadeOut(400);
	tzo.src=nSrc;
	return true;
}
function tzdLoader(tzd) {
	if(tzd.style.display!='block') $(tzd).fadeIn(400);
}
function popMerchantUrlVer9(chBox) {
	var urlText = $('img', chBox.parentNode).attr('longdesc').replace("http://", "");
	var elem = $('#selMerDiv div:contains('+urlText+')');
	if (!urlText) elem = $('#selMerDiv div:empty:lt(1)');
	/*if (!elem.hasClass('nodp')) $('#selMerDiv div.sMer.nodp:lt(1)').removeClass('nodp');*/
	elem.remove();
	if ($('#selMerDiv div.sMer').length<=4) /*nodClass='nodp';*/$('#selMerDiv, .bcY').height("");

	return true;
}
function pushMerchantUrlVer9(chBox) {
	var nodClass='';
	if ($('#selMerDiv div.sMer').length>=4) /*nodClass='nodp';*/$('#selMerDiv, .bcY').height("auto");
	$('#selMerDiv').append("<div class='sMer "+nodClass+"' onclick='compare(cmpMsg,"+$('img', chBox.parentNode).parent().attr('id').substr(1)+")'>"+
		$('img', chBox.parentNode).attr('longdesc').replace("http://", "")+
	"</div>");
	return true;
}
function convertDate(date) {
	var tmp=new Object();
	tmp.d = USDate ? date.substr(3,2) : date.substr(0,2);
	tmp.m = USDate ? date.substr(0,2) : date.substr(3,2);
	tmp.y = date.substr(6,4);
	return tmp;
}
function trackPPB(blyn) {
	$.ajax( { url:"/ajax/track_ppb.php", type:"POST", 
		data: {'trackingId':queryCode, 'idReferral':idReferral, 'blocker':blyn }
	});
	return;
}
function LZ(t) {
	t = t.toString();
	if (t.length==1) return "0"+t;
	return t;
};
function validDate(date,limit) { //returns: 0 if not valid, 1 if valid, but limit is in past, 2 if both dates are in future and they are valid
	today=new Date();
	today = USDate ? (LZ(today.getMonth()*1+1))+"/"+(LZ(today.getDate()))+"/"+(today.getFullYear()) : (LZ(today.getDate()))+"/"+(LZ(today.getMonth()*1+1))+"/"+(today.getFullYear());

	if (!limit) {
		limit=today;
	};
	var t=convertDate(limit);
	if (t.d>31 || t.d<1 || t.m>12 || t.m<1 || t.y<2008) return 0;
	limit=new Date();
	limit.setFullYear(t.y,t.m-1,t.d);
	var d = convertDate(date);
	if (d.d>31 || d.d<1 || d.m>12 || d.m<1 || d.y<2008) return 0;

	var t=convertDate(today);
	var today = new Date();
	today.setFullYear(t.y,t.m-1,t.d);

	var tmp = new Date();
	tmp.setFullYear(d.y,d.m-1,d.d);
	if (limit>tmp) return 0;
	if (tmp.getDate()!=(d.d*1) || (tmp.getMonth()+1)!=(d.m*1) || tmp.getFullYear()!=(d.y*1)) return 0;
	if (limit<today) return 1;
	return 2;
};

function Rounded(selector,bk,color,size){$(selector).each(function(){AddTop(this,bk,color,size);AddBottom(this,bk,color,size);});}
function AddTop(el,bk,color,size){var i;var d=document.createElement("b");var cn="r";var lim=4;if(size && size=="small"){cn="rs";lim=2}d.className="rtop";d.style.backgroundColor=bk;for(i=1;i<=lim;i++){var x=document.createElement("b");x.className=cn + i;x.style.backgroundColor=color;d.appendChild(x);}el.insertBefore(d,el.firstChild);}
function AddBottom(el,bk,color,size){var i;var d=document.createElement("b");var cn="r";var lim=4;if(size && size=="small"){ cn="rs"; lim=2}d.className="rbottom";d.style.backgroundColor=bk;for(i=lim;i>0;i--){var x=document.createElement("b");x.className=cn + i;x.style.backgroundColor=color;d.appendChild(x);}el.appendChild(d,el.firstChild);};
var openedAlertBox = false;
var undefined;
var timeoutDelay = 500; 
var timeoutId = false;
var newWin = 0;
var alertsEnabled = true;
var http = createRequestObject();
var httpNews = createRequestObject();
var prevCity1 = "";
var prevCity2 = "";
if(typeof(initMail)=='undefined')
	var initMail = "Enter your e-mail address";
if(typeof(coap)=='coap')
	var coap = "city or airport code"; //city or Airport code
var searchSys = "def";
//var nrAdvertisers = 8;
var linkCounter = 'http://www.travelgrove.com/cgi-bin/cruises/link_counter.cgi';

var errorMsg, depCityError, arrCityError, dateError, negDateError, mailError, chAgeError;
var nrSelMer=0;
var fButton1 = new Image();
var fButton2 = new Image();
var chBoxChecked = new Image();
var chBoxUnchecked = new Image();
var emptyImg = new Image();
var cmpInProcess = false;
var wasValidated = false;

var selectedMerchants = new Array();
var selectedMerchantsUrls = new Array();
var newWinX = 20;
var newWinY = 20;

function createRequestObject() {
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest();
	} catch (e) {	try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {	try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e) { return false; }
		}
	}
	return xmlHttp;
}

function validateAndRefresh(city1, city2, cityOrAirport, searchSystem) {
	var dataForm = document.forms.ExpressBkFltonly;
	if(!dataForm) return false;
	if(document.grovezine && document.grovezine.email)
		var mailAddress = document.grovezine.email.value;
	else
		var mailAddress = initMail;
	if(document.images["step1"])
		document.images["step1"].src = "../images/main/general/deselect1.gif";
	if(document.images["step2"])
		document.images["step2"].src = "../images/main/general/select2.gif";
	if(document.getElementById('shadowDiv'))
		document.getElementById('shadowDiv').style.display='none';
	if(document.getElementById('selectMerchant'))
		document.getElementById('selectMerchant').disabled = false;

	if(mailAddress!=initMail && !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mailAddress))) {
		if(alertsEnabled) alert(mailError); //invalid mail address
	} else if(mailAddress!=initMail) {
		httpNews.onreadystatechange=function() {
			if(httpNews.readyState == 4) {
				var response ="";
				response=httpNews.responseText;
				var myDiv = (document.getElementById('newsLetterDiv')) ? document.getElementById('newsLetterDiv') : document.getElementById('newsText');
				if(myDiv && response)
				{
					if(response=="reactivate")
					{
						if(confirm("This email address was already unsubscrubed.\n Do you wish to reactivate it?")==true)
						{
							httpNews.open('get', '/ajax/subscribe.php?reactivate=yes&source=FARE&email='+mailAddress+'&searchsystem='+searchSystem, true);
							httpNews.send(null);
							myDiv.innerHTML = "Thank you for registering.";
						}
					}
					else
						myDiv.innerHTML = response;
				} //if myDiv && response
			} //readt state = 4
			//else alert("State:"+httpNews.readyState);
		} // on ready state change
		httpNews.open('get', '/ajax/subscribe.php?source=FARE&email='+mailAddress+'&searchsystem='+searchSystem+'&idReferral='+idReferral+'&adid='+adId, true);
		httpNews.send(null);
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+100);
		document.cookie="news=" +escape("yes")+";expires="+exdate;
		var myWin = window;
	} //if valid mailAddress
	if(versionNr==7 || versionNr==8) {
		changeBlursAndButtons(0,1, 0);
	}
	if(versionNr==9)
		slideDivs(3);
} //end function

function jump(id, merchant) {
	var myWinWidth = screen.width * 0.8;
	var myWinHeight = screen.height * 0.8;
	var myWinCoord = "left="+newWinX+",top="+newWinX+",width="+myWinWidth+",height="+myWinHeight+",resizable = yes,scrollbars=yes, toolbar=yes, location=yes";
	var line = document.ExpressBkFltonly.cruiseline.value;
	var monthYear = document.ExpressBkFltonly.month_year.value;
	var dest = document.ExpressBkFltonly.destination.value;
	var lengthOfStay = document.ExpressBkFltonly.length_of_stay.value;
	var leaveDate = new Date();
	var myMY = leaveDate.getFullYear() * 100 + leaveDate.getMonth() + 1;
	if(monthYear && monthYear < myMY) {
		alert('Please select a valid date.');
		return false;
	}
	var link = linkCounter+'?merchant='+merchant+'&logo=fd'+'&cruiseline='+line+'&destination='+dest+'&month_year='+monthYear+'&length_of_stay='+lengthOfStay+'&intitem='+id+'&idReferral='+idReferral+'&adid='+adId+'&querycode='+queryCode+'&subID='+subID+'&source=fare';
//	newWin = window.open(link,"_blank",myWinCoord);
	newWin = window.open(link,"_blank",myWinCoord);
}

function selectBoxWithImg(advNr)
{
	var chBox = document.getElementById("selectBox"+advNr);
	if(!chBox.checked && nrSelMer>=40)
	{
		showMaxAlert();
		return false;
	}
	chBox.checked = !chBox.checked;
	var chBoxImg = document.getElementById('imgChBox'+advNr);
	if(chBoxImg)
	{
		if(chBox.checked)
			chBoxImg.src = chBoxChecked.src;
		else
			chBoxImg.src = chBoxUnchecked.src;
	}
	return chBox.onclick();
}

function compare(alertMsg,filterMerchants) {
	if(cmpInProcess) return;
	if(versionNr==7 || versionNr==8)
		showRedirectBox();
	cmpInProcess = true;
	if(!wasValidated && versionNr!=7)
			document.getElementById('go').onclick();
	newWinX = 20;
	newWinY = 20;
	if(nrSelMer == 0) {
		cmpInProcess = false;
		alert(alertMsg);
		return false;
	}
	dx = 30;
	dy = 30;
	var n = selectedMerchants.length;
	var prevOpenedMerName = "";
	setTimeout("cmpInProcess = false;",2000);
	for(var merId=n-1; merId>=0; merId--)
		if(selectedMerchants[merId]) {
			var params = selectedMerchants[merId];
			var delim = params.indexOf("_");
			var mId = params.substring(0, delim);
			var mName = params.substring(delim+1);
			if (!filterMerchants || (filterMerchants && filterMerchants==mId)) {
				jump(mId, mName);
				newWinX += dx;
				newWinY += dy;
				if(newWin == null || typeof(newWin) == 'undefined') {
					window.focus();
					//deselectFirstIfBlocked(prevOpenedMerName);
					if(versionNr==7 || versionNr==8)
						hideAlert();
					showBlDiv();
					return false;
				}
				prevOpenedMerName = mName;
			}
		}
	if(versionNr==7 || versionNr==8) {
		this.backStep(3);
		this.setTimeout('hideAlert()', 6000);
	}
	return true;
}

function compareVer4(alertMsg) {
	return compare(alertMsg);
}
function compareVer5(alertMsg) {
	return compare(alertMsg);
}

function closeBlDiv() {
	if(versionNr==9) {
		$('#slideCont').slideDown(400, function() {
			document.getElementById('ppDiv').style.display = "none";
		});
		return;
	}
	var ppDiv = (document.getElementById('popupTable')) ? document.getElementById('popupTable') : document.getElementById('blockerDiv');
	if(!ppDiv) return false;
	ppDiv.style.visibility = "hidden";	
	if(document.all) //IE
	{
		var sbForm = document.forms.ExpressBkFltonly;
		if(!sbForm) return false;
		if(sbForm.leave_day) sbForm.leave_day.style.visibility = 'visible';
		if(sbForm.leave_year) sbForm.leave_year.style.visibility = 'visible';
		if(sbForm.return_day) sbForm.return_day.style.visibility = 'visible';
		if(sbForm.return_year) sbForm.return_year.style.visibility = 'visible';
		if(sbForm.inp_child_pax_cnt) sbForm.inp_child_pax_cnt.style.visibility = 'visible';
		if(sbForm.star_rating) sbForm.star_rating.style.visibility = 'visible';
		if(sbForm.no_rooms) sbForm.no_rooms.style.visibility = 'visible';
		if(sbForm.cruiseline)
		{
			sbForm.cruiseline.style.visibility = 'visible';
			sbForm.destination.style.visibility = 'visible';
			sbForm.length_of_stay.style.visibility = 'visible';
			sbForm.month_year.style.visibility = 'visible';
		}
	}
}

function addMerchant(advNr)
{
	var chBox = document.getElementById("selectBox"+advNr);
	if(chBox.checked) return;
	if(!chBox.checked && nrSelMer>=4) return false;
	chBox.checked = !chBox.checked;
	var chBoxImg = document.getElementById('imgChBox'+advNr);
	if(chBoxImg)
	{
		//if(chBox.checked)
			chBoxImg.src = chBoxChecked.src;
		//else
			//chBoxImg.src = chBoxUnchecked.src;
	}
	return chBox.onclick();
}

function hideMaxAlert()
{
	setTimeout("document.body.onclick = null;", 100);
	var alertTable = (document.getElementById('alertTable')) ? document.getElementById('alertTable') : document.getElementById('maxAlert');
	if(!alertTable)
		return false;
	alertTable.style.visibility = 'hidden';
	return;
}

function hideAlert() {
	if(!openedAlertBox) return;
	var pt = (document.getElementById('popupTable')) ? document.getElementById('popupTable') : document.getElementById('blockerDiv');
	var at = (document.getElementById('alertTable')) ? document.getElementById('alertTable') : document.getElementById('maxAlert');
	var rb = document.getElementById('redirectDiv'); //redirect Box
	if(at && at.style.visibility == 'visible') {
		at.style.visibility = 'hidden';
	}
	if(pt && pt.style.visibility == 'visible') {
		pt.style.visibility = 'hidden';
	}
	if(rb && rb.style.visibility == 'visible') {
		rb.style.visibility = 'hidden';
	}
	if(versionNr==7 || versionNr==8) showFieldsV7();
	openedAlertBox = false;
	setTimeout("openedAlertBox = false;", 10);
	document.body.onclick = null;
	return;
}

function preventEventToPropagate(ev)
{
	if(document.all)
	{
		ev.returnValue=false;
		ev.cancelBubble = true;
	} else {
		ev.preventDefault();
		ev.stopPropagation();
	}
}

function popSelMer(mId, mName)
{
	var n = selectedMerchants.length;
	for(var i=0; i<n; i++)
	{
		if(selectedMerchants[i] == mId+"_"+mName)
		{
			selectedMerchants[i] = undefined;
			return true;
		}
	}
}

function pushSelMer(mId, mName)
{
	var n = selectedMerchants.length;
	selectedMerchants[n] = mId+"_"+mName;
}

function pushMerchantImg(chBox)
{
	var merImgId = "img" + chBox.id.replace("selectBox","");
	var imgId = "selMer"+nrSelMer;
	var merImgSmall = new Image();
	//merImgSmall.src = document.images[merImgId].src;
	merImgSmall.src = document.images[merImgId].src.replace("merchants","merchants_small");
	document.images[imgId].src = merImgSmall.src;
	return true;
}

function popMerchantImg(chBox)
{
	var merImgId = "img" + chBox.id.replace("selectBox","");
	var tr = document.getElementById("selMerTr");
	var n = tr.cells.length;
	var i=0;
	for(; i<n; i++)
	{
		logoSmallSrc = tr.cells[i].firstChild.src;
		logoSmallSrc = logoSmallSrc.replace("merchants_small", "merchants");
		selMerImgSrc = document.images[merImgId].src;
		if(logoSmallSrc == selMerImgSrc)
		{
			tr.deleteCell(i);
			tr.insertCell(n-1);
			tr.cells[n-1].innerHTML = '<img src="'+emptyImg.src+'" id="selMer" name="selMer" alt="">';
			for(var j=i; j<n; j++)
			{
				tr.cells[j].firstChild.id = "selMer"+(j+1);
				tr.cells[j].firstChild.name = "selMer"+(j+1);
			}
		}
	}
}

function setCheckboxImgs()
{
	for(var i=1; i< advIdx+1; i++)
	{
		if(document.images["imgChBox"+i])
			document.images["imgChBox"+i].src = chBoxUnchecked.src;
		document.getElementById("selectBox"+i).checked = false;
	}
}

function pushMerchantImgVer6(chBox)
{
	var merImgId = "img" + chBox.id.replace("selectBox","");
	var imgId = "selMer"+nrSelMer;
	var merImg = new Image();
	merImg.src = document.images[merImgId].src;
	if(document.images[imgId])
		document.images[imgId].src = merImg.src;
	//else alert("ImgId:"+imgId);
	return true;
}

function popMerchantImgVer6(chBox) {
	var merImgId = "img" + chBox.id.replace("selectBox","");
	selMerImgSrc = document.images[merImgId].src; // the clicked image
	var tbl = document.getElementById("selMerTable");
	var n = tbl.rows.length;
	var imgChildIdx = 0;
	//var s = selMerImgSrc+", \n";
	for(var i=0; i<n; i++)
	{
		tc = tbl.rows[i].cells[0];
		logoSmallSrc = "";
		for(imgChildIdx=0; imgChildIdx<tc.childNodes.length; imgChildIdx++)
			if(tc.childNodes[imgChildIdx].src)
				break;
		//finding the picture node in the node list of a table cell
		logoSmall = tc.childNodes[imgChildIdx];
		if(logoSmall.src == selMerImgSrc)
		{
			for(var j=i; j<n-1; j++)
			{
				var imgTd1 =  tbl.rows[j].cells[0].childNodes[imgChildIdx];
				var imgTd2 =  tbl.rows[j+1].cells[0].childNodes[imgChildIdx];
				imgTd1.src = imgTd2.src;
			} //moving all images after the deleted image upper with one position
			tbl.rows[j].cells[0].childNodes[imgChildIdx].src = emptyImg.src;
			break;
		} //if found
	} //finding the deselected merchant in the compare table
	//for
};
