var TopOffset = 75;

var LeaveAlertAdditionalOffset = 100;
var IE6 = (navigator.userAgent.toLowerCase().indexOf('msie 6') != -1) && (navigator.userAgent.toLowerCase().indexOf('msie 7') == -1);
var IE = window.addEventListener ? false : true;

var closing = 0;
var dist_screen = 94; // ff ie
var version = 0;

function showAlert(isleaving) {


    version = isleaving == 0 ? 1 : 2;
    var windHeight = getWindowHeight();
    var offset = 75;
    if (version == 2) {
        offset = 580;
    }
    if (IE) {
        offset += 25;
    }
    TopOffset = offset;    
    if (windHeight - offset < 0) {
        TopOffset = 75;
    }
	//var top = getPageScroll() + 50;			

	if(closing == 0)
	{
		closing = 1;
		
		var radio_form = buildContainer(isleaving);

		if(isleaving == 1)
		{
			buildLeaveAlert(radio_form);
		}
		else
		{
			buildFeedbackForm(radio_form);
		}

		moveAlert();
	}

	return;
}

function moveAlert() {

	if(IE6)
	{
		ie6SelectFix('hidden');
	}

	var move;
	
	if(IE)
	{
		move = document.body.clientWidth - 524;
	}
	else
	{
		move = window.outerWidth - 524;
	}
	var div_inside = mint.$('leave_alert');
	div_inside.style.left = (screen.width - dist_screen) + 'px';
	div_inside.style.display = 'none';
	
	mint.fx.Fade("box_overlay", 100, 10, 100);
	//mint.$('box_overlay').appear({ form: 0.0, to: 0.7, queue: 'end', duration: 0.05  });
	mint.fx.Fade("feedback_btn", 0, 10, 100);
	//mint.$('feedback_btn').fade({  queue: 'end', duration: 0.05  });
	mint.fx.Fade("leave_alert", 100, 10, 100);
	mint.$("leave_alert").style.display = 'block';
	//mint.$('leave_alert').appear({ queue: 'end', duration: 0.05  });


	if(IE && !IE6)
	{
	    //mint.$('leave_alert').style.position = 'fixed';
	    if (version==2) {
	        mint.$('leave_alert').style.top = (LeaveAlertAdditionalOffset + TopOffset).toString() + 'px';
	    } else {
	        mint.$('leave_alert').style.top = TopOffset + 'px';
	    }
		
	}
	var top = mint.$('leave_alert').style.top.replace('px','');

	mint.fx.Move("leave_alert", move, top, 10, 100, setIE6expression);	
	//new Effect.Move('leave_alert', { x: move, y: top, mode: 'absolute', queue: 'end', duration: 0.05, afterFinish : setIE6expression });

}

function buildContainer(isLeaving) {
	
	var body = document.body;

	var box = document.createElement('div');
	box.setAttribute('id','box_overlay');
	box.innerHTML = '';

	var pageHeight = getPageHeight();
	box.style.height = pageHeight + 'px';

	var main_cont = document.createElement('div');
	main_cont.setAttribute('id','main_cont');

	var div_inside = document.createElement('div');
	div_inside.setAttribute('id', 'leave_alert');
	if (version == 2) {
	    div_inside.setAttribute('style', 'display:none;top:' + (LeaveAlertAdditionalOffset + TopOffset).toString() + 'px;right:-410px;');
	} else {
	    div_inside.setAttribute('style', 'display:none;top:' + TopOffset + 'px;right:-410px;');
	}

	var black_hole = document.createElement('div');
	black_hole.setAttribute('id','alert_main');

	var main_header = document.createElement('div');
	main_header.setAttribute('id','alert_main_header');

	var exit = document.createElement('div');
	exit.setAttribute('id','leave_exit');
	exit.onclick = function() { close_alert(); }

	main_header.appendChild(exit);
	main_cont.appendChild(main_header);

	var header = document.createElement('div');
	header.setAttribute('id','leave_header');

	if(isLeaving == 1)
	{
		header.className = "before_go";
		header.innerHTML = before_go;
	}
	else
	{
		what_is_your_query;
	}

	var radio_form = document.createElement('form');
	radio_form.setAttribute('id','leave_form');
	radio_form.name = 'leave_form';

	black_hole.appendChild(header);
	
	var zakladka = document.createElement('div');
	zakladka.setAttribute('id','zakladka');
	zakladka.className = 'zakladka';
	zakladka.onclick = function() { close_alert(); }

	black_hole.appendChild(radio_form);

	main_cont.appendChild(black_hole);
	div_inside.appendChild(zakladka);
	div_inside.appendChild(main_cont);
	
	body.appendChild(div_inside);
	
	box.style.display = 'none';
	body.appendChild(box);

	return radio_form;
}

function buildLeaveAlert(radio_form) {

	for(i = 1; i < 10; ++i)
	{
		var answer = document.createElement('div');
		var radio = document.createElement('input');
		var spanik = document.createElement('div');

		radio.setAttribute('type','radio');
		radio.setAttribute('name','why_leave');
		radio.setAttribute('id','why_leave' + i);
		radio.setAttribute('value', i);
		radio.className = 'leave_radio';

		answer.className = 'fdb_label';
		answer.onclick = function(){ hideOthers(this.childNodes[0]);}
		
		var tmp_div;
		var tmp_input;

		if( i == 1 )
		{
			spanik.innerHTML = more_websites;
		}
		if( i == 2 )
		{
			spanik.innerHTML = not_i_look_for;
		}
		if( i == 3 )
		{
			spanik.innerHTML = no_reason;
		}
		if( i == 4 )
		{
			spanik.innerHTML = sth_annoyed;

			spanik.setAttribute('id','span_annoyed');

			tmp_div = document.createElement('div');
			tmp_div.setAttribute('id','plzExplain');
			tmp_div.className = 'leave_span';
			tmp_div.innerHTML = plz_explain;
			tmp_div.style.display = 'none';

			tmp_input = document.createElement('textarea');
			tmp_input.setAttribute('id','ta_explain');
			tmp_input.setAttribute('name','ta_exp');
			tmp_input.className = 'fdb_comment';
			tmp_input.value = comment;
			tmp_input.style.display = 'none';

			tmp_input.onfocus = function() { txtClicked(this,comment); }
			tmp_input.onblur = function() { txtOutClicked(this,comment); }

		}
		if( i == 5 )
		{
			spanik.innerHTML = too_exp;
			spanik.setAttribute('id','span_tooExp');

			tmp_div = document.createElement('div');
			tmp_div.setAttribute('id','say_why');
			tmp_div.className = 'leave_span';
			tmp_div.innerHTML = say_why  + ' <br />';

			tmp_input = document.createElement('textarea');
			tmp_input.setAttribute('id','tarea_sw');
			tmp_input.setAttribute('name','say_why');
			tmp_input.className = 'fdb_comment';
			tmp_input.value = comment;

			tmp_input.onfocus = function() { txtClicked(this,comment); }
			tmp_input.onblur = function() { txtOutClicked(this,comment); }
			
			tmp_div.style.display = 'none';
			tmp_input.style.display = 'none';
		}
		if( i == 6 )
		{
			spanik.innerHTML = nothing_avb;
		}
		if( i == 7 )
		{
			spanik.innerHTML = no_choice;
			//answer.style.border = 'none';
		}
		if( i == 8 )
		{
			spanik.innerHTML = cover_city;
			//answer.style.border = 'none';
		}
		if( i == 9 )
		{
			spanik.innerHTML = hate_popups;
			answer.style.border = 'none';
		}

		answer.appendChild(radio);
		answer.appendChild(spanik);

		if( i == 4 || i == 5 )
		{
			answer.appendChild(tmp_div);
			answer.appendChild(tmp_input);
		}

		radio_form.appendChild(answer);
	}

	var button = document.createElement('div');
	button.setAttribute('id','leave_btn');
	button.innerHTML = submit;

	if(window.addEventListener) { // Mozilla, Netscape, Firefox
		button.addEventListener('click', leaveBtn, false);
	}
	else
	{
		button.attachEvent('onclick', leaveBtn);
	}
	radio_form.appendChild(button);

}

function buildFeedbackForm(radio_form) {
	
	for(i = 1; i < 6; ++i)
	{
		var answer = document.createElement('div');
		var radio = document.createElement('input');
		var div_explain  = document.createElement('div');
		var div_email   = document.createElement('input');
		var div_comment = document.createElement('textarea');

		radio.setAttribute('type','radio');
		radio.setAttribute('name','fdb_form');
		radio.setAttribute('id','fdb_form' + i);
		radio.setAttribute('value', i + 9); // first 9 -> leave alert
		radio.className = 'leave_radio';

		answer.className = 'fdb_label';

		div_explain.className = 'fdb_explain';
		div_explain.setAttribute('id','expl' + i);
		div_explain.style.display = 'none';
		div_explain.setAttribute('type','text');
		div_email.className  = 'fdb_email';
		div_email.setAttribute('name','fdb_email');
		div_email.setAttribute('id','email' + i);
		div_email.value = email;
		div_email.onfocus = function() { txtClicked(this,email); }
		div_email.onblur = function() { txtOutClicked(this,email); }
		div_email.style.display = 'none';
		div_comment.className = 'fdb_comment';
		div_comment.setAttribute('name','fdb_comment');
		div_comment.setAttribute('id','comment' + i);
		div_comment.value = comment;
		div_comment.onblur = function() { txtOutClicked(this,comment); }
		div_comment.onfocus = function() { txtClicked(this,comment); }
		div_comment.style.display = 'none';

		var spanik = document.createElement('div');
		answer.onclick = function(){ hideOthers(this.childNodes[0]);}

		var resid;

		if( i == 1 )
		{
			spanik.innerHTML = report_problem + ' <br />';
			div_explain.innerHTML = explain1;
		}
		if( i == 2 )
		{
			spanik.innerHTML = missing_info + ' <br />';
			div_explain.innerHTML = explain2;
		}
		if( i == 3 )
		{
			spanik.innerHTML = suggestion + ' <br />';
			div_explain.innerHTML = explain3;
		}
		if( i == 4 )
		{
			spanik.innerHTML = booking_dept_qstn + ' <br />';
			spanik.setAttribute('id','span_email');

			var exp_span = document.createElement('span');
			exp_span.innerHTML = explain4;
			exp_span.style.float = 'left';

			resid = document.createElement('input');
			resid.setAttribute('id','resid');
			resid.setAttribute('type','text');
			resid.setAttribute('name','resid');
			resid.className = 'fdb_resid';
			resid.style.display = 'none';
			resid.onfocus =  function() { txtClicked(this,rid)}
			resid.onblur  = function() { txtOutClicked(this,rid); }
			resid.value = rid;
/*
			var resid_y = document.createElement('input');
			resid_y.setAttribute('type','radio');
			resid_y.setAttribute('name','rid');
			resid_y.setAttribute('id','rid_y');
			resid_y.setAttribute('value', '1');
			resid_y.className = 'fdb_res_radio';
			resid_y.onclick = function() { mint.$('resid').appear();}

			var resid_n = document.createElement('input');
			resid_n.setAttribute('type','radio');
			resid_n.setAttribute('name','rid');
			resid_n.setAttribute('id','rid_n');
			resid_n.setAttribute('value', '0');
			resid_n.className = 'fdb_res_radio';
			resid_n.onclick = function() { mint.$('resid').fade();}*/

			var resid_y = newElement("input",{type:"radio",name:"rid",id:"rid_y",value:"1"},{onclick:function(){mint.$('resid').style.display = 'block';}});
			var resid_n = newElement("input",{type:"radio",name:"rid",id:"rid_n",value:"0"},{onclick:function(){mint.$('resid').style.display = 'none';}});
			resid_y.className = 'fdb_res_radio';
			resid_n.className = 'fdb_res_radio';
			
			
			var span_y = document.createElement('label'); 
			span_y.innerHTML = fdb_yes;
			span_y.className = 'fdb_res_span';
			span_y.htmlFor = 'rid_y';
			span_y.style.paddingRight = '15px';
			span_y.onclick = function() { mint.$('resid').style.display = 'block';}
			
			var span_n = document.createElement('label'); 
			span_n.className = 'fdb_res_span';
			span_n.htmlFor = 'rid_n';
			span_n.innerHTML = fdb_no;
			span_n.style.paddingRight = '40px';
			span_n.onclick = function() { mint.$('resid').style.display = 'block'; }

			div_explain.appendChild(exp_span);
			div_explain.appendChild(span_n);
			div_explain.appendChild(resid_n);
			div_explain.appendChild(span_y);
			div_explain.appendChild(resid_y);
		}
		if( i == 5 )
		{
			spanik.innerHTML = cooperation + ' <br />';
			div_explain.innerHTML = '';
			div_explain.style.height = '1px';
			
			answer.style.border = 'none';
		}

		answer.appendChild(radio);
		answer.appendChild(spanik);
		answer.appendChild(div_explain);
		if( i == 4 )
		{
			answer.appendChild(resid);
		}
		answer.appendChild(div_email);
		answer.appendChild(div_comment);
		radio_form.appendChild(answer);
	}

	var button = document.createElement('div');
	button.setAttribute('id','leave_btn');
	button.innerHTML = submit;

	if(window.addEventListener){ // Mozilla, Netscape, Firefox
		button.addEventListener('click', feedBtn, true);
	}
	else
	{
		button.attachEvent('onclick', feedBtn);
	}

	radio_form.appendChild(button);

}

function setIE6expression() {

	if(IE6) {

	    if (version == 2) {
	        mint.$('leave_alert').style.setExpression('top', (LeaveAlertAdditionalOffset + TopOffset).toString() + ' + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) + \'px\' ', 'JScript');  
	    } else {
	        mint.$('leave_alert').style.setExpression('top', TopOffset + ' + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) + \'px\' ', 'JScript');  
	    }
		
	}
}

function txtClicked(txtObject, text) {

	if(txtObject.value == text)
	{
		txtObject.value = '';
		var cName = txtObject.className;
		
		if(!cName.match(/_clicked/))
			txtObject.className = cName + '_clicked';
	}

}

function txtOutClicked(txtObject, text) {

	if(txtObject.value == '')
	{
		txtObject.className = txtObject.className.replace('_clicked', '');
		txtObject.value = text;
	}

}

function hideOthers(radio) {
	var mail_err = mint.$('err_mail') ? true : false;
	if(mail_err)
	{
		mint.$('err_mail').parentNode.removeChild(mint.$('err_mail'));
	}

	var id = radio.id;

	radio.checked = true;	
	
	if( id.match(/why_leave/) )
	{

		for(i = 1; i < 10; ++i)
		{
			if(id != 'why_leave' + i)
			{
				mint.$('why_leave' + i).checked = false;
			}
		}
		
		if( id != 'why_leave4' )
		{
			mint.$('plzExplain').style.display = 'none';
			mint.$('ta_explain').style.display = 'none';
			if( id != 'why_leave5' )
			{
				mint.$('say_why').style.display = 'none';
				mint.$('tarea_sw').style.display = 'none';
			}
		}
		else
		{
			mint.$('plzExplain').style.display='';
			mint.$('ta_explain').style.display='';
		}
		if( id != 'why_leave5' )
		{
			mint.$('say_why').style.display = 'none';
			mint.$('tarea_sw').style.display = 'none';
		}
		else
		{
			mint.$('say_why').style.display='';
			mint.$('tarea_sw').style.display='';
		}

	}
	else
	{
		
		for(i = 1; i < 6; ++i)
		{
			if(id != 'fdb_form' + i)
			{
				mint.$('expl' + i).style.display = 'none';
				mint.$('email' + i ).style.display = 'none';
				mint.$('comment' + i ).style.display = 'none';
				mint.$('fdb_form' + i).checked = false;
			}
			else
			{
			  /*document.getElementById('expl' + i).style.display = 'block';
				document.getElementById('email' + i ).style.display = 'block';
				document.getElementById('comment' + i ).style.display = 'block';*/
				mint.$('expl' + i).style.display='';
				mint.$('email' + i ).style.display='';
				mint.$('comment' + i ).style.display='';
			}
			
			if(id != 'fdb_form4')
			{
				mint.$('resid').style.display = 'none';
				mint.$('rid_y').checked = false;
			}
			
		}
}
}
function getWindowHeight() {
    var windowHeight = 0;
    if (self.innerHeight) {	// all except Explorer
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowHeight = document.body.clientHeight;
    }
    return windowHeight;
}

function getPageHeight() {
	
	var yScroll;
	var windowHeight;
	var pageHeight = 0;
	
	if (window.innerHeight && window.scrollMaxY) {	
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.offsetHeight;
	}

	if (self.innerHeight) {	// all except Explorer
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowHeight = document.body.clientHeight;
	}	

	// for small pages with total height less then height of the viewport

	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	return pageHeight;
}

function leaveBtn() {

	var additionalInfo = '';

	var form = mint.$('leave_form');

	var selected_radio;
	var em;

	for(i = 1; i < 10; ++i)
	{
		if(mint.$('why_leave' + i).checked)
		{
			selected_radio = i;
		}
	}

	if(selected_radio == 4)
	{
		additionalInfo = mint.$('ta_explain').value;
	}	
	if(selected_radio == 5)
	{
		additionalInfo = mint.$('tarea_sw').value;
	}
	if (additionalInfo == comment) {
	    additionalInfo = "";
	}

	additionalInfo = additionalInfo + '<br />Url:' + window.location;

	var answerid = mint.$('why_leave' + selected_radio).value;
	var cookieID = new Date().getTime();
	var cookieValue = "answerid=" + answerid + "&additionalInfo=" + escape(additionalInfo);
	createCookie(cookieID, cookieValue,0);
	var req = mint.Request();
	var url = "/FeedbackFormControler.aspx?id=" + cookieID + "&v=2";
	try {
	    url += "&c=" + JSMAN_CITYID;
	}catch(er){}
	req.Send(url, null);
	mint.$('alert_main').innerHTML = ty_for_feedback;
	mint.$('alert_main').style.textAlign = 'center';
	mint.$('alert_main').style.height = '100px';
	mint.$('alert_main').style.paddingTop = '50px';
	mint.$('alert_main').style.paddingBottom = '50px';
	mint.$('alert_main').style.lineHeight = '90px';
	mint.$('alert_main').style.fontSize = '14pt';

}

function feedBtn() {

	var reservationid = -1;
	var email2    = '';
	var comments = '';

	var form = mint.$('leave_form');

	var selected_radio;
	var em;

	for(i = 1; i < 6; ++i)
	{
		if(mint.$('fdb_form' + i).checked)
		{
		    selected_radio = i;		    
		}
	}
	
	if(selected_radio == 4)
	{
		em = mint.$('email4').value;
		if( !isValidEmail(em) )
		{
			var again = mint.$('err_mail') ? true : false;
			if( !again )
			{
				var spanik = document.createElement('div');
				spanik.className = 'err';
				spanik.setAttribute('id','err_mail');
				spanik.innerHTML = '* ' + wrong_email;
				
				var parent = mint.$('email4').parentNode;
				var ta_com = mint.$('comment4');

				parent.insertBefore(spanik,ta_com);
			}
			return;
		}
		else
		{
			email2 = em;
			comments = mint.$('comment4').value != comment ? mint.$('comment4').value : '';

			if( mint.$('rid_y').checked && parseInt(mint.$('resid').value))
			{
				reservationid = parseInt(mint.$('resid').value);
			}
			else if( mint.$('rid_y').checked )
			{
			    reservationid = -1;
			}
		}
	}
	else
	{
	    email2 = mint.$('email' + selected_radio).value != email ? mint.$('email' + selected_radio).value : '';
	    
	    comments = mint.$('comment' + selected_radio).value != comment ? mint.$('comment' + selected_radio).value : '';
	    
    }
    comments = comments +'<br />Url:' + window.location;

	var answerid = mint.$('fdb_form' + selected_radio).value;
	var cookieID = new Date().getTime();
	var cookieValue = "answerid=" + answerid + "&email=" + escape(email2) + "&comments=" + escape(comments) + "&reservationid=" + reservationid;
	createCookie(cookieID, cookieValue,0);
	var req = mint.Request();
	var url = "/FeedbackFormControler.aspx?id=" + cookieID + "&v=1";
	try{
	    url += "&c=" + JSMAN_CITYID;
	}catch(err){}
	req.Send(url, null);
	mint.$('alert_main').innerHTML = ty_for_feedback;
	mint.$('alert_main').style.textAlign = 'center';
	mint.$('alert_main').style.height = '100px';
	mint.$('alert_main').style.paddingTop = '50px';
	mint.$('alert_main').style.paddingBottom = '50px';
	mint.$('alert_main').style.lineHeight = '90px';
	mint.$('alert_main').style.fontSize = '14pt';

}

function close_alert() {

	var move;

	if(IE)
	{
		move = document.body.clientWidth - dist_screen;
	}
	else
	{
		move = window.outerWidth - dist_screen;
	}

	var top = mint.$('leave_alert').style.top.replace('px','');
	mint.fx.Move("leave_alert", move, top, 10, 100);
	//new Effect.Move('leave_alert', { x: move, y: top, mode: 'absolute', queue: 'end', duration: 0.2 });
	mint.fx.Fade("leave_alert", 0, 10, 100);
	//new Effect.Fade('leave_alert', { queue: 'end', duration: 0.2  });
	if(leaveAlert1 == 1)
	{
	    mint.fx.Fade("feedback_btn", 100, 10, 100);
	    mint.$('feedback_btn').style.display = 'block';
		//new Effect.Appear('feedback_btn', { queue: 'end', duration: 0.2 });
	}
	mint.fx.Fade("box_overlay", 0, 10, 100, null, hideAlert);
	//mint.$('box_overlay').fade({ queue: 'end', duration: 0.2, afterFinish : hideAlert });

}

function hideAlert() {
	var box = document.getElementById('box_overlay');
	var alert_leave = document.getElementById('leave_alert');
	
	document.body.removeChild(box);
	document.body.removeChild(alert_leave);
	closing = 0;
	ie6SelectFix('visible');
}

function getMouseXY(e) {

	var name = "leave_alert";
	if (readCookie("Visit") == null) {
	    return;
	}
	if(readCookie(name) != "1")
	{
		var mouseY;
		if(IE) mouseY = event.clientY;
		else mouseY = e.clientY;

		if(mouseY <= 20)
		{	    
		    showAlert(1);
			createCookie(name, "1",14)
			
		}
	}
}

function readCookie(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;
}

function isValidEmail(strEmail) {

	var validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;

	// search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
    {
      return false;
    } 
    return true; 
}

function ie6SelectFix(newState) {

	var elements = document.documentElement.getElementsByTagName('select');
     
    for (var i=0; i<elements.length; i++) {
		elements[i].style.visibility = newState;
    }

} 

function newElement(type,att,evts,appendToObj){

	var elem;
	if(isNameQuirk() && att.name != null){
	  elem = document.createElement('<' + type + ' name="' + att.name + '">');
	}
	else{
	  elem = document.createElement(type);
	}
   
	for(var prop in att){
	  elem.setAttribute(prop,att[prop]);
	}

	if(evts){
	  for(var evt in evts){
		elem[evt] = evts[evt];
	  }
	}

	if(appendToObj){
	  appendToObj.appendChild(elem);
	}

	return elem;
}

function isNameQuirk(){
	var elem1 = document.createElement("div");
	var elem2 = document.createElement("input");
	elem2.type = "hidden";
	elem2.name = "testName";
	elem1.appendChild(elem2);
	var isQuirk = (elem1.innerHTML.indexOf("test") == -1);
	isNameQuirk = function() {return isQuirk;}
	return isNameQuirk();
}

function TabNewPosition() {
    try {
        var feedback_btn = mint.$('feedback_btn');
        var windowHeight = getWindowHeight() - 80;
        feedback_btn.style.top = windowHeight + 'px'
    } catch (error1) { }
}
function startAlert() {



	if(leaveAlert1 == 1)
	{
		var feedback_btn = document.createElement('span');
		feedback_btn.setAttribute('id','feedback_btn');
		feedback_btn.className = 'feedback_btn';
		feedback_btn.onclick = function() { showAlert(0); }
		feedback_btn.title = fdb_form;
		var windowHeight = getWindowHeight() - 80;
		feedback_btn.style.top = windowHeight+'px';

		document.body.appendChild(feedback_btn);
	}

	if(leaveAlert2 == 1)
	{
		if (!IE) document.captureEvents(Event.MOUSEMOVE);

		if(window.addEventListener) { // Mozilla, Netscape, Firefox
			document.addEventListener('mousemove', getMouseXY, true);
		} else { // IE
			document.attachEvent('onmousemove', getMouseXY);
		}
	}

}
function createCookie(name, value, days) {
    var expires = "";
    if (days > 0) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        expires = "; expires=" + date.toGMTString();
    }
    document.cookie = name + "=" + value + expires + "; path=/";   
}

function scrollEvent() {
    var offset = getScrollXY();
    var scrollOffset = parseInt(offset[1]);   
    var totalOffset = 0;
    if (version == 2) {
        totalOffset = LeaveAlertAdditionalOffset + TopOffset - scrollOffset;
    } else {
        totalOffset = TopOffset - scrollOffset;
    }
    var alertBox =mint.$('leave_alert');
    if (alertBox != null) {
        alertBox.style.top = totalOffset + 'px';
    }
}

AddEvent(window, 'load', startAlert);
AddEvent(window, 'resize', TabNewPosition);
AddEvent(window, 'scroll', scrollEvent);
//Event.observe(window, 'load', startAlert, false);
//Event.observe(window, 'scroll',scrollEvent, false);

function getScrollXY() {
    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 [scrOfX, scrOfY];
}

