
var ms_ad_lang 

	if (ms_ad_lang  == ""  || ms_ad_lang == undefined )
	{
		ms_ad_lang =  "EN";
	} 
 
function saveImpression(JS_host) {
	var w = window
	ad_client = w.ms_ad_client
	
	if(JS_host == undefined){
//	if(true){
		ms_url = "http://www.moveandstay.com/affiliates/tracking.asp?ms_ad_client=" + ad_client
	}else{
		ms_url = JS_host + "affiliates/tracking.asp?ms_ad_client=" + ad_client
	}
	//ms_url = "http://sabaai/moveandstay.com_com/affiliates/tracking.asp?ms_ad_client=" + ad_client

	iframe = "<iframe src=\""+ms_url+"\" width=\"0\" height=\"0\" noresize scrolling=\"no\" hspace=\"0\" vspace=\"0\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>";
	document.write(iframe);
}

function isInteger(s){
	var i;
	if (s.charAt(0) == "-") {
		j = 1;
	} else {
		j = 0;
	}
    for (i = j; i < s.length; i++){
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function quoted(str) {
  return (str != null) ? '"' + str + '"' : '""';
}

function calcHeight() {
	var the_height=document.getElementById('theiframe').contentWindow.document.body.scrollHeight;//find the height of the internal page
	document.getElementById('theiframe').style.height=the_height;//change the height of the iframe
}

function show_listing() {
	var w = window;

	JS_city_id = w.ms_city;
	JS_ms_ad_client = w.ms_ad_client;
	JS_ms_page = w.ms_type;
	JS_ms_property_id = w.ms_property_id;
	JS_ms_lang = w.ms_lang;
	
	if(JS_ms_lang = "undefined"){
		JS_ms_lang = 'en';
	}

	if (w.ms_ad_frameborder != "") {
		ad_frameborder = w.ms_ad_frameborder;
	} else {
		ad_frameborder = "0";
	}

	if (w.ms_ad_scrolling == "no") {
		ad_scrolling = "no";
	} else if (w.ms_ad_scrolling == "yes") {
		ad_scrolling = "yes";
	} else {
		ad_scrolling = "auto";
	}

	if (w.ms_ad_format.search("x") > 0) {
		ad_format = w.ms_ad_format.split("x");

		if (isInteger(ad_format[0]))	{
			ad_width = ad_format[0];
		} else {
			ad_width = "100%";
		}

		if (isInteger(ad_format[1]))	{
			ad_height = ad_format[1];
		} else {
			ad_height = "100%";
		}
	} else {
		ad_width = "100%";
		ad_height = "100%";
	}
	
	
	var hostnameArr = new Array('lang','beta','mstest','matilda','matilda-lang','lisa','lisa-lang','bird','bird-lang');
	var _hostname = document.location.hostname;
	var _hostname_local = "";

	JS_url = "http://www.moveandstay.com/"

	for(var i=0;i<hostnameArr.length;i++){
		//alert(hostnameArr[i].toString());
		if(_hostname.search(hostnameArr[i].toString()) >= 0){
			JS_url = window.location.protocol + "//" + window.location.host + "/";
		}
	}
	
	if(window.location.host == '192.168.1.80'){
		JS_url =  window.location.protocol + "//" + 'matilda-lang' + "/";
	}
	


//	alert(JS_url);
	
	if (JS_ms_page.toUpperCase() != "SA") {
		JS_url = "http://www.moveandstay.fr/"
	}

	var JS_host = JS_url;
	//JS_url = "http://www.moveandstay.com/"
	//JS_url = "http://sabaai/moveandstay.com_com/"
	//JS_url = "http://192.168.0.4/moveandstay.com_com/"
	//JS_url = "http://199.231.131.45/moveandstay.com/"
	//JS_url = "http://huahin/moveandstay.com_com/"

	fullURL = document.URL;
	startIndex = fullURL.lastIndexOf('=');
	endIndex = fullURL.length;
	if (JS_ms_property_id > 0) {
		JS_id = JS_ms_property_id;
	} else {
		JS_id = 0;
		if (startIndex > 0) {
			JS_id = fullURL.substr(startIndex + 1, endIndex);
		}
	}

	if (JS_ms_page.toUpperCase() == "SA") {
//		JS_url += "affiliates/serviced-apartments.php?"
		JS_url += "affiliates/serviced-apartments.asp?"
	} else if (JS_ms_page.toUpperCase() == "SO") {
		JS_url += "affiliates/serviced_offices.asp?"
	} else if (JS_ms_page.toUpperCase() == "SA_DESC") {
		if (JS_id > 0) {
			JS_url += "affiliates/apartments_description.asp?id=" + JS_id + "&";
			ad_height = "800";
		} else {
			JS_url += "affiliates/servicedapartments.asp?"
		}
	} else if (JS_ms_page.toUpperCase() == "SO_DESC") {
		if (JS_id > 0) {
			JS_url += "affiliates/offices_description.asp?id=" + JS_id + "&";
			ad_height = "800";
		} else {
			JS_url += "affiliates/serviced_offices.asp?"
		}
	} else if (JS_ms_page.toUpperCase() == "DEFAULT") {
		JS_url += "affiliates/moveandstay.asp?"
	} else {
		JS_url += "affiliates/servicedapartments.asp?"
	}
	

	if (JS_city_id != "") {
		ms_url = JS_url + "ms_ad_client=" + JS_ms_ad_client + "&city_id=" + JS_city_id+"&lang="+ms_ad_lang;
	} else {
		ms_url = JS_url + "ms_ad_client=" + JS_ms_ad_client + "&city_id=1&lang="+ms_ad_lang;
	}

	if (JS_city_id != "") {
		ms_url = JS_url + "ms_ad_client=" + JS_ms_ad_client + "&city_id=" + JS_city_id+"&lang="+ms_ad_lang;
	} else {
		ms_url = JS_url + "ms_ad_client=" + JS_ms_ad_client + "&city_id=1&lang="+ms_ad_lang;
	}
	
	if(ad_height != "100%"){
		ms_url = ms_url + "&ad_height=" +ad_height;	
	}

	if(ad_width != "100%"){
		ms_url = ms_url + "&ad_width=" +ad_width;	
	}

//	alert(ad_height);

	iframe_tag = '<ifr' + 'ame' +
						' name="theiframe"' +
						' id="theiframe"' +
						' width="' + ad_width + '"' +
						' height="' + ad_height + '"' +
						' frameborder="' + ad_frameborder + '"' +
						' src="' + ms_url + '"' +
						' marginwidth="0"' +
						' marginheight="0"' +
						' vspace="0"' +
						' hspace="0"' +
						' allowtransparency="true"' +
						' scrolling="' + ad_scrolling + '"' +
						' onload="calcHeight();"' +
						'>' +
						'Sorry, your browser does not support iframe technology. Please use Internet explorer 5.5+ or Netscape 6+.' +
						'</ifr' + 'ame>';
	document.write(iframe_tag);
	saveImpression(JS_host);
}
show_listing();
// -->