﻿function utf8(wide) {
  var c, s;
  var enc = "";
  var i = 0;
  while(i<wide.length) {
    c= wide.charCodeAt(i++);
    // handle UTF-16 surrogates
    if (c>=0xDC00 && c<0xE000) continue;
    if (c>=0xD800 && c<0xDC00) {
      if (i>=wide.length) continue;
      s= wide.charCodeAt(i++);
      if (s<0xDC00 || c>=0xDE00) continue;
      c= ((c-0xD800)<<10)+(s-0xDC00)+0x10000;
    }
    // output value
    if (c<0x80) enc += String.fromCharCode(c);
    else if (c<0x800) enc += String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F));
    else if (c<0x10000) enc += String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F));
    else enc += String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F));
  }
  return enc;
}
var hexchars = "0123456789ABCDEF";
function UseTrustConnection(ID1,ID2){
	try
	{
		var obj = document.getElementById(ID1);
		var obj1 = document.getElementById(ID2);
		if(obj.checked == true)
		{
			obj1.style.display = "None";
		}
		else
		{
			obj1.style.display = "Block";
		}
	}
	catch(ex)
	{
		DisplayErrors("ChangeImages", ex.message);
	}
}
function DisplayColumnInView(ID1, ID2){
	try
	{
		var obj = document.getElementById(ID1);
		var obj1 = document.getElementById(ID2);
		if(obj.checked == true)
		{
			obj1.style.display = "Block";
		}
		else
		{
			obj1.style.display = "None";
		}
	}
	catch(ex)
	{
		DisplayErrors("ChangeImages", ex.message);
	}
}
function ShowAndHiddenControl(ID1, ID2, ID3){
	try
	{
		var obj = document.getElementById(ID1);
		var obj1 = document.getElementById(ID2);
		var obj2 = document.getElementById(ID3);
		if(obj.checked == true)
		{
			obj1.style.display = "Block";
			obj2.style.display = "Block";
		}
		else
		{
			obj1.style.display = "None";
			obj2.style.display = "None";
		}
	}
	catch(ex)
	{
		DisplayErrors("ChangeImages", ex.message);
	}
}

function toHex(n) {
  return hexchars.charAt(n>>4)+hexchars.charAt(n & 0xF);
}

var okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";

function encodeURIComponentNew(s) {
  var s = utf8(s);
  var c;
  var enc = "";
  for (var i= 0; i<s.length; i++) {
    if (okURIchars.indexOf(s.charAt(i))==-1)
      enc += "%"+toHex(s.charCodeAt(i));
    else
      enc += s.charAt(i);
  }
  return enc;
}
function Bamboo_Encode(s){
	if (typeof encodeURIComponent == "function") {
		// Use JavaScript built-in function
		// IE 5.5+ and Netscape 6+ and Mozilla
		return encodeURIComponent(s);
	} else {
		// Need to mimic the JavaScript version
		// Netscape 4 and IE 4 and IE 5.0
		return encodeURIComponentNew(s);
	}
}
function Bamboo_AddEvent(obj, evType, fn, useCapture) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, useCapture);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent("on" + evType, fn);
		return r;
	} else {
		alert("Bamboo_AddEvent could not add event!");
	}
}
function Bamboo_GetXMLHttpRequest() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else {
		if (window.Bamboo_XMLHttpRequestProgID) {
			return new ActiveXObject(window.Bamboo_XMLHttpRequestProgID);
		} else {
			var progIDs = ["Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
			for (var i = 0; i < progIDs.length; ++i) {
				var progID = progIDs[i];
				try {
					var x = new ActiveXObject(progID);
					window.Bamboo_XMLHttpRequestProgID = progID;
					return x;
				} catch (e) {
				}
			}
		}
	}
	return null;
}
function Bamboo_CallBack(url, target, id, method, args, clientCallBack, clientCallBackArg, includeControlValuesWithCallBack, updatePageAfterCallBack) {
	if (window.Bamboo_PreCallBack) {
		var preCallBackResult = Bamboo_PreCallBack();
		if (!(typeof preCallBackResult == "then " || preCallBackResult)) {
			if (window.Bamboo_CallBackCancelled) {
				Bamboo_CallBackCancelled();
			}
			return null;
		}
	}
	var x = Bamboo_GetXMLHttpRequest();
	var result = null;
	if (!x) {
		result = { "value": null, "error": "NOXMLHTTP" };
		Bamboo_DebugError(result.error);
		if (window.Bamboo_Error) {
			Bamboo_Error(result);
		}
		if (clientCallBack) {
			clientCallBack(result, clientCallBackArg);
		}
		return result;
	}
	x.open("POST", url ? url : Bamboo_DefaultURL, clientCallBack ? true : false);
	x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
	x.setRequestHeader("Accept-Encoding", "gzip, deflate");
	if (clientCallBack) {
		x.onreadystatechange = function() {
			if (x.readyState != 4) {
				return;
			}
			Bamboo_DebugResponseText(x.responseText);
			result = Bamboo_GetResult(x);
			if (result.error) {
				Bamboo_DebugError(result.error);
				if (window.Bamboo_Error) {
					Bamboo_Error(result);
				}
			}
			if (updatePageAfterCallBack) {
				Bamboo_UpdatePage(result);
			}
			Bamboo_EvalClientSideScript(result);
			clientCallBack(result, clientCallBackArg);
			x = null;
			if (window.Bamboo_PostCallBack) {
				Bamboo_PostCallBack();
			}
		}
	}
    var encodedData = "";
    if (target == "Page") {
        encodedData += "&Bamboo_PageMethod=" + method;
    } else if (target == "MasterPage") {
        encodedData += "&Bamboo_MasterPageMethod=" + method;
    } else if (target == "Control") {
        encodedData += "&Bamboo_ControlID=" + id.split(":").join("_");
        encodedData += "&Bamboo_ControlMethod=" + method;
    }
	if (args) {
		for (var argsIndex = 0; argsIndex < args.length; ++argsIndex) {
			if (args[argsIndex] instanceof Array) {
				for (var i = 0; i < args[argsIndex].length; ++i) {
					encodedData += "&Bamboo_CallBackArgument" + argsIndex + "=" + Bamboo_Encode(args[argsIndex][i]);
				}
			} else {
				encodedData += "&Bamboo_CallBackArgument" + argsIndex + "=" + Bamboo_Encode(args[argsIndex]);
			}
		}
	}
	if (updatePageAfterCallBack) {
		encodedData += "&Bamboo_UpdatePage=true";
	}
	if (includeControlValuesWithCallBack) {
		var form = document.getElementById(Bamboo_FormID);
		if (form != null) {
			for (var elementIndex = 0; elementIndex < form.length; ++elementIndex) {
				var element = form.elements[elementIndex];
				if (element.name) {
					var elementValue = null;
					if (element.nodeName.toUpperCase() == "INPUT") {
						var inputType = element.getAttribute("type").toUpperCase();
						if (inputType == "TEXT" || inputType == "PASSWORD" || inputType == "HIDDEN") {
							elementValue = element.value;
						} else if (inputType == "CHECKBOX" || inputType == "RADIO") {
							if (element.checked) {
								elementValue = element.value;
							}
						}
					} else if (element.nodeName.toUpperCase() == "SELECT") {
						if (element.multiple) {
							elementValue = [];
							for (var i = 0; i < element.length; ++i) {
								if (element.options[i].selected) {
									elementValue.push(element.options[i].value);
								}
							}
						} else if (element.length == 0) {
						    elementValue = null;
						} else {
							elementValue = element.value;
						}
					} else if (element.nodeName.toUpperCase() == "TEXTAREA") {
						elementValue = element.value;
					}
					if (elementValue instanceof Array) {
						for (var i = 0; i < elementValue.length; ++i) {
							encodedData += "&" + element.name + "=" + Bamboo_Encode(elementValue[i]);
						}
					} else if (elementValue != null) {
						encodedData += "&" + element.name + "=" + Bamboo_Encode(elementValue);
					}
				}
			}
			// ASP.NET 1.1 won't fire any events if neither of the following
			// two parameters are not in the request so make sure they're
			// always in the request.
			if (typeof form.__VIEWSTATE == "undefined") {
				encodedData += "&__VIEWSTATE=";
			}
			if (typeof form.__EVENTTARGET == "undefined") {
				encodedData += "&__EVENTTARGET=";
			}
		}
	}
	Bamboo_DebugRequestText(encodedData.split("&").join("\n&"));
	x.send(encodedData);
	if (!clientCallBack) {
		Bamboo_DebugResponseText(x.responseText);
		result = Bamboo_GetResult(x);
		if (result.error) {
			Bamboo_DebugError(result.error);
			if (window.Bamboo_Error) {
				Bamboo_Error(result);
			}
		}
		if (updatePageAfterCallBack) {
			Bamboo_UpdatePage(result);
		}
		Bamboo_EvalClientSideScript(result);
		if (window.Bamboo_PostCallBack) {
			Bamboo_PostCallBack();
		}
	}
	return result;
}
function Bamboo_GetResult(x) {
	var result = { "value": null, "error": null };
	var responseText = x.responseText;
	try {
		result = eval("(" + responseText + ")");
	} catch (e) {
		if (responseText.length == 0) {
			result.error = "NORESPONSE";
		} else {
			result.error = "BADRESPONSE";
			result.responseText = responseText;
		}
	}
	return result;
}
function Bamboo_SetHiddenInputValue(form, name, value) {
    var input = null;
    if (form[name]) {
        input = form[name];
    } else {
        input = document.createElement("input");
        input.setAttribute("name", name);
        input.setAttribute("type", "hidden");
    }
    input.setAttribute("value", value);
    var parentElement = input.parentElement ? input.parentElement : input.parentNode;
    if (parentElement == null) {
        form.appendChild(input);
        form[name] = input;
    }
}
function Bamboo_RemoveHiddenInput(form, name) {
    var input = form[name];
    var parentElement = input.parentElement ? input.parentElement : input.parentNode;
    if (input && parentElement == form) {
        form[name] = null;
        form.removeChild(input);
    }
}
function Bamboo_FireEvent(eventTarget, eventArgument, clientCallBack, clientCallBackArg, includeControlValuesWithCallBack, updatePageAfterCallBack) {
	var form = document.getElementById(Bamboo_FormID);
	Bamboo_SetHiddenInputValue(form, "__EVENTTARGET", eventTarget);
	Bamboo_SetHiddenInputValue(form, "__EVENTARGUMENT", eventArgument);
	Bamboo_CallBack(null, null, null, null, null, clientCallBack, clientCallBackArg, includeControlValuesWithCallBack, updatePageAfterCallBack);
	form.__EVENTTARGET.value = "";
	form.__EVENTARGUMENT.value = "";
}
function Bamboo_UpdatePage(result) {
	var form = document.getElementById(Bamboo_FormID);
	if (result.viewState) {
		Bamboo_SetHiddenInputValue(form, "__VIEWSTATE", result.viewState);
	}
	if (result.viewStateEncrypted) {
		Bamboo_SetHiddenInputValue(form, "__VIEWSTATEENCRYPTED", result.viewStateEncrypted);
	}
	if (result.eventValidation) {
		Bamboo_SetHiddenInputValue(form, "__EVENTVALIDATION", result.eventValidation);
	}
	if (result.controls) {
		for (var controlID in result.controls) {
			var containerID = "Bamboo_" + controlID.split("$").join("_") + "__";
			var control = document.getElementById(containerID);
			if (control) {
				control.innerHTML = result.controls[controlID];
				if (result.controls[controlID] == "") {
					control.style.display = "none";
				} else {
					control.style.display = "block";
				}
			}
		}
	}
	if (result.pagescript) {
	    Bamboo_LoadPageScript(result, 0);
	}
}
// Load each script in order and wait for each one to load before proceeding
function Bamboo_LoadPageScript(result, index) {
    if (index < result.pagescript.length) {
		try {
		    var script = document.createElement('script');
		    script.type = 'text/javascript';
		    if (result.pagescript[index].indexOf('src=') == 0) {
		        script.src = result.pagescript[index].substring(4);
		    } else {
		        if (script.canHaveChildren ) {
		            script.appendChild(document.createTextNode(result.pagescript[index]));
		        } else {
		            script.text = result.pagescript[index];
		        }
		    }
	        document.getElementsByTagName('head')[0].appendChild(script);
	        if (typeof script.readyState != "undefined") {
	            script.onreadystatechange = function() {
	                if (script.readyState != "complete" && script.readyState != "loaded") {
	                    return;
	                } else {
	                    Bamboo_LoadPageScript(result, index + 1);
	                }
	            }
	        } else {
                Bamboo_LoadPageScript(result, index + 1);
	        }
		} catch (e) {
		    Bamboo_DebugError("Error adding page script to head. " + e.name + ": " + e.message);
		}
	}
}
function Bamboo_EvalClientSideScript(result) {
	if (result.script) {
		for (var i = 0; i < result.script.length; ++i) {
			try {
				eval(result.script[i]);
			} catch (e) {
				alert("Error evaluating client-side script!\n\nScript: " + result.script[i] + "\n\nException: " + e);
			}
		}
	}
}
function Bamboo_DebugRequestText(text) {
}

function Bamboo_DebugResponseText(text) {
}

function Bamboo_DebugError(text) {
}
//Fix for bug #1429412, "Reponse callback returns previous response after file push".
//see http://sourceforge.net/tracker/index.php?func=detail&aid=1429412&group_id=151897&atid=782464
function Bamboo_Clear__EVENTTARGET() {
	var form = document.getElementById(Bamboo_FormID);
	Bamboo_SetHiddenInputValue(form, "__EVENTTARGET", "");
}
function Bamboo_InvokePageMethod(methodName, args, clientCallBack, clientCallBackArg) {
	Bamboo_Clear__EVENTTARGET(); // fix for bug #1429412
    return Bamboo_CallBack(null, "Page", null, methodName, args, clientCallBack, clientCallBackArg, true, true);
}
function Bamboo_InvokeMasterPageMethod(methodName, args, clientCallBack, clientCallBackArg) {
	Bamboo_Clear__EVENTTARGET(); // fix for bug #1429412
    return Bamboo_CallBack(null, "MasterPage", null, methodName, args, clientCallBack, clientCallBackArg, true, true);
}
function Bamboo_InvokeControlMethod(id, methodName, args, clientCallBack, clientCallBackArg) {
	Bamboo_Clear__EVENTTARGET(); // fix for bug #1429412
    return Bamboo_CallBack(null, "Control", id, methodName, args, clientCallBack, clientCallBackArg, true, true);
}
function Bamboo_PreProcessCallBack(
    control,
    e,
    eventTarget,
    causesValidation, 
    validationGroup, 
    imageUrlDuringCallBack, 
    textDuringCallBack, 
    enabledDuringCallBack,
    preCallBackFunction,
    callBackCancelledFunction,
    preProcessOut
) {
	preProcessOut.Enabled = !control.disabled;
	var preCallBackResult = true;
	if (preCallBackFunction) {
		preCallBackResult = preCallBackFunction(control);
	}
	if (typeof preCallBackResult == "undefined" || preCallBackResult) {
		var valid = true;
		if (causesValidation && typeof Page_ClientValidate == "function") {
			valid = Page_ClientValidate(validationGroup);
		}
		if (valid) {
			var inputType = control.getAttribute("type");
			inputType = (inputType == null) ? '' : inputType.toUpperCase();
			if (inputType == "IMAGE" && e != null) {
                var form = document.getElementById(Bamboo_FormID);
                if (e.offsetX) {
                    Bamboo_SetHiddenInputValue(form, eventTarget + ".x", e.offsetX);
                    Bamboo_SetHiddenInputValue(form, eventTarget + ".y", e.offsetY);
                } else {
                    Bamboo_SetHiddenInputValue(form, eventTarget + ".x", e.clientX - control.offsetLeft + 1);
                    Bamboo_SetHiddenInputValue(form, eventTarget + ".y", e.clientY - control.offsetTop + 1);
                }
			}
			preProcessOut.OriginalText = control.innerHTML;
			if (imageUrlDuringCallBack || textDuringCallBack) {
			    if (control.nodeName.toUpperCase() == "INPUT") {
			        if (inputType == "CHECKBOX" || inputType == "RADIO" || inputType == "TEXT") {
			            preProcessOut.OriginalText = GetLabelText(control.id);
			            SetLabelText(control.id, textDuringCallBack);
			        } else if (inputType == "IMAGE") {
			            if (imageUrlDuringCallBack) {
			                preProcessOut.OriginalText = control.src;
			                control.src = imageUrlDuringCallBack;
			            } else {
			                preProcessOut.ParentElement = control.parentElement ? control.parentElement : control.parentNode;
			                if (preProcessOut.ParentElement) {
			                    preProcessOut.OriginalText = preProcessOut.ParentElement.innerHTML;
			                    preProcessOut.ParentElement.innerHTML = textDuringCallBack;
			                }
			            }
			        } else if (inputType == "SUBMIT") {
			            preProcessOut.OriginalText = control.value;
			            control.value = textDuringCallBack;
			        }
			    } else if (control.nodeName.toUpperCase() == "SELECT") {
			        preProcessOut.OriginalText = GetLabelText(control.id);
			        SetLabelText(control.id, textDuringCallBack);
			    } else {
				    control.innerHTML = textDuringCallBack;
				}
			}
			control.disabled = (typeof enabledDuringCallBack == "undefined") ? false : !enabledDuringCallBack;
			return true;
        } else {
            return false;
        }
	} else {
	    if (callBackCancelledFunction) {
		    callBackCancelledFunction(control);
		}
		return false;
	}
}
function Bamboo_PreProcessCallBackOut() {
    // Fields
    this.ParentElement = null;
    this.OriginalText = '';
    this.Enabled = true;
}
function Bamboo_PostProcessCallBack(
    result, 
    control,
    eventTarget, 
    clientCallBack, 
    clientCallBackArg, 
    imageUrlDuringCallBack, 
    textDuringCallBack, 
    postCallBackFunction, 
    preProcessOut
) {
    if (postCallBackFunction) {
        postCallBackFunction(control);
    }
	control.disabled = !preProcessOut.Enabled;
    var inputType = control.getAttribute("type");
    inputType = (inputType == null) ? '' : inputType.toUpperCase();
	if (inputType == "IMAGE") {
	    var form = document.getElementById(Bamboo_FormID);
        Bamboo_RemoveHiddenInput(form, eventTarget + ".x");
        Bamboo_RemoveHiddenInput(form, eventTarget + ".y");
	}
	if (imageUrlDuringCallBack || textDuringCallBack) {
	    if (control.nodeName.toUpperCase() == "INPUT") {
	        if (inputType == "CHECKBOX" || inputType == "RADIO" || inputType == "TEXT") {
	            SetLabelText(control.id, preProcessOut.OriginalText);
	        } else if (inputType == "IMAGE") {
	            if (imageUrlDuringCallBack) {
	                control.src = preProcessOut.OriginalText;
	            } else {
	                preProcessOut.ParentElement.innerHTML = preProcessOut.OriginalText;
	            }
	        } else if (inputType == "SUBMIT") {
	            control.value = preProcessOut.OriginalText;
	        }
	    } else if (control.nodeName.toUpperCase() == "SELECT") {
	        SetLabelText(control.id, preProcessOut.OriginalText);
	    } else {
	        control.innerHTML = preProcessOut.OriginalText;
	    }
	}
	if (clientCallBack) {
	    clientCallBack(result, clientCallBackArg);
	}
}
function Bamboo_FireCallBackEvent(
	control,
	e,
	eventTarget,
	eventArgument,
	causesValidation,
	validationGroup,
	imageUrlDuringCallBack,
	textDuringCallBack,
	enabledDuringCallBack,
	preCallBackFunction,
	postCallBackFunction,
	callBackCancelledFunction,
	includeControlValuesWithCallBack,
	updatePageAfterCallBack
) {
    if (control.type == "radio") {
	    Bamboo_GetValueControl(control.id);
    }
	var preProcessOut = new Bamboo_PreProcessCallBackOut();
	var preProcessResult = Bamboo_PreProcessCallBack(
	    control, 
	    e, 
	    eventTarget,
	    causesValidation, 
	    validationGroup, 
	    imageUrlDuringCallBack, 
	    textDuringCallBack, 
	    enabledDuringCallBack, 
	    preCallBackFunction, 
	    callBackCancelledFunction, 
	    preProcessOut
	);
    if (preProcessResult) {
	    Bamboo_FireEvent(
		    eventTarget,
		    eventArgument,
		    function(result) {
                Bamboo_PostProcessCallBack(
                    result, 
                    control, 
                    eventTarget,
                    null, 
                    null, 
                    imageUrlDuringCallBack, 
                    textDuringCallBack, 
                    postCallBackFunction, 
                    preProcessOut
                );
		    },
		    null,
		    includeControlValuesWithCallBack,
		    updatePageAfterCallBack
	    );
    }
}
function BambooListControl_OnClick(
    e,
	causesValidation,
	validationGroup,
	textDuringCallBack,
	enabledDuringCallBack,
	preCallBackFunction,
	postCallBackFunction,
	callBackCancelledFunction,
	includeControlValuesWithCallBack,
	updatePageAfterCallBack
) {
	var target = e.target || e.srcElement;
	if (target.nodeName.toUpperCase() == "LABEL" && target.htmlFor != '')
	    return;
	var eventTarget = target.id.split("_").join("$");
	Bamboo_FireCallBackEvent(
	    target, 
	    e,
	    eventTarget, 
	    '', 
	    causesValidation, 
	    validationGroup, 
	    '',
	    textDuringCallBack, 
	    enabledDuringCallBack, 
	    preCallBackFunction, 
	    postCallBackFunction, 
	    callBackCancelledFunction, 
	    true, 
	    true
	);
}

function GetLabelText(id) {
    var labels = document.getElementsByTagName('label');
    for (var i = 0; i < labels.length; i++) {
        if (labels[i].htmlFor == id) {
            return labels[i].innerHTML;
        }
    }
    return null;
}
function SetLabelText(id, text) {
    var labels = document.getElementsByTagName('label');
    for (var i = 0; i < labels.length; i++) {
        if (labels[i].htmlFor == id) {
            labels[i].innerHTML = text;
            return;
        }
    }
}
function Bamboo_SetCursor(){
	document.body.style.cursor="wait"; 
}
function Bamboo_RemoveCursor(){
	document.body.style.cursor = "auto"; 
}

/* AJAX object */

 function GetXmlHttp()
 {
    var xmlhttp = false;
    if (window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest()
    }
    else if (window.ActiveXObject)
    {
        try
        {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
        } 
        catch (e) 
        {
            try
            {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
            } catch (E) 
            {
                xmlhttp = false;
            }
        }
    }
    return xmlhttp;
 }
 
            
/* Sending error */
function SendErrorScript(address)
{
    var xmlhttp =  GetXmlHttp();
    var ctl00_m_g_8bd8af26_6979_417f_ab2e_f8be0db106b3MapurlError =  '&report=error&message=' + address; 
    if (xmlhttp) {
        xmlhttp.open("POST",window.location.href, true );
        xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
        xmlhttp.setRequestHeader("Accept-Encoding", "gzip, deflate");
        xmlhttp.send(ctl00_m_g_8bd8af26_6979_417f_ab2e_f8be0db106b3MapurlError);
    }
}

///////////////////--Bamboo G Map View for other countries--////////////////////////
var countryNames = new Array();
countryNames[0] = 'uk'; countryNames[1] = 'united kingdom'; countryNames[2] = 'england'; countryNames[3] = 'britain';countryNames[4] = 'china';
var isMapNull = false;

function CheckCountryNames(country){
	var flagCountry = false;
	
	for (var i = 0; i < countryNames.length; i++)
	{
		if (country.toLowerCase() == countryNames[i])
		{	
			flagCountry = true;
			break;	
		}
	}
	return flagCountry;
}
function GetPostCode(arrayAddress, stringName){
	var arr = arrayAddress.split(";=;");
	var resultString = "";		
	switch (stringName)
	{
		case "address": 
		{	
			resultString = arr[0] + ', ' + arr[1] + ', ' + arr[3];
			break;
		}
		case "citycountry": 
		{
			resultString = arr[1] + ', ' + arr[3];
			break;
		}
		case "country": 
		{
			resultString = arr[3];
			break;
		}
		default : break;
	}	
	return resultString;
}
function ShowAddressForOtherCountries(mapID, arrayAdress, markID, flag, idCSS, CallbackFunction) { 
	try
	{
	  //alert("ShowAddressForOtherCountries:: " + eval(mapID + "MyCountAddress"));
		var postCode = GetPostCode(arrayAdress, "address");
	 	var localSearch = new GlocalSearch();
	 	localSearch.setSearchCompleteCallback(null, function() {
	   		if (localSearch.results[0])
	   		{  
	    		var resultLat = localSearch.results[0].lat;
	    		var resultLng = localSearch.results[0].lng;
	    		var point = new GLatLng(resultLat, resultLng);
	    		CallbackFunction(mapID, point, arrayAdress, markID, flag, idCSS);			  
	   		}
	   		else
	   		{
	   	 		ShowCityCountryForOtherCountries(mapID, localSearch, arrayAdress, markID, flag, idCSS, CallbackFunction);
	   		}
	  	}); 
	 
	 	localSearch.execute(postCode);
 	}
 	catch(ex)
 	{
 	    DisplayErrors("ShowAddressForOtherCountries::", ex.message);
 	}
}
function ShowCityCountryForOtherCountries(mapID, localSearch, arrayAdress, markID, flag, idCSS, CallbackFunction) { 
	try
	{
		var postCode = GetPostCode(arrayAdress, "citycountry");
	 	localSearch.setSearchCompleteCallback(null, function() {
	   		if (localSearch.results[0])
	   		{  
	    		var resultLat = localSearch.results[0].lat;
	    		var resultLng = localSearch.results[0].lng;
	    		var point = new GLatLng(resultLat, resultLng);
	    		CallbackFunction(mapID, point, arrayAdress, markID, flag, idCSS);			  
	   		}
	   		else
	   		{
	   	 		ShowCountryForOtherCountries(mapID, localSearch, arrayAdress, markID, flag, idCSS, CallbackFunction);
	   		}
	  	}); 	 
	 	localSearch.execute(postCode);
	}
	catch(ex)
	{
	    DisplayErrors("ShowCityCountryForOtherCountries::", ex.message);
	}
}
function ShowCountryForOtherCountries(mapID, localSearch, arrayAdress, markID, flag, idCSS, CallbackFunction) { 
	try
	{
		var postCode = GetPostCode(arrayAdress, "country");	 
		
	 	localSearch.setSearchCompleteCallback(null, function() {
	   		if (localSearch.results[0])
	   		{  
	    		var resultLat = localSearch.results[0].lat;
	    		var resultLng = localSearch.results[0].lng;  		
	    		var point = new GLatLng(resultLat, resultLng);
	    		
	    		CallbackFunction(mapID, point, arrayAdress, markID, flag, idCSS);			  
	   		}
	   		else
	   		{
	   		    //alert(postCode + " not found");
	   		}
	  	}); 	 
	 	localSearch.execute(postCode);
	}
	catch(ex)
	{
	    DisplayErrors("ShowCountryForOtherCountries::", ex.message);
	}
}
function PlaceMarkerAtPoint(mapID, point, arrayAdress, markID, flag, idCSS){
	try
	{
	  
	    map = eval(mapID);
	    if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
	  
		var arr = arrayAdress.split(";=;");
		var markerLocation = arr[(arr.length - 3)];
		var markerWidth = arr[(arr.length - 2)];
		var markerHeight = arr[(arr.length - 1)];
		icons = CreateIcon(markerLocation, markerWidth, markerHeight);		
		
		var marker = new GMarker(point, icons);
		marker.Id = markID;
		marker.Title = arrayAdress;		
		
		if (!flagSetCenter)
		{
		    if (typeof map.setCenter == "function")
		    {
			    map.setCenter(point, parseInt(zoomLevel, 0));
			    flagSetCenter = true;
			}
		}	
	  
	  eval(mapID + "MyCountAddress++");
	  
	  var loadingPage = document.getElementById(mapID.substring(0, mapID.length - 3) + "_loadingPage");
        if (loadingPage && eval(mapID + "MyCountAddress <= " + mapID + "ItemsOnPage"))
        {
          loadingPage.style.display = "";
          loadingPage.innerHTML = eval("loadingMarker_" + mapID) + " " + eval(mapID + "MyCountAddress") + " " + eval("ofMarker_"+ mapID) + " " + eval(mapID + "ItemsOnPage") + " ...";
        }
    	      
		OpenInfoWindowTabsForOtherCountries(mapID, arrayAdress, marker, idCSS);
		
		//var totalItems = map.getOverlays().length;
		//if (flag == totalItems)	SetMapBestZoom(mapID);
		
		if (eval(mapID + "MyCountAddress >= " + mapID + "ItemsOnPage"))
		{
		  //if (loadingPage)
		  //{
		  //  setTimeout(function() { loadingPage.style.display = "none"; }, 2000);
		  //  eval(mapID + "MyCountAddress = 0;");
		  //}
		  SendReport( mapID );
		}	
		
	}
	catch(ex)
	{
	    DisplayErrors("PlaceMarkerAtPoint::", ex.message);
	}
}
function OpenInfoWindowTabsForOtherCountries(mapID, arrayAdress, marker, idCSS){
	try
	{
		var styles = document.getElementsByTagName("STYLE");
		var extract = extractStyleSheet( styles ,  '.VirtualMapViewInfoBox-'+idCSS);
		
	    map = eval(mapID);
	    if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
	    var gTabTitles = fixArray(eval(mapID + "GTabTitles"));
	    var arrayTabs = fixArray(eval(mapID + "ArrayTabs"));
		var arr = arrayAdress.split(";=;");
		var htm = new Array();
	  	var n = 4;  	
	  	for (var j = 0; j < gTabTitles.length; j++)
	  	{
	  		var contenTab = arrayTabs[j].split(";@#@;");
		  	htm[j]  = "<table class='VirtualMapViewInfoWindowTabs-" + idCSS + "'>";
		  	for (var i = 0; i < contenTab.length; i++)
		  	{
		  		if (contenTab[i] != '')
		  		{
					htm[j] += "<tr><td style='"+extract.styleSheet+"' "+(extract.noWrap ? "nowrap='true'" : "")+">" + contenTab[i] + ":</td><td style='"+extract.styleSheet+"' "+(extract.noWrap ? "nowrap='true'" : "")+">" + CheckURL(Trim(arr[n])) + "</td></tr>";
		  	 		n++;	
		  		}
		  	}
		  	htm[j] += "</table>";
	  	}
		var infoTabs = null;
		if ((gTabTitles.length == 0) || (gTabTitles.length == 1))
		{		
			infoTabs = [new GInfoWindowTab(gTabTitles[0], htm[0])];
		}
		if (gTabTitles.length == 2)
		{
			infoTabs = [new GInfoWindowTab(gTabTitles[0], htm[0]), new GInfoWindowTab(gTabTitles[1], htm[1])];
		}
		if (gTabTitles.length == 3)
		{
			infoTabs = [new GInfoWindowTab(gTabTitles[0], htm[0]), new GInfoWindowTab(gTabTitles[1], htm[1]),
						new GInfoWindowTab(gTabTitles[2], htm[2])];				
		}
		GEvent.addListener(marker, "click", function() {
		  marker.openInfoWindowTabsHtml(infoTabs,{maxWidth:300});
		});
		map.addOverlay(marker);
	}
	catch(ex)
	{
	    DisplayErrors("OpenInfoWindowTabsForOtherCountries::", ex.message);
	}
}
///////////////////--Bamboo G Map View --////////////////////////
var icons; var arrAddr = new Array();
var iNode = new Array();
	iNode[0] = new Array();	iNode[0][0] = "http://www.google.com/mapfiles/marker.png"; 
  	iNode[0][1] = 32; iNode[0][2] = 32; 	
var flagSetCenter = false; var mapIsLoad = false; var arrayTabs = new Array(); 

function fixArray(src)
{
    var re = "";
    var s = src.split(";#;|");
    for(var i = 0; i < s.length; i++)
    {
        if (s[i].length == 0 || s[i] == '')
        {
        }
        else
        {
            re += s[i] + ";#;|";
        }
    }
    return re;
}
function GetNumberOfTabs(tViewField, tabTitles){
	try
	{
		tViewField = unescape(tViewField.toString());
	    
	    var gTabTitles = new Array();
		var arrayFieldTemp = tViewField.split(";#;|");
		
		var arrayTabTemp = tabTitles.split(";#;|");
		
		return tabTitles.split(";#;|");
	}
	catch(ex)
	{
	    DisplayErrors("GetNumberOfTabs::", ex.message);
	}
}
/////////////////---Send error report ---///////////////////////////////////////////////
function SendReport(mapID)
{
    map = eval(mapID);
    if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
	  
    var loadingPage = document.getElementById(mapID.substring(0, mapID.length - 3) + "_loadingPage");
    if (loadingPage) {
	    if (typeof map.getOverlays == 'function' && map.getOverlays().length == eval(mapID + "ItemsOnPage"))
	    {
	      SetMapBestZoom(mapID);
	      setTimeout(function() { loadingPage.style.display = "none";   }, 2000);
	    }
	    else {
	      setTimeout(function() { loadingPage.style.display = "none";  SetMapBestZoom(mapID); }, 2000);
	    }
	    //eval(mapID + "MyCountAddress = 0;");
	  }
	  //send report
	  
	  if (eval(mapID + "MyErrorAddress") != "") {
	    SendErrorScript(eval(mapID + "MyErrorAddress"));
	  }
}   
function OnLoadMarkerByAddress(mapID, arrayAddress, markID, flag, idCSS){
 	try
	{
		if (mapID != null)
		{
			if (arrayAddress == '')
			{
				//map.setCenter(new GLatLng(34, 0), 2);
				alert(eval("AddressNull_" + mapID));
			}
			else
			{
				if (markID != '')
				{
				    //alert(markID);
				    //document.getElementById("mmm").value += markID + "\n";  
                    //debugger;
				    var arrayCountries = arrayAddress.split(";=;");
				    var country = arrayCountries[3].toLowerCase();
					if (CheckCountryNames(country))
			            ShowAddressForOtherCountries(mapID, arrayAddress, markID, flag, idCSS, PlaceMarkerAtPoint);
					else
						ShowAddress(mapID, arrayAddress, markID, flag, idCSS);
		        }
	   	    }
        }
	}
	catch(ex)
	{
	    DisplayErrors("OnLoadMarkerByAddress::", ex.message);
	}
}

function CreateIcon(markerLocation, markerWidth, markerHeight) {
    var icon = new GIcon();
    icon.image = markerLocation;
    //icon.iconSize = new GSize(markerWidth, markerHeight);
    icon.iconAnchor = new GPoint(6, 20);
    icon.infoWindowAnchor = new GPoint(10, 20);
	return icon; 
} 

/* My customize style sheet */
function extractStyleSheet( styleElements, className) {
	var ret = new Object();
	ret.styleSheet = "";
	ret.noWrap = false;
	
	var endIndex, startIndex, arr, pair, tmp;
	
	for( var elem = 0; elem < styleElements.length; elem++) {
		var styleContent = styleElements[elem].innerHTML;
		startIndex = styleContent.indexOf(className);
		
		if (startIndex >= 0) {
			tmp = styleContent.substring(startIndex+className.length+1);
			tmp = tmp.replace('{','');
		
			endIndex = tmp.indexOf('}');
			ret.styleSheet = tmp.substring(0, endIndex);
			
			arr = ret.styleSheet.split(';');
			for( var j = 0; j < arr.length; j++) {
				pair = arr[j].split(':');
				pair[0] = Trim(pair[0].toLowerCase());
				if (pair.length==2) 
				{ 
					pair[1] = Trim(pair[1].toLowerCase());
					if ((pair[0]=="white-space" && pair[1].indexOf('nowrap')>=0) ||
						(pair[0]=="nowrap" && pair[1]=="true"))
						ret.noWrap = true;
				}
			}
		}
	}
	return ret;
}

function fixArray(src)
{
    var s = "";
    for(var i = 0; i < src.length; i++)
    {
        if (Trim(src[i]) != '')
        {
            s += (s.length > 0 ? ";#;" : "") + src[i];
        }
    }
    return s.split(";#;");
}

function OpenInfoWindowTabs(mapID, fullAddress, marker, condition, markerIsAdded, idCSS){
	try
	{
		var styles = document.getElementsByTagName("STYLE");
		var extract = extractStyleSheet( styles ,  '.VirtualMapViewInfoBox-'+idCSS);
				
	    map = eval(mapID);
	    if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
	    
	    var arrayTabs = fixArray(eval(mapID + "ArrayTabs"));
	    var gTabTitles = fixArray(eval(mapID + "GTabTitles"));
	        
		if (condition == 'address')
		{
		    
			var arr = fullAddress.split(";=;");
			var htm = new Array();
		  	var n = 4;
		  			  	
		  	for (var j = 0; j < gTabTitles.length; j++)
		  	{
		  	    if (gTabTitles[j] != '')
		  	    {
		  		    var contenTab = arrayTabs[j].split(";@#@;");
			  	    htm[j]  = "<table class='VirtualMapViewInfoWindowTabs-" + idCSS + "'>";
			  	    for (var i = 0; i < contenTab.length; i++)
			  	    {
			  		    if (contenTab[i] != '')
			  		    {
			  			    htm[j] += "<tr><td style='"+extract.styleSheet+"' "+(extract.noWrap ? "nowrap='true'" : "")+">" + contenTab[i] + ":</td><td style='"+extract.styleSheet+"' "+(extract.noWrap ? "nowrap='true'" : "")+">" + CheckURL(Trim(arr[n])) + "</td></tr>";
			  	 		    n++;	
			  		    }
			  	    }
			  	    htm[j] += "</table>";
			  	}
		  	}
			var infoTabs = null;
			if ((gTabTitles.length == 0) || (gTabTitles.length == 1))
			{		
				infoTabs = [new GInfoWindowTab(gTabTitles[0], htm[0])];
			}
			if (gTabTitles.length == 2)
			{
				infoTabs = [new GInfoWindowTab(gTabTitles[0], htm[0]), new GInfoWindowTab(gTabTitles[1], htm[1])];
			}
			if (gTabTitles.length == 3)
			{
				infoTabs = [new GInfoWindowTab(gTabTitles[0], htm[0]), new GInfoWindowTab(gTabTitles[1], htm[1]),
							new GInfoWindowTab(gTabTitles[2], htm[2])];				
			}
			if (!markerIsAdded)
			{
				GEvent.addListener(marker, "click", function() {
				  marker.openInfoWindowTabsHtml(infoTabs,{maxWidth:300});				  
				});
				map.addOverlay(marker);
			}
			else
			{
				marker.openInfoWindowTabsHtml(infoTabs,{maxWidth:300});
			}
		}
		else
		{
			var arr = fullAddress.split(";=;");
			var htm = new Array();
		  	var n = 3;
		  	for (var j = 0; j < gTabTitles.length; j++)
		  	{
		  		var contenTab = arrayTabs[j].split(";@#@;");
			  	htm[j]  = "<table class='VirtualMapViewInfoWindowTabs-" + idCSS + "'>";
			  	for (var i = 0; i < contenTab.length; i++)
			  	{
			  		if (contenTab[i] != '')
			  		{
						htm[j] += "<tr><td style='"+extract.styleSheet+"' "+(extract.noWrap ? "nowrap='true'" : "")+">" + contenTab[i] + ":</td><td style='"+extract.styleSheet+"' "+(extract.noWrap ? "nowrap='true'" : "")+">" + CheckURL(Trim(arr[n])) + "</td></tr>";
			  	 		n++;	
			  		}
			  	}	  
			  	htm[j] += "</table>";
		  	}
			var infoTabs = null;
			if ((gTabTitles.length == 0) || (gTabTitles.length == 1))
			{		
				infoTabs = [new GInfoWindowTab(gTabTitles[0], htm[0])];
			}
			if (gTabTitles.length == 2)
			{
				infoTabs = [new GInfoWindowTab(gTabTitles[0], htm[0]), new GInfoWindowTab(gTabTitles[1], htm[1])];
			}
			if (gTabTitles.length == 3)
			{
				infoTabs = [new GInfoWindowTab(gTabTitles[0], htm[0]), new GInfoWindowTab(gTabTitles[1], htm[1]),
							new GInfoWindowTab(gTabTitles[2], htm[2])];				
			}
				
			if (!markerIsAdded)
			{
				GEvent.addListener(marker, "click", function() {
				  marker.openInfoWindowTabsHtml(infoTabs,{maxWidth:300});
				});
				map.addOverlay(marker);
			}
			else
			{
				marker.openInfoWindowTabsHtml(infoTabs,{maxWidth:300});
			}
		}
	}
	catch(ex)
	{
	    DisplayErrors("OpenInfoWindowTabs::", ex.message);
	}
}

/////////////////---According to the Address, the City, the State and the Country to display marker---///////////////////////

function ShowAddress(mapID, fullAddress, markID, flag, idCSS) {
	try
	{
	  //alert("ShowAddress:: " + eval(mapID + "MyCountAddress"));
	  map = eval(mapID);
	  if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
	  
	  var geocoder = eval(mapID + "Geocoder");	    
		if (geocoder) 
		{
			var arr = fullAddress.split(";=;");			
			var fullAddr = FixAddressText(arr[0]) + ' ' + arr[1] + ' ' + arr[2] + ' ' + arr[3];
			var markerLocation = arr[(arr.length - 3)];
			var markerWidth = arr[(arr.length - 2)];
			var markerHeight = arr[(arr.length - 1)];			
			
			geocoder.getLatLng(fullAddr, function(point) {
			if (!point) 
			{
			    ShowCityStateCountry(mapID, fullAddress, markID, flag, idCSS);        
			} 
			else 
			{
			    if (!flagSetCenter)
				{
				    if (typeof map.setCenter == "function")
				    {
			            map.setCenter(point, parseInt(zoomLevel, 0));
			      	    flagSetCenter = true;
			      	}
			    }
			    
			    //alert(markID);
				//document.getElementById("mmm").value += markID + ":: ShowAddress :: " + eval(mapID + "MyCountAddress") + "::" +  fullAddr + "\n";  
				  
			    icons = CreateIcon(markerLocation, markerWidth, markerHeight);
			    eval(mapID + "MyCountAddress++");
			    
			    var marker = new GMarker(point, icons);
				marker.Id = markID;
				marker.Title = fullAddress;
				 
				var loadingPage = document.getElementById(mapID.substring(0, mapID.length - 3) + "_loadingPage");
                if (loadingPage && eval(mapID + "MyCountAddress <= " + mapID + "ItemsOnPage"))
                {
                    loadingPage.style.display = "";
                    loadingPage.innerHTML = eval("loadingMarker_" + mapID) + " " + eval(mapID + "MyCountAddress") + " " + eval("ofMarker_" + mapID ) + " " +  eval(mapID + "ItemsOnPage") + " ...";
                }
          
				OpenInfoWindowTabs(mapID, fullAddress, marker, 'address', false, idCSS);
				  
				if (eval(mapID + "MyCountAddress >= " + mapID + "ItemsOnPage"))
				{
				    SendReport( mapID );
				}
								  
			 }
		   });
		}
		
    }
    catch(ex)
    {
        DisplayErrors("ShowAddress::", ex.message);
    }
}
 
/////////////////---According to the City, the State and the Country to display marker---///////////////////////

function ShowCityStateCountry(mapID, cityStateCountry, markID, flag, idCSS) {
	try
	{	
	  map = eval(mapID);
	  if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
	  
	  var geocoder = eval(mapID + "Geocoder");
		if (geocoder) 
		{
			var arr = cityStateCountry.split(";=;");
			fullAddr = arr[1] + ' ' + arr[2] + ' ' + arr[3];
			var markerLocation = arr[(arr.length - 3)];
			var markerWidth = arr[(arr.length - 2)];
			var markerHeight = arr[(arr.length - 1)];			
			geocoder.getLatLng(fullAddr, function(point) {
			if (!point) 
			{
			    ShowCityCountry(mapID, cityStateCountry, markID, flag, idCSS);
			} 
			else 
			{
			    if (!flagSetCenter)
				{
				    if (typeof map.setCenter == "function")
				    {
			            map.setCenter(point, parseInt(zoomLevel, 0));
			      	    flagSetCenter = true;
			      	}
			    }
			    icons = CreateIcon(markerLocation, markerWidth, markerHeight);
			     
			    //document.getElementById("mmm").value += markID + ":: ShowCityStateCountry :: " + eval(mapID + "MyCountAddress") + "::" +  fullAddr + "\n";  
			     
				eval(mapID + "MyCountAddress++"); 
				   
			    var marker = new GMarker(point, icons);
				marker.Id = markID;
				marker.Title = cityStateCountry;
				  
				var loadingPage = document.getElementById(mapID.substring(0, mapID.length - 3) + "_loadingPage");
                if (loadingPage && eval(mapID + "MyCountAddress <= " + mapID + "ItemsOnPage"))
                {
                    loadingPage.style.display = "";
                    loadingPage.innerHTML = eval("loadingMarker_" + mapID) + " " + eval(mapID + "MyCountAddress") + " " + eval("ofMarker_" + mapID) + " " + eval(mapID + "ItemsOnPage") + " ...";
                }
				  
				OpenInfoWindowTabs(mapID, cityStateCountry, marker, 'address', false, idCSS);
				  
					
				if (eval(mapID + "MyCountAddress >= " + mapID + "ItemsOnPage"))
				{
				    SendReport( mapID );
				}
								  
			   }
			});
		}
		
	}
	catch(ex)
	{
	    DisplayErrors("ShowCityStateCountry::", ex.message);
	}
}

/////////////////---According to the City and the Country to display marker---///////////////////////

function ShowCityCountry(mapID, cityCountry, markID, flag, idCSS) {
	try
	{	
    map = eval(mapID);	
    if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
    
    var geocoder = eval(mapID + "Geocoder");
		if (geocoder) 
		{
			var arr = cityCountry.split(";=;");
			fullAddr = arr[1] + ' ' + arr[3];
			var markerLocation = arr[(arr.length - 3)];
			var markerWidth = arr[(arr.length - 2)];
			var markerHeight = arr[(arr.length - 1)];			
			geocoder.getLatLng(fullAddr, function(point) {
			if (!point) 
			{
				ShowCountry(mapID, cityCountry, markID, flag, idCSS);
			} 
			else 
			{				 
				 if (!flagSetCenter)
				 {
				    if (typeof map.setCenter == "function")
				    {
			      	    map.setCenter(point, parseInt(zoomLevel, 0));
			      	    flagSetCenter = true;
			      	}
			     }
			     icons = CreateIcon(markerLocation, markerWidth, markerHeight);
				  
				  //document.getElementById("mmm").value += markID + ":: ShowCityCountry :: " + eval(mapID + "MyCountAddress") + "::" +  fullAddr + "\n";  
				  
				 eval(mapID + "MyCountAddress++");			      
			     var marker = new GMarker(point, icons);
				 marker.Id = markID;
				 marker.Title = cityCountry;
				  
				 var loadingPage = document.getElementById(mapID.substring(0, mapID.length - 3) + "_loadingPage");
                 if (loadingPage && eval(mapID + "MyCountAddress <= " + mapID + "ItemsOnPage"))
                 {
                   loadingPage.style.display = "";
                   loadingPage.innerHTML = eval("loadingMarker_" + mapID) + " " + eval(mapID + "MyCountAddress") + " " + eval("ofMarker_" + mapID) + " " + eval(mapID + "ItemsOnPage") + " ...";
                 }
				  
				 OpenInfoWindowTabs(mapID, cityCountry, marker, 'address', false, idCSS);	
				  
					
					if (eval(mapID + "MyCountAddress >= " + mapID + "ItemsOnPage"))
					{
					  SendReport( mapID );
					}
					
			    }
			});		
		}
	}
	catch(ex)
	{
	    DisplayErrors("ShowCityCountry::", ex.message);
	}
}
 

/////////////////---According to the Country to display marker---///////////////////////

function ShowCountry(mapID, country, markID, flag, idCSS) {
	try
	{	
    map = eval(mapID);
   if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
    
    var geocoder = eval(mapID + "Geocoder");	
		if (geocoder) 
		{
			var arr = country.split(";=;");
			fullAddr = arr[3];
			var markerLocation = arr[(arr.length - 3)];
			var markerWidth = arr[(arr.length - 2)];
			var markerHeight = arr[(arr.length - 1)];	
			geocoder.getLatLng(fullAddr, function(point) {
			if (!point) 
			{
			    eval(mapID + "MyErrorAddress += \";@;" + arr[0] + ";=;" + arr[1] + ";=;" + arr[2] + ";=;" + arr[3] + "\";");	
				//map.setZoom(parseInt(zoomLevel, 0));
				eval(mapID + "MyCountAddress++");	
					
				var loadingPage = document.getElementById(mapID.substring(0, mapID.length - 3) + "_loadingPage");
                if (loadingPage && eval(mapID + "MyCountAddress <= " + mapID + "ItemsOnPage"))
                {
                    loadingPage.style.display = "";
                    loadingPage.innerHTML = eval("loadingMarker_" + mapID) + " " + eval(mapID + "MyCountAddress") + " " + eval("ofMarker_" + mapID) + " " +  eval(mapID + "ItemsOnPage") + " ...";
                }
				if (eval(mapID + "MyCountAddress >= " + mapID + "ItemsOnPage"))
				{
                    SendReport( mapID );
				}
			} 
			else 
			{				 
			    if (!flagSetCenter)
				{
				    if (typeof map.setCenter == "function")
				    {
			            map.setCenter(point, parseInt(zoomLevel, 0));
			      	    flagSetCenter = true;
			      	}    
			    }
			    icons = CreateIcon(markerLocation, markerWidth, markerHeight);
			    
			    //document.getElementById("mmm").value += markID + ":: ShowCountry :: " + eval(mapID + "MyCountAddress") + "::" +  fullAddr + "\n";  
			    
				eval(mapID + "MyCountAddress++");			
				  	      
			    var marker = new GMarker(point, icons);
				marker.Id = markID;
				marker.Title = country;
				  
				var loadingPage = document.getElementById(mapID.substring(0, mapID.length - 3) + "_loadingPage");
                if (loadingPage && eval(mapID + "MyCountAddress <= " + mapID + "ItemsOnPage"))
                {
                    loadingPage.style.display = "";
                    loadingPage.innerHTML = eval("loadingMarker_" + mapID) + " " + eval(mapID + "MyCountAddress") + " " + eval("ofMarker_" + mapID) + " " + eval(mapID + "ItemsOnPage") + " ...";
                }
                OpenInfoWindowTabs(mapID, country, marker, 'address', false, idCSS);
				 
				//var totalItems = map.getOverlays().length;
				//if (flag == totalItems)	SetMapBestZoom(mapID);		
					
				if (eval(mapID + "MyCountAddress >= " + mapID + "ItemsOnPage"))
				{
                    SendReport( mapID );
				}
									  
			  }
		    });			
		}
	}
	catch(ex)
    {
        DisplayErrors("ShowCountry::", ex.message);
    }
}

///////////////////////////--Show the map with data marker by using the Coordinates--///////////////////////////////////////

function OnLoadMarkerByCoordinates(mapID, fullCoordinates, markID, flag, eastWard, idCSS){
	try
	{
	    //debugger;
		if (mapID != null)
		{
			if (fullCoordinates == '')
			{
				//map.setCenter(new GLatLng(34, 0), 2);
				alert('Empty');
			}
			else
		       	ShowCoordinates(mapID, fullCoordinates, markID, flag, eastWard, idCSS);
       	}		
	}
	catch(ex)
	{
	    DisplayErrors("OnLoadMarkerByCoordinates::", ex.message);
	}	
}
function ShowCoordinates(mapID, fullCoordinates, markID, flag, eastWard, idCSS){
	try
	{
	    map = eval(mapID);   
	    if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
		if (eval(mapID + "Geocoder")) 
	  	{
	        var arr = fullCoordinates.split(";=;");
	        var latTude = arr[0];  var alTude = arr[2]; var markerLocation = arr[(arr.length - 3)];
		    var markerWidth = arr[(arr.length - 2)]; var markerHeight = arr[(arr.length - 1)];			
			var lngTude = arr[1];
			var point = null;
			if (eastWard != null)
       	        point = new GLatLng(latTude, ConvertLongitude(lngTude), alTude);   			
       	    else
       	        point = new GLatLng(latTude, lngTude, alTude);       
       	        		
   			if (!point) 
			{
			    eval(mapID + "MyErrorAddress += \";@;" + arr[0] + ";=;" + arr[1] + ";=;" + arr[2] + ";=;" + arr[3] + "\";");	
				//map.setZoom(parseInt(zoomLevel, 0));
				eval(mapID + "MyCountAddress++");	
				//alert("Error: can not locate this address ...\n" + country + "\nNum: " + eval(mapID + "MyCountErrorAddress"));
				//alert("Error");
				//document.getElementById("mmm").value += markID + ":: ShowCountry-NoPoint :: " + eval(mapID + "MyCountAddress") + "::" +  fullAddr + "\n";  
					
				var loadingPage = document.getElementById(mapID.substring(0, mapID.length - 3) + "_loadingPage");
                if (loadingPage && eval(mapID + "MyCountAddress <= " + mapID + "ItemsOnPage"))
                {
                    loadingPage.style.display = "";
                    loadingPage.innerHTML = eval("loadingMarker_" + mapID) + " " + eval(mapID + "MyCountAddress") + " " + eval("ofMarker_" + mapID) + " " +  eval(mapID + "ItemsOnPage") + " ...";
                }
				if (eval(mapID + "MyCountAddress >= " + mapID + "ItemsOnPage"))
				{
                    SendReport( mapID );
				}
			    map.setZoom(parseInt(zoomLevel, 0));
            } 
			else 
			{
			    if (!flagSetCenter)
			    {
			        if (typeof map.setCenter == "function")
			        {
                        map.setCenter(point, parseInt(zoomLevel, 0));
                        flagSetCenter = true;
                    }
                }
                icons = CreateIcon(markerLocation, markerWidth, markerHeight);
                var pt = null;
                if (eastWard != null)
				    pt = new GLatLng(latTude, ConvertLongitude(lngTude));
			    else
				    pt = new GLatLng(latTude, lngTude);	
  					   
				eval(mapID + "MyCountAddress++")
  				      
                var marker = new GMarker(point, icons);
                marker.Id = markID;
                marker.Title = fullCoordinates;
                
                var loadingPage = document.getElementById(mapID.substring(0, mapID.length - 3) + "_loadingPage");
                if (loadingPage && eval(mapID + "MyCountAddress <= " + mapID + "ItemsOnPage"))
                {
                    loadingPage.style.display = "";
                    loadingPage.innerHTML = eval("loadingMarker_" + mapID) + " " + eval(mapID + "MyCountAddress") + " " + eval("ofMarker_" + mapID) + " " + eval(mapID + "ItemsOnPage") + " ...";
                }
                
			    OpenInfoWindowTabs(mapID, fullCoordinates, marker, 'coordinates', false, idCSS);
			    
			  
			    if (eval(mapID + "MyCountAddress >= " + mapID + "ItemsOnPage"))
				{
					SendReport( mapID );
				}  
		     }
		  }	    
    }
    catch(ex)
    {
        DisplayErrors("ShowCoordinates::", ex.message);
    }
}
function ConvertLongitude(myLng){
	var result = Trim(myLng);
	try
	{
		result = parseFloat(result) - 180;
	}
	catch(ex)
	{
		DisplayErrors("ConvertLongitude::", ex.message);
	}
	return result;
}
function ShowLocationByMarkerId(mapID, markerId, idCSS){
	try
	{
	    //alert(mapID);
	    map = eval(mapID);
	    if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
	    
		for (var i = 0;  i < map.getOverlays().length; i++)
		{
			var marker =  map.getOverlays(i) ;
			var point = marker[i].getPoint();		
			if (markerId == marker[i].Id)
			{	
			    if (typeof map.setCenter == "function")
			    {
				    map.setCenter(point);		
				}
				OpenInfoWindowTabs(mapID, marker[i].Title, marker[i], eval(mapID + "StrOption"), true, idCSS);
				break;
			}
		}
	}
	catch(ex)
	{
	    DisplayErrors("ShowLocationByMarkerId::", ex.message);
	}
}

///////////////////////////--Set Zoom Level and Map type--///////////////////////////////////////

function SetMapTypeAndZoomLevelCurrent(mapID, mapTypeID, option){
    try
    {
        map = eval(mapID);
        if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
        
		var mapType = document.getElementById(mapTypeID).value.toLowerCase();
		if (option == 'VE')
		{
			map.SetMapStyle(mapType);
		}
		else
		{
			//var mapType = map.getCurrentMapType().getName().toLowerCase();
			switch(mapType)
    		{
    			case "map":
    			{
    				map.setMapType(G_NORMAL_MAP);
    				break;
    			}
    			case "satellite":
    			{
	   				map.setMapType(G_SATELLITE_MAP);
    				break;
    			}
    			case "hybrid":
    			{
    				map.setMapType(G_HYBRID_MAP);
    				break;
    			}
    			default: break;
    		} 
    	}
    }
    catch(ex)
    {
        DisplayErrors("SetMapTypeAndZoomLevelCurrent::", ex.message);
    }	
}

function GetMapTypeAndZoomLevel(mapID, mapTypeID, zoomLevelID){
  try
  {
    map = eval(mapID);
    if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
    
	  var mapType = map.getCurrentMapType().getName().toLowerCase();
	  document.getElementById(mapTypeID).value = mapType;
	  document.getElementById(zoomLevelID).value = map.getZoom();
	}
	catch(ex)
	{
	    DisplayErrors("GetMapTypeAndZoomLevel::", ex.message);
	}
}
function GetMapTypeAndZoomLevelVE(mapID, mapTypeID, zoomLevelID){
    try
    {
        map = eval(mapID);
       if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
        
		var mapType = map.GetMapStyle();
		document.getElementById(mapTypeID).value = mapType;
		document.getElementById(zoomLevelID).value = map.GetZoomLevel();
	}
	catch(ex)
	{
	    DisplayErrors("GetMapTypeAndZoomLevelVE::", ex.message);
	}
}

function SetValueForHiddenField(hiddenID, hiddenValue){
    try
    {
    	var hiddenField = document.getElementById(hiddenID).value;    	
    	if (hiddenField != null)
    	{
			document.getElementById(hiddenID).value = hiddenValue;
		}
	}
	catch(ex)
	{
	    DisplayErrors("SetValueForHiddenField::", ex.message);
	}
}  
function CheckOnChanged(sourceID, destinationId){
	try
	{
		var tempDestination = document.getElementById(destinationId).value;
		var tempSource = document.getElementById(sourceID).value;
		
		if ((tempDestination != null) && (tempSource != null))
		{
			document.getElementById(destinationId).value = tempSource;
		}
	}
	catch(ex)
	{
	    DisplayErrors("CheckOnChanged::", ex.message);
	}
}
function SetMapTypeAndZoomLevel(mapID, mapTypeID, zoomLevelID){
    try
    {
        map = eval(mapID);    
    	if (map != null)
    	{
			var mapType = document.getElementById(mapTypeID).value;
	
			switch(mapType)
	    	{
	    		case "map":
	    		{
	    			map.setMapType(G_NORMAL_MAP);
	    			break;
	    		}
	    		case "satellite":
	    		{
		   			map.setMapType(G_SATELLITE_MAP);
	    			break;
	    		}
	    		case "hybrid":
	    		{
	    			map.setMapType(G_HYBRID_MAP);
	    			break;
	    		}
	    		default: break;
	    	}
    	} 
    }
    catch(ex)
    {
        DisplayErrors("SetMapTypeAndZoomLevel::", ex.message);
    }	
}
function ClearImages(objid){		
	if(objid =='')
	 map.clearOverlays();
}
//---------------------------------------------------------------------------------------
function addOnLoadEvent(func) {
	try
	{
	
		var oldOnLoad  = window.onload;
		if (typeof window.onload != 'function') 
		{
		 	//alert("Hello");
		 	window.onload = func;
		} 
		else 
		{
			window.onload = function() 
			{
			    //alert("Goodbye");
				oldOnLoad ();
				func();
			}
		} 
		//window.attachEvent('onload', func);       
	}
	catch(ex)
	{
	    //alert(ex.message);
		DisplayErrors("addOnLoadEvent::", ex.message);
	}
}
function VirtualMapView_OnUnLoaded(){
	try
	{
		GUnload();
	}
	catch(ex){}
}
function ShowPopupSourceEdit(idObjData, btnSave, btnCancel){ 
	window.open("wpresources/Bamboo.VirtualMapView/PopupVirtualMapView.html?ContainID=" + escape(idObjData) + "&s=" + btnSave + "&c=" + btnCancel,'FullScreen','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=665,height=530');  
	return false;
}
function IsBlank(val){
	if(val==null)
	{
		return true;
	}
	for(var i=0;i<val.length;i++)
	{
		if((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r"))
		{
			return false;
		}
	}
	return true;
}
function StartWithZero(val){
	if (val.charAt(0) == '0')
		return true;
	else
		return false;
}
function IsInteger(val){
	if (StartWithZero(val))
	{
		return false;
	}
	for(var i = 0; i < val.length; i++)
	{
		if(!IsDigit(val.charAt(i)))
		{
			return false;
		}
	}
	return true;
}
function IsDigit(num){	
	if(num.length > 1)
	{
		return false;
	}
	var string = "1234567890";
	if(string.indexOf(num) != -1)
	{
		return true;
	}
	return false;
}
function CheckInteger(validatorID, mapID){
	try
	{
		var num = document.getElementById(validatorID).value;
		
		if (!IsInteger(num))
		{
			alert(eval("enterNumberValue_" + mapID));
			document.getElementById(validatorID).focus();
			document.getElementById(validatorID).select();
		}
		if (IsBlank(num))
		{
			alert(eval("enterNumberRow") + mapID);
			document.getElementById(validatorID).focus();
			document.getElementById(validatorID).select();
		}
	}
	catch(ex)
	{
	    DisplayErrors("CheckInteger::", ex.message);
	}
}
//--------------------------------------VIRTUAL EARTH--------------------------------------------

var infoBox = null;
//------------------
function ShapeInfo(e, mapID, idCSS){
    try
    {
        if (infoBox && infoBox == eval("infoBox_"+mapID)) infoBox.style.display = "none";
        
        infoBox = eval("infoBox_"+mapID);
        
        map = eval(mapID);
        
        if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
        
	    map.HideInfoBox();
	    
	    
	    if(e.elementID != null)
	    {
	        layer = eval(mapID + "layer");
	        var _s = map.GetShapeByID(e.elementID).GetZIndex();
	        
		    for (var j = 0; j < layer.GetShapeCount(); j++)
		    {
			    var shape = layer.GetShapeByIndex(j);
			    var shapeID = shape.GetZIndex();
			    
			    if (shapeID == _s)
			    {
			        map.PanToLatLong(shape.GetPoints()[0]);
			        window.setTimeout(function() { map.ShowInfoBox(shape); },500);
			        break;
			    } 
    	    }		
	    }
    }
    catch(ex)
    {
        DisplayErrors("ShapeInfo::", ex.message);
    }
}
function AddShapeLayerOnMap(mapID, latLong, fullAddress, n, myShapeID, index, idCSS){
	try
	{
        map = eval(mapID);
        layer = eval(mapID + "layer");
        
        if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
	    
		var arr = fullAddress.split(";=;");
		var iconLocation = arr[(arr.length - 3)];
		var iconWidth = arr[(arr.length - 2)];
		var iconHeight = arr[(arr.length - 1)];		
		var shape = new VEShape(VEShapeType.Pushpin, latLong);
		var details = GetContentOfTabs(fullAddress, n, eval(mapID + "GTabTitles"), eval(mapID + "ArrayTabs"), idCSS);
		var titles = GetTitleOfTabs(fullAddress, n, eval(mapID + "GTabTitles"), eval(mapID + "ArrayTabs"), idCSS);
		
		var newShapeID = parseInt(idCSS) + index;
		shape.SetZIndex(newShapeID);
		
		var customIcon = new VECustomIconSpecification;
		customIcon.Image = iconLocation;
		shape.SetCustomIcon(customIcon);
		shape.SetTitle(titles);
		shape.SetDescription(details);		
		
		layer.AddShape(shape);
        
        map.AddShapeLayer(layer);
	}
	catch(ex)
	{
	    DisplayErrors("AddShapeLayerOnMap::", ex.message);
	}
}
function SetMapBestView(mapID, option){
	try
	{
		map = eval(mapID);
		if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
		if (option == "VE")
		{
			var points = eval(mapID + "MyViewPoints");
			var arrayPoints = new Array();
			for(var i = 0; i < points.length; i=i+2)
			{
				var pt = new VELatLong(points[i], points[i+1]); 
				arrayPoints.push(pt);
			}			
			map.SetMapView(arrayPoints);	
		}
	}
	catch(ex)
	{
		DisplayErrors("SetMapBestView::", ex.message);
	}
}
function SetMapBestZoom(mapID){
	try
	{
		map = eval(mapID);
		if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
		var bounds = eval(mapID + "MyViewPoints");
		for (var i = 0;  i < map.getOverlays().length; i++)
		{
			var marker =  map.getOverlays(i) ;
			var point = marker[i].getPoint();		
			bounds.extend(point);
		}		
		map.setZoom(map.getBoundsZoomLevel(bounds));
		if (typeof map.setCenter == "function")
		{
		    map.setCenter(bounds.getCenter()); 
		}
		var myCountTime = eval(mapID + "mySetTimeOut");
		if (myCountTime < 2)
		{
			//setTimeout("SetMapBestZoom('" + mapID + "')", 1000); 
			eval(mapID + "mySetTimeOut++");
		}		
	}
	catch(ex)
	{
		DisplayErrors("SetMapBestZoom::", ex.message);
	}
}

function ShowVEByAddress(mapID, newMyArray, strShapeID, idCSS)
{
  try
  {
    map = eval(mapID);
    if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
		eval(mapID + "MyArray = newMyArray");
		eval(mapID + "MyShapeID = strShapeID");
		index = eval(mapID + "Index");
		
		var loadingPage = document.getElementById(mapID.substring(0, mapID.length - 3) + "_loadingPage");
		if (loadingPage)
		{
		  loadingPage.style.display = "";
		  loadingPage.innerHTML = eval("loadingMarker_" + mapID) + " " + index + " "+ eval("ofMarker_" + mapID) +  " " + eval(mapID + "MyArray.length") + " ...";
		}
		
		if (eval("index < " + mapID + "MyArray.length"))
		{         
			eval(mapID + "TmpFullAddress = " + mapID +  "MyArray[index]");
			var whereResult = GetStringAddress(eval(mapID + "TmpFullAddress"), 0);
			map.Find(null, whereResult, null, map.GetShapeLayerByIndex(0), 0, 1, null, true, false, false, function(){ ShowPushPinByAddress(arguments[0], arguments[1], arguments[2], arguments[3], mapID, idCSS); });
			map.ShowMessageBox = false;
		}
		else
		{
		  if (loadingPage)
		  {
		    setTimeout(function() { loadingPage.style.display = 'none'; }, 2000);
		  }
		  
			SetMapBestView(mapID, "VE");
			return false;
        
       }

       if (eval(mapID + "Index >= " + mapID + "ItemsOnPage")) {
           SendReport(mapID);
       }
  }
  catch(ex)
  {
    DisplayErrors("ShowVEByAddress::", ex.message);
  }
}
function ShowPushPinByAddress(layer, whatResults, whereResults, hasMore, mapID, idCSS){
	try
	{
    map = eval(mapID);
   if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
		if (whereResults != null)
		{
			eval(mapID + "MyViewPoints.push(" + whereResults[0].LatLong + ")");
			AddShapeLayerOnMap(mapID, whereResults[0].LatLong, eval(mapID + "TmpFullAddress"), 4, eval(mapID + "MyShapeID"), eval(mapID + "Index"), idCSS);
			eval(mapID + "Index++");
			ShowVEByAddress(mapID, eval(mapID + "MyArray"), eval(mapID + "MyShapeID"), idCSS);
		}
		else {
		    //alert("find another!");
			var whereResult = GetStringAddress(eval(mapID + "TmpFullAddress"), 1);
			map.Find(null, whereResult, null, map.GetShapeLayerByIndex(0), 0, 1, null, true, false, false, function(){ ShowPushPinByCityStateCountry(arguments[0], arguments[1], arguments[2], arguments[3], mapID, idCSS); });

        }
        if (eval(mapID + "Index >= " + mapID + "ItemsOnPage")) {
            SendReport(mapID);
        }
	}
  catch(ex)
  {
    DisplayErrors("ShowPushPinByAddress::", ex.message);
  }
}
function ShowPushPinByCityStateCountry(layer, whatResults, whereResults, hasMore, mapID, idCSS){
	try
	{
    map = eval(mapID);
   if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
		if (whereResults != null)
		{
			eval(mapID + "MyViewPoints.push(" + whereResults[0].LatLong + ")");
			AddShapeLayerOnMap(mapID, whereResults[0].LatLong, eval(mapID + "TmpFullAddress"), 4, eval(mapID + "MyShapeID"), eval(mapID + "Index"), idCSS);
			eval(mapID + "Index++");
			ShowVEByAddress(mapID, eval(mapID + "MyArray"), eval(mapID + "MyShapeID"), idCSS);
		}
		else {
		    //alert("find another country !");
			var whereResult = GetStringAddress(eval(mapID + "TmpFullAddress"), 2);
			map.Find(null, whereResult, null, map.GetShapeLayerByIndex(0), 0, 1, null, true, false, false, function(){ ShowPushPinByCityCountry(arguments[0], arguments[1], arguments[2], arguments[3], mapID, idCSS); });

        }
        if (eval(mapID + "Index >= " + mapID + "ItemsOnPage")) {
            SendReport(mapID);
        }
	}
	catch(ex)
	{
	    DisplayErrors("ShowPushPinByCityStateCountry::", ex.message);
	}
}
function ShowPushPinByCityCountry(layer, whatResults, whereResults, hasMore, mapID, idCSS){
	try
	{
    map = eval(mapID);
    if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
		if (whereResults != null)
		{
			eval(mapID + "MyViewPoints.push(" + whereResults[0].LatLong + ")");
			AddShapeLayerOnMap(mapID, whereResults[0].LatLong, eval(mapID + "TmpFullAddress"), 4, eval(mapID + "MyShapeID"), eval(mapID + "Index"), idCSS);
			eval(mapID + "Index++");
			ShowVEByAddress(mapID, eval(mapID + "MyArray"), eval(mapID + "MyShapeID"), idCSS);
		}
		else {
		    //alert("find another city country");
			var whereResult = GetStringAddress(eval(mapID + "TmpFullAddress"), 3);
			map.Find(null, whereResult, null, map.GetShapeLayerByIndex(0), 0, 1, null, true, false, false, function(){ ShowPushPinByStateCountry(arguments[0], arguments[1], arguments[2], arguments[3], mapID, idCSS); });

        }
        if (eval(mapID + "Index >= " + mapID + "ItemsOnPage")) {
            SendReport(mapID);
        }
	}
	catch(ex)
	{
	    DisplayErrors("ShowPushPinByCityCountry::", ex.message);
	}
}
function ShowPushPinByStateCountry(layer, whatResults, whereResults, hasMore, mapID, idCSS){
	try
	{
    map = eval(mapID);
   if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }

	    if (whereResults != null) {
	        
	        eval(mapID + "MyViewPoints.push(" + whereResults[0].LatLong + ")");
	        AddShapeLayerOnMap(mapID, whereResults[0].LatLong, eval(mapID + "TmpFullAddress"), 4, eval(mapID + "MyShapeID"), eval(mapID + "Index"), idCSS);
	        eval(mapID + "Index++");
	        ShowVEByAddress(mapID, eval(mapID + "MyArray"), eval(mapID + "MyShapeID"), idCSS);
	    }
	    
	    if (hasMore == null) {
	        
	        var dv = document.createElement("DIV");
	        dv.innerHTML = eval(mapID + "TmpFullAddress");
	        
	        eval(mapID + "MyErrorAddress += \";@;" + dv.children(0).children(0).innerText + "\";");
	        //eval(mapID + "MyCountAddress++");
	        
	        var loadingPage = document.getElementById(mapID.substring(0, mapID.length - 3) + "_loadingPage");
	        if (loadingPage && eval(mapID + "Index <= " + mapID + "ItemsOnPage")) {
	            loadingPage.style.display = "";
	            loadingPage.innerHTML = eval("loadingMarker_" + mapID) + " " + eval(mapID + "Index") + " " + eval("ofMarker_" + mapID) + " " + eval(mapID + "ItemsOnPage") + " ...";
	        }
	    }

	    if (eval(mapID + "Index >= " + mapID + "ItemsOnPage")) {
	        SendReport(mapID);
	    }	       
		//alert(hasMore);
	}
	catch(ex)
	{
	    DisplayErrors("ShowPushPinByStateCountry::", ex.message);
	}
}

/* My custom Content of VE */
function redrawContentWithStyleSheet( content, idCSS) {
	var dv, tables, _table;
	var titleStyle, contentStyle, styles, classNameTitle, classNameContent;
	
	styles = document.getElementsByTagName("STYLE");
	
	dv = document.createElement("DIV");
	dv.innerHTML = content;
	tables = dv.getElementsByTagName("TABLE");
	//return content;;
	if (tables.length>0) {
		_table = tables[0];
		
		// detect browser 
		var isFF = window.navigator.appName.indexOf('Netscape')>=0;
		
		// Extract stylesheet;
		classNameTitle = '.VirtualMapViewTitle-'+idCSS;
		titleStyle = extractStyleSheet( styles, classNameTitle);
		classNameContent = '.VirtualMapViewInfoBox-'+idCSS;
		contentStyle = extractStyleSheet( styles, classNameContent);
		// Fetch style sheet
		var row, tableContent = '<table class="VirtualMapViewInfoBox-'+idCSS+'" cellspacing="0" cellpadding="0" style="margin-right: 10px">';
		for(var iRow = 0; iRow < _table.rows.length; iRow++ ) {
			row = _table.rows[iRow];
			if (row.cells.length==1) {
				// For title
				tableContent += '<tr><td colspan="2" class="VirtualMapViewTitle-'+idCSS+'" style="'+titleStyle.styleSheet+'" '+(titleStyle.noWrap ? 'nowrap="true"' : '')+'>'+ (isFF ? row.cells[0].textContent : row.cells[0].innerText)+'</td></tr>';
			}
			else {
				//for content
				tableContent += '<tr>';
				tableContent += '	<td style="'+contentStyle.styleSheet+'" '+(contentStyle.noWrap ? 'nowrap="true"' : '')+'>'+ (isFF ? row.cells[0].textContent : row.cells[0].innerText)+'</td>';
				
				var srcText = isFF ? row.cells[1].textContent : row.cells[1].innerText;
				var hyperlink = srcText.substring(0,srcText.indexOf(','));
				var hypertext = srcText.substring(srcText.indexOf(',')+1);
				
				var targetText = isURL(hyperlink) ? '<a href="'+hyperlink+'" target="_blank">'+hypertext+'</a>' : row.cells[1].innerHTML;
				
				tableContent += '	<td style="'+contentStyle.styleSheet+'" '+(contentStyle.noWrap ? 'nowrap="true"' : '')+'>'+ targetText +'</td>';
				//alert(row.cells[1].innerText);
				tableContent += '</tr>';
			}
		}
		tableContent += '</table>';
		return tableContent;
	}
	else 
		return content;
}

/* For bug 222 */
function isURL(url) {
    var reg = new RegExp("/?([:\/\w\s\d\.]*)/");
    return url.match(reg);
}

/* My custome size */
function resizeShape() {
	// detect browser 
	var isFF = window.navigator.appName.indexOf('Netscape')>=0;
		
	var dv, tables, maxSize, child, stop = false;
	dv = document.getElementById("MSVE_navAction_palette");
	
	dv = dv.nextSibling;
	// Fixed for FF/Netscape
	while (dv.nodeType!=1) dv = dv.nextSibling;
	
	// Get real Size:
	tables = dv.getElementsByTagName("TABLE");
	maxSize = 0;
	for(var iTable = 0; iTable < tables.length; iTable++) {
		maxSize = maxSize < tables[iTable].offsetWidth ? tables[iTable].offsetWidth : maxSize;
	}
	
	if (maxSize > 0)  {
		childrenDIV = dv.getElementsByTagName("DIV");
		for(var child = 0; child < childrenDIV.length; child++) {
			
			// resize Popup
			//if (childrenDIV[child].className != 'ero-beak' && childrenDIV[child].className != 'active' && childrenDIV[child].className != 'deactive')
			//	childrenDIV[child].style.width = maxSize + 25 + 'px';
			
			// remove DIV if it's empty
			if (childrenDIV[child].className == 'ero-paddingHack' || childrenDIV[child].className == 'ero-actions') {
				var t = isFF ? childrenDIV[child].textContent : childrenDIV[child].innerText;
				if (Trim(t) == '' || t.length == 0) {   
					childrenDIV[child].style.padding = '0px'; 
					childrenDIV[child].style.margin = '0px';
					childrenDIV[child].style.height = '0px';
				}
			}
		}
	}
}

/*
return object has class name is the same of class name by arguments
*/
function getTagByClassName( tags, className ) {
	var o = null;
	for(var id = 0; id < tags.length; id++)
		if (tags[id].className == className) { o = tags[id]; break; }
	
	return o;
}

function redrawContentTab( content, idCSS) {
	var dv, tables, _table, retTable, row;
	var titleStyle, contentStyle, styles, classNameTitle, classNameContent;
	var arrTitle = new Array();
	var arrContent = new Array();
	
	styles = document.getElementsByTagName("STYLE");
	
	dv = document.createElement("DIV");
	dv.innerHTML = content;
	tables = dv.getElementsByTagName("TABLE");
	
	if (tables.length>0 && tables[0].id != "tab2007") {
		_table = tables[0];
		
		// detect browser 
		var isFF = window.navigator.appName.indexOf('Netscape')>=0;
		
		// Extract stylesheet;
		classNameTitle = '.VirtualMapViewTitle-'+idCSS;
		titleStyle = extractStyleSheet( styles, classNameTitle);
		classNameContent = '.VirtualMapViewInfoBox-'+idCSS;
		contentStyle = extractStyleSheet( styles, classNameContent);
				
		var json = '( { "O" : [] ';
		for(var iRow = 0; iRow < _table.rows.length; iRow++) {
			row = _table.rows[iRow];
			if (row.cells.length == 1) {
				// For Title or Breakline
				// Add Title
				var t = isFF ? row.cells[0].textContent : row.cells[0].innerText;
				// close before Tab
				if (iRow > 0 && Trim(t)!='' && t.length>0) json += '] ';
				if (Trim(t)!='' && t.length>0) json += ', "'+t+'" : [ "" ';
			}
			else {
				//for Content
				var t0 = isFF ? row.cells[0].textContent : row.cells[0].innerText;
				var t1 = isFF ? row.cells[1].textContent : row.cells[1].innerText;
				json += ', "'+t0+':'+t1+'"';
			}
		}
		// Close tab after
		json += '] })';
		var json = eval(json);
		// JSON Technology
		retTable = '<table cellspacing="0" cellpadding="0" width=\"95%\" id="tab2007" class="VirtualMapViewInfoBox-'+idCSS+'">';
		
		var titleTab = '<tr class="tbTabTitle">';
		var contentTab = '<tr class="tbTabBody"><td colspan="3">';
		
		var count = 0; // Number of Tab
		for(var item in json) {
			if (item != 'O') {
				titleTab += '<td class="header"><div class="'+(count==0 ? 'active' : 'deactive')+'" onclick="settab(this)">'+item+'</div></td>';
				contentTab += '<table id="childTab'+count+'" cellspacing="0" width=\"100%\" cellpadding="0" style="'+(count>0 ? 'display:none' : '')+'">';
				for (var index in json[item]) {
					pair = json[item][index];
					pairs = pair.split('::');
					if (pairs.length == 2) {
						contentTab += '<tr>';
						contentTab += '		<td style="'+titleStyle.styleSheet+'" '+(titleStyle.noWrap ? 'nowrap' : '')+'>'+pairs[0]+':</td>';
						contentTab += '		<td style="'+contentStyle.styleSheet+'" '+(contentStyle.noWrap ? 'nowrap' : '')+'>'+pairs[1]+'</td>';
						contentTab += '</tr>';
					}
				}
				contentTab += '</table>';
				// More tab
				count++;
			}
		}
		titleTab += '</tr>';
		contentTab += '</td></tr>';
		
		retTable += titleTab + contentTab + '</table>'; 
		return NoBreak(retTable);
	}
	else 
		return content; // No Rebuild Tab
}

function setTabActive(obj,idCSS) {
	var tdObject = obj.parentNode; // Slit to TD
	var trObj = tdObject.parentNode; // Slit to TR
	
	var maxHeight = 0;
	
	for(var i=0;i<trObj.cells.length; i++) {
		if (trObj.cells[i].getElementsByTagName("A").length>0) trObj.cells[i].getElementsByTagName("A")[0].className = "deactive";
		var b = document.getElementById("tab_"+idCSS+"_"+i);
		if (b.tagName == "TABLE")
		{
	        maxHeight = maxHeight < b.offsetHeight ? b.offsetHeight : maxHeight;	    
		}
		if (b) b.style.display='none';
	}
	
	document.getElementById('tab_'+idCSS+'_'+tdObject.cellIndex).style.display = 'block';
	document.getElementById('tab_'+idCSS+'_'+tdObject.cellIndex).style.height =  maxHeight + 'px';
	obj.className = "active";
}

/*
GetPosition(param)
- param: ID of object need to get the position
- return: Position of object
*/
function GetPosition(objectID, shapeId) {
    var pos = new Object;
    pos.x = 0;
    pos.y = 0;
    
    var arrShapeID = objectID.split('#');
    var parentShapeId = arrShapeID[0].substring(0, arrShapeID[0].length-1);
    var parentShapeObject = eval(parentShapeId);
    var arrObjectInparent = parentShapeObject.getElementsByTagName("A");
    
    var obj = null;
    
    for(var objIndex=0; objIndex < arrObjectInparent.length; objIndex++)
        if ( arrObjectInparent[objIndex].id.indexOf(shapeId) > 0 ) 
        {
            obj = arrObjectInparent[objIndex];
            break;
        }
    
    if (obj!=null) {
        while (obj.offsetParent!=null)
	    {
		    pos.x+=obj.offsetLeft - obj.scrollLeft;
		    pos.y+=obj.offsetTop - obj.scrollTop;
		    obj=obj.offsetParent;
	    }
    }
    return pos;
}


function ShowShapeLayerById(mapID, myShapeLayerId, idCSS)
{
 	try
	{
	    if (infoBox && infoBox == eval("infoBox_"+mapID)) infoBox.style.display = "none";
	    
	    infoBox = eval("infoBox_"+mapID);
	    
	    map = eval(mapID);
	   if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
	    map.HideInfoBox();
		layer = eval(mapID + "layer");
		
		var _mid = myShapeLayerId.split('_');
		
		layer = eval(mapID + "layer");
		    
		for (var j = 0; j < layer.GetShapeCount(); j++)
		    {
			    var shape = layer.GetShapeByIndex(j);
			    var shapeID = shape.GetZIndex();
			    var _m = parseInt(_mid[_mid.length-2]) + parseInt(_mid[_mid.length-1]);
			    
			    if (shapeID == _m)
			    {
			        var _sid = shape.GetID().split('_'); // _sid = msftve_1001_200037
			        var _idx = parseInt(_sid[_sid.length-1]) - 200000; // _idx = 37
			        var _rid = shape.GetID() + '_' + (10000 + _idx); // _rid = msftve_1001_200037_10037
			        //alert(_rid + ' === ' + map.GetZoomLevel());
			        if (map.GetZoomLevel() != 1)
			        {
			            map.PanToLatLong(shape.GetPoints()[0]);
			            map.AttachEvent("onendpan",function() { window.setTimeout(function() { map.ShowInfoBox(shape); },500); });
			            //window.setTimeout(function() { map.ShowInfoBox(shape); },500);
			        }
			        else
			        {
			            VEShowVEShapeERO(_rid, map.GUID);
			        }
			        break;
			    } 
    	    }		
		
	}
	catch(ex)
	{
	     //alert(ex.message);
	    DisplayErrors("ShowShapeLayerById::", ex.message);
	}
}


function ShowShapeLayerByIdCoordinate(mapID, myShapeLayerId, idCSS)
{
 	try
	{
	    if (infoBox) infoBox.style.display = "none";
	    infoBox = eval("infoBox_" + mapID);
	    
	    map = eval(mapID);
	   if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
	    map.HideInfoBox();
	    
	    layer = eval(mapID + "layer");
		
		var _mid = myShapeLayerId.split('_');
		
		layer = eval(mapID + "layer");
		    
		for (var j = 0; j < layer.GetShapeCount(); j++)
		    {
			    var _sid = shape.GetID().split('_'); // _sid = msftve_1001_200037
			        var _idx = parseInt(_sid[_sid.length-1]) - 200000; // _idx = 37
			        var _rid = shape.GetID() + '_' + (10000 + _idx); // _rid = msftve_1001_200037_10037
			        //alert(_rid + ' === ' + map.GetZoomLevel());
			        if (map.GetZoomLevel() != 1)
			        {
			            map.PanToLatLong(shape.GetPoints()[0]);
			            map.AttachEvent("onendpan",function() { window.setTimeout(function() { map.ShowInfoBox(shape); },500); });
			            //window.setTimeout(function() { map.ShowInfoBox(shape); },500);
			        }
			        else
			        {
			            VEShowVEShapeERO(_rid, map.GUID);
			        }
			        break;
    	    }		
		
	}
	catch(ex)
	{
	    DisplayErrors("ShowShapeLayerByIdCoordinate::", ex.message);
	}
} 


function GetTitleOfTabs(fullAddress, n, gTabTitles, arrayTabs, idCSS) 
{
    gTabTitles = fixArray(gTabTitles);
    arrayTabs = fixArray(arrayTabs);
     
    var arr = fullAddress.split(";=;");
    var results = '<table style="width: auto" class="VirtualMapViewTitle-' + idCSS + '"><tr>';
    for (var tabIdx = 0; tabIdx < gTabTitles.length; tabIdx++) 
    {
        results += '<td class="VirtualMapViewTitle-' + idCSS +'" colspan="2" nowrap="true"><a href="java'+'script:void(0)" class="'+(tabIdx==0 ? 'active' : 'deactive')+'" onclick="setTabActive(this,'+idCSS+')">' + gTabTitles[tabIdx] + '</td>';   
    }
    results += '</tr></table>';
    
    return results;
}
function GetContentOfTabs(fullAddress, n, gTabTitles, arrayTabs, idCSS)
{
    gTabTitles = fixArray(gTabTitles);
    arrayTabs = fixArray(arrayTabs);
	var arr = fullAddress.split(";=;");
	var results  = "";				
	for (var j = 0; j < gTabTitles.length; j++)
	{
		results += '<table id="tab_'+idCSS+'_'+j+'" class="VirtualMapViewInfoBox-' + idCSS + '" style="'+(j>0 ? 'display: none' : '')+'">';
		var contenTab = arrayTabs[j].split(";@#@;");		
		for (var i = 0; i < contenTab.length; i++)
		{
			if (contenTab[i] != '')
			{
				var str1 = arr[n];
				var str2 = CheckURL(arr[n], 'VE');
				if (str1 == str2)
				{
					if (str1.indexOf(' ') != -1)
					{
						if (contenTab[i].indexOf(' ') != -1)
							results += '<tr><td nowrap>' + contenTab[i] + ':</td><td style="padding-left: 25px">' + str1 + '</td></tr>';
						else
							results += '<tr><td nowrap>' + SplitString(contenTab[i], 14) + ':</td><td style="padding-left: 25px">' + str1 + '</td></tr>';
					}
					else
					{
						if (contenTab[i].indexOf(' ') != -1)
							results += '<tr><td nowrap>' + contenTab[i] + ':</td><td style="padding-left: 25px">' + SplitString(str1, 20) + '</td></tr>';
						else
							results += '<tr><td nowrap>' + SplitString(contenTab[i], 14) + ':</td><td style="padding-left: 25px">' + SplitString(str1, 20) + '</td></tr>';
					}	
				}
				else
					results += '<tr><td nowrap>' + SplitString(contenTab[i], 14) + ':</td><td style="padding-left: 25px">' + str2 + '</td></tr>';				
				n++;	
			}
		}
		//if (j < (gTabTitles.length - 1))
		//	results += "<tr><td colspan='2' width='100%'><hr style ='height:1px;color:silver;'></td></tr>";			
		results += '</table>';
	}
	results += '';
	
	return results;
}
function FixAddressText(address){
    //Fix special character
    address = address.replace('/', ' ');
    address = address.replace('&', ' ');
    
    //Fix abbreviation
    address = address.replace(' hwy. ', ' Highway ');
    address = address.replace(' Hwy. ', ' Highway ');    
    address = address.replace(' hwy ', ' Highway ');
    address = address.replace(' Hwy ', ' Highway ');
    address = address.replace(' Bl ', ' Blvd. ');    
    
    return address;
}
function GetStringAddress(fullAddress, option){
	var strResult = "";
	var arrayAddress = fullAddress.split(";=;");
	switch(option)
	{
		case 0://Street, City, State, Country
		{
	  		strResult = FixAddressText(arrayAddress[0]) + ', ' + arrayAddress[1] + ', ' + arrayAddress[2] + ', ' + arrayAddress[3];
	  		break;
		}
		case 1://City, State, Country
		{
	  		strResult = arrayAddress[1] + ', ' + arrayAddress[2] + ', ' + arrayAddress[3];
	  		break;
		}
		case 2://City, Country
		{
	  		strResult = arrayAddress[1] + ', ' + arrayAddress[3];
	  		break;
		}
		case 3://State, Country
		{
	  		strResult = arrayAddress[2] + ', ' + arrayAddress[3];
	  		break;
		}	  	 	
		case 4://Country
		{
	  		strResult = arrayAddress[3];
	  		break;
		} 	 	
		default: break;
	}
	return strResult;
}
function GetShapeID(strShapeID){
	var result = "";
	var tmpArray = strShapeID.toString().split("#");
	result = tmpArray[1];
	
	return result;
}
//---------------------------------------------------------------------------------------------------------------------
var flagSetCenter = false;
function ShowVEByCoordinates(mapID, newMyArray, strShapeID, flag, eastWard, idCSS){
    try
    {
    //alert(strShapeID);
		map = eval(mapID);        
		if (map == null) 
	    {
	        if (!isMapNull) alert(eval("notLoadMap_" + mapID));
	        isMapNull = true;
	        return;
	    }
        if (!flag)
        {
			var lat = null;
			var lng = null;			
			var latLonArray = newMyArray.split(";=;");
			lat = parseFloat(latLonArray[0]);
			if (eastWard != null)
				lng = ConvertLongitude(latLonArray[1]);
			else
				lng = parseFloat(latLonArray[1]);
			eval(mapID + "MyViewPoints.push(" + lat + ")");
			eval(mapID + "MyViewPoints.push(" + lng + ")");
			var latLong = new VELatLong(lat,lng);
			AddShapeLayerOnMap(mapID, latLong, newMyArray, 3, strShapeID, eval(mapID + 'Index'), idCSS);
			eval(mapID + "Index++");
			map.ShowMessageBox = false;
			
		}
		else
			SetMapBestView(mapID, "VE");
    }
    catch(ex)
    {
        DisplayErrors("ShowVEByCoordinates::", ex.message);
    }
}
function SplitString(myString, len){
	var result = "";
	if (myString.length > len)
	{
		var n = 0;
		for (var i = 0; i < myString.length; i++)
		{
			n++;
			result += '' + myString.charAt(i);
			if (n == len)
			{
				result += '<br>';
				n = 0;
			}
		}
	}
	else
		result = myString;
	return result;
}
var imageTypes = new Array();
	imageTypes[0] = ".gif";	imageTypes[1] = ".jpg";	imageTypes[2] = ".jpeg";		
	imageTypes[3] = ".png";	imageTypes[4] = ".bmp";	imageTypes[5] = ".wmf";	imageTypes[6] = ".dib";	
		
function CheckImage(myString){
	var flagResult = false;
	myString = myString.toLowerCase();
	for (var i = 0; i < imageTypes.length; i++)
	{
		if (myString.indexOf(imageTypes[i]) != -1)
		{
			var nArray = myString.split(".");
			var eEnd = '.' + nArray[nArray.length -1];
			if (eEnd == imageTypes[i])
			{
				flagResult = true;
				break;
			}
		}
	}
	return flagResult;
}
function CheckURL(myString, myOption) {
	var myResult = myString;
	//alert(myString + " == " + myOption);
	var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	try
	{
		if (regexp.test(myString))
		{
			if (myString.toLowerCase().indexOf(",") != -1)
			{
			    // Exist colon
				//var urlArray = myString.split(","); //;@#@;
				
				var hyperlink = myString.substring(0,myString.indexOf(','));
				var hypertext = myString.substring(myString.indexOf(',')+1);
				
				if (!CheckImage(Trim(hyperlink)))
					myResult = "<a href=\"" + Trim(hyperlink) + "\" target='_blank' title=\"" + Trim(hypertext) + "\" >" + SplitString(hypertext, 20) + "</a>";
				else
				{
					if (myOption == 'GM')
						myResult = "<a href=\"" + Trim(hyperlink) + "\" target='_blank' title =\"" + Trim(hypertext) + "\" ><img src=\"" + Trim(hyperlink) + "\" style='border:0' width='120px'></a>";
					else
						myResult = "<a href=\"" + unescape(Trim(hyperlink)) + "\" target='_blank' title =\"" + unescape(Trim(hypertext)) + "\" ><img src=\"" + unescape(Trim(hyperlink)) + "\" style='border:0' width='120px'></a>";
				}
			}
			else
			{
				if (!CheckImage(Trim(myString)))
					myResult = "<a href=\"" + unescape(Trim(myString)) + "\" target='_blank' >" + unescape(SplitString(Trim(myString), 20)) + "</a>";
				else
				{
					if (myOption == 'GM')
						myResult = "<a href=\"" + unescape(Trim(myString)) + "\" target='_blank' title =\"" + unescape(Trim(myString)) + "\" ><img src=\"" + unescape(Trim(myString)) + "\" style='border:0' width='120px'></a>";
					else
						myResult = "<a href=\"" + unescape(Trim(myString)) + "\" target='_blank' title =\"" + unescape(Trim(myString)) + "\" ><img src=\"" + unescape(Trim(myString)) + "\" style='border:0' width='120px'></a>";
				}
			}
		}
		else
		{
			if (myString.toLowerCase().indexOf("www.") != -1)
			{
				if (myString.toLowerCase().indexOf(",") != -1)
				{
					//var urlArray = myString.split(",");
					var hyperlink = myString.substring(0,myString.indexOf(','));
				    var hypertext = myString.substring(myString.indexOf(',')+1);
				
					if (!CheckImage(Trim(hyperlink)))
						myResult = "<a href=ht"+"tp://" + Trim(hyperlink) + " target='_blank' title=\"" + Trim(hypertext) + "\" > " + Trim(hypertext) + "</a>";
					else
					{
						if (myOption == 'GM')
							myResult = "<a href=ht"+"tp://" + Trim(hyperlink) + " target='_blank' title=\"" + Trim(hypertext) + "\" ><img src=\"" + Trim(hyperlink) + "\" style='border:0' width='120px'></a>";
						else
							myResult = "<a href=ht"+"tp://" + escape(Trim(hyperlink)) + " target='_blank' title=\"" + escape(Trim(hypertext)) + "\" ><img src=\"" + escape(Trim(hyperlink)) + "\" style='border:0' width='120px'></a>";
					}
				}
				else
				{
					if (!CheckImage(Trim(myString)))
						myResult = "<a href=ht"+"tp://" + Trim(myString) + " target='_blank' title=\"" + Trim(myString) + "\" >" + Trim(myString) + "</a>";
					else
					{
						if (myOption == 'GM')
							myResult = "<a href=ht"+"tp://" + Trim(myString) + " target='_blank' title=\"" + Trim(myString) + "\" ><img src=\"" + Trim(myString) + "\" style='border:0' width='120px'></a>";
						else
							myResult = "<a href=ht"+"tp://" + escape(Trim(myString)) + " target='_blank' title=\"" + escape(Trim(myString)) + "\" ><img src=\"" + escape(Trim(myString)) + "\" style='border:0' width='120px'></a>";
					}	
				}	
			}
			else
				myResult = myString;
		}
	}
	catch(ex)
	{
	    DisplayErrors("CheckURL::", ex.message);
	}
	return myResult;
}
function NoBreak(value) {
	var reg = /\r\n/g;
	return value.replace(reg,'');
}
function LTrim(value) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}
function RTrim(value) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}
function Trim(value) {
	return LTrim(RTrim(value));
}
function VirtualMapViewShowToolTip(mapID, values, idCSS){
	var myResult = null;
	try
	{
	    myResult = unescape(values);
        if (eval(mapID + "StrOption == 'address'"))
	        myResult = escape(GetStringForToolTip(mapID, myResult, 4, idCSS));
        else
	        myResult = escape(GetStringForToolTip(mapID, myResult, 3, idCSS));
    }
    catch(ex)
    {
        DisplayErrors("VirtualMapViewShowToolTip::", ex.message);
    }
	return myResult;
}
function GetStringForToolTip(mapID, fullAddress, n, idCSS){
	var gTabTitles = eval(mapID + "GTabTitles");	
    var arrayTabs = eval(mapID + "ArrayTabs");	
	var arr = fullAddress.split(";=;");
	var results  = "<table class='VirtualMapViewToolTipBody-" + idCSS + "'>";	
    results += "<tr><td colspan=2 width=100% style=color:gray><b>" + eval("descriptionItem_" + mapID) + "</b><hr style=height:1px;color:silver;></td></tr>";
	
	for (var j = 0; j < gTabTitles.length; j++)
	{
		var contenTab = arrayTabs[j].split(";@#@;");
		for (var i = 0; i < contenTab.length; i++)
		{
			if (contenTab[i] != '')
			{
				var str1 = arr[n];
				if ((str1.indexOf('http://') != -1) || (str1.indexOf('www.') != -1))
				{
					var str2 = str1.split(",");
					str1 = str2[0];
				}
				results += "<tr><td style=white-space:nowrap>" + contenTab[i] + ":</td><td style=white-space:nowrap>" + str1 + "</td></tr>";
				n++;	
			}
		}
	}
	results += "</table>";
	return results;
}

//Tooltip
if (typeof document.attachEvent!='undefined')
{
   window.attachEvent('onload', Init);
   document.attachEvent('onmousemove', MoveMouse);
   document.attachEvent('onclick', IsMove);
}
else
{
   window.addEventListener('load', Init, false);
   document.addEventListener('mousemove', MoveMouse, false);
   document.addEventListener('click', IsMove, false);
}

var oDv = document.createElement("div");
var dvHdr = document.createElement("div");
var dvBdy = document.createElement("div");
var windowlock, boxMove, fixposx, fixposy, lockX, lockY, fixx, fixy, ox, oy;
var boxLeft, boxRight, boxTop, boxBottom, evt, mouseX, mouseY, boxOpen, totalScrollTop, totalScrollLeft;
boxOpen = false;
ox = 10;
oy = 10;
lockX = 0;
lockY = 0;

function Init(){
	oDv.appendChild(dvHdr);
	oDv.appendChild(dvBdy);
	oDv.style.position = "absolute";
	oDv.style.visibility = "hidden";
	oDv.style.border = "solid 1px black";
	//oDv.className = "ms-quickLaunch";
	//oDv.style.width = "1px";
	oDv.style.zIndex = 999;
//	oDv.style.filter='alpha(opacity=90)'; // IE
//	oDv.style.opacity='0.9'; // FF
	document.body.appendChild(oDv);
}

function DefHdrStyle(){
	dvHdr.innerHTML = '<img  style="vertical-align:middle"  src="info.gif">&nbsp;&nbsp;' + dvHdr.innerHTML;
	dvHdr.style.fontWeight = 'bold';
	dvHdr.style.fontFamily = 'arial';
	dvHdr.style.border = '1px solid #A5CFE9';
	dvHdr.style.padding = '2';
	dvHdr.style.fontSize = '11';
	dvHdr.style.color = '#FFFFFF';
	dvHdr.style.background = '#4B7A98';
	dvHdr.style.filter = 'alpha(opacity = 85)'; // IE
	dvHdr.style.opacity = '0.85'; // FF
}

function DefBdyStyle(){
	dvBdy.style.borderBottom = '1px solid #A5CFE9';
	dvBdy.style.borderLeft = '1px solid #A5CFE9';
	dvBdy.style.borderRight = '1px solid #A5CFE9';
	dvBdy.style.fontFamily = 'arial';
	dvBdy.style.fontSize = '11';
	dvBdy.style.padding = '3';
	dvBdy.style.color = '#1B4966';
	dvBdy.style.background = '#FFFFFF';
	dvBdy.style.filter = 'alpha(opacity=85)'; // IE
	dvBdy.style.opacity = '0.85'; // FF
}

function IsElemBO(txt){
if (!txt || typeof(txt) != 'string') 
    return false;
if ((txt.indexOf('header') > -1) && (txt.indexOf('body') > -1) && (txt.indexOf('[') > -1) && (txt.indexOf('[') > -1)) 
   return true;
else
   return false;
}

function ScanBO(curNode){
	  if (IsElemBO(curNode.title))
	  {	        
            curNode.boHDR = GetParam('header', curNode.title);
            curNode.boBDY = unescape(GetParam('body', curNode.title));
            // custom for Virtual map View
            //curNode.boBDY = ShowTooltip(curNode.boBDY);
            //---
			curNode.boCSSBDY = GetParam('cssbody', curNode.title);			
			curNode.boCSSHDR = GetParam('cssheader', curNode.title);
			curNode.IEbugfix = (GetParam('HideSelects', curNode.title) == 'on') ? true:false;
			curNode.fixX = parseInt(GetParam('fixedrelx', curNode.title));
			curNode.fixY = parseInt(GetParam('fixedrely', curNode.title));
			curNode.absX = parseInt(GetParam('fixedabsx', curNode.title));
			curNode.absY = parseInt(GetParam('fixedabsy', curNode.title));
			curNode.offY = (GetParam('offsety', curNode.title) != '') ? parseInt(GetParam('offsety', curNode.title)):10;
			curNode.offX = (GetParam('offsetx', curNode.title) != '') ? parseInt(GetParam('offsetx', curNode.title)):10;
			curNode.fade = (GetParam('fade', curNode.title) == 'on') ? true:false;
			curNode.fadespeed = (GetParam('fadespeed', curNode.title) != '') ? GetParam('fadespeed', curNode.title):0.04;
			curNode.delay=(GetParam('delay', curNode.title) != '') ? parseInt(GetParam('delay', curNode.title)):0;
			if (GetParam('requireclick', curNode.title) == 'on')
			{
				curNode.requireclick = true;
				document.all ? curNode.attachEvent('onclick', ShowHideBox):curNode.addEventListener('click', ShowHideBox, false);
				document.all ? curNode.attachEvent('onmouseover', HideBox):curNode.addEventListener('mouseover', HideBox, false);
			}
			else
			{// Note : if requireclick is on the stop clicks are ignored   			
   			if (GetParam('doubleclickstop', curNode.title) != 'off')
   			{
   				document.all ? curNode.attachEvent('ondblclick', PauseBox):curNode.addEventListener('dblclick', PauseBox, false);
   			}	
   			if (GetParam('singleclickstop',curNode.title) == 'on')
   			{
   				document.all ? curNode.attachEvent('onclick', PauseBox):curNode.addEventListener('click', PauseBox, false);
   			}
   		}
			curNode.windowLock = GetParam('windowlock', curNode.title).toLowerCase() == 'off' ? false:true;
			curNode.title = '';
			curNode.hasbox = 1;
	   }
	   else
	      curNode.hasbox = 2;   
}


function GetParam(param,list){
	var reg = new RegExp('([^a-zA-Z]' + param + '|^' + param + ')\\s*=\\s*\\[\\s*(((\\[\\[)|(\\]\\])|([^\\]\\[]))*)\\s*\\]');
	var res = reg.exec(list);
	var returnvar;
	if(res)
		return res[2].replace('[[','[').replace(']]',']');
	else
		return '';
}

function Left(elem){	
	var x=0;
	if (elem.calcLeft)
		return elem.calcLeft;
	var oElem = elem;
	while(elem){
		 if ((elem.currentStyle) && (!isNaN(parseInt(elem.currentStyle.borderLeftWidth))) && (x != 0))
		 	x += parseInt(elem.currentStyle.borderLeftWidth);
		 x += elem.offsetLeft;
		 elem = elem.offsetParent;
	  } 
	oElem.calcLeft = x;
	return x;
}

function Top(elem){
	 var x = 0;
	 if (elem.calcTop)
	 	return elem.calcTop;
	 var oElem = elem;
	 while(elem)
	 {		
	 	 if ((elem.currentStyle) && (!isNaN(parseInt(elem.currentStyle.borderTopWidth))) && (x != 0))
		 	x += parseInt(elem.currentStyle.borderTopWidth); 
		 x += elem.offsetTop;
	         elem = elem.offsetParent;
 	 } 
 	 oElem.calcTop = x;
 	 return x; 	 
}

var ah,ab;
function ApplyStyles(){
	if(ab)
		oDv.removeChild(dvBdy);
	if (ah)
		oDv.removeChild(dvHdr);
	dvHdr = document.createElement("div");
	dvBdy = document.createElement("div");
	CBE.boCSSBDY?dvBdy.className = CBE.boCSSBDY : DefBdyStyle();
	CBE.boCSSHDR?dvHdr.className = CBE.boCSSHDR : DefHdrStyle();
	dvHdr.innerHTML = CBE.boHDR;
	dvBdy.innerHTML = CBE.boBDY;
	ah = false;
	ab = false;
	if (CBE.boHDR != '')
	{		
		oDv.appendChild(dvHdr);
		ah = true;
	}	
	if (CBE.boBDY != '')
	{
		oDv.appendChild(dvBdy);
		ab = true;
	}	
}

var CSE, iterElem,LSE,CBE,LBE, totalScrollLeft, totalScrollTop, width, height ;
var ini = false;

function SHW(){
   if (document.body && (document.body.clientWidth != 0))
   {
      width = document.body.clientWidth;
      height = document.body.clientHeight;
   }
   if (document.documentElement && (document.documentElement.clientWidth != 0) && (document.body.clientWidth + 20 >= document.documentElement.clientWidth))
   {
      width = document.documentElement.clientWidth;   
      height = document.documentElement.clientHeight;   
   }   
   return [width,height];
}

var ID = null;
function MoveMouse(e){
   //boxMove=true;
	e ? evt = e : evt = event;
	
	CSE = evt.target ? evt.target : evt.srcElement;
	
	if (!CSE.hasbox)
	{
	   // Note we need to scan up DOM here, some elements like TR don't get triggered as srcElement
	   iElem = CSE;
	   while ((iElem.parentNode) && (!iElem.hasbox))
	   {
	      ScanBO(iElem);
	      iElem = iElem.parentNode;
	   }	   
	}
	
	if ((CSE != LSE) && (!IsChild(CSE, dvHdr)) && (!IsChild(CSE, dvBdy)))
	{		
	   if (!CSE.boxItem)
	   {
			iterElem = CSE;
			while ((iterElem.hasbox == 2) && (iterElem.parentNode))
				iterElem = iterElem.parentNode; 
			CSE.boxItem = iterElem;
		}
		iterElem = CSE.boxItem;
		if (CSE.boxItem&&(CSE.boxItem.hasbox == 1))
		{
			LBE = CBE;
			CBE = iterElem;
			if (CBE != LBE)
			{
				ApplyStyles();
				if (!CBE.requireclick)
					if (CBE.fade)
					{
						if (ID != null)
							clearTimeout(ID);
						ID=setTimeout("FadeIn("+ CBE.fadespeed +")", CBE.delay);
					}
					else
					{
						if (ID != null)
							clearTimeout(ID);
						COL = 1;
						ID = setTimeout("oDv.style.visibility='visible';ID=null;", CBE.delay);						
					}
				if (CBE.IEbugfix) 
				{
				    HideSelects();
				} 
				fixposx = !isNaN(CBE.fixX) ? Left(CBE) + CBE.fixX : CBE.absX;
				fixposy = !isNaN(CBE.fixY) ? Top(CBE) + CBE.fixY : CBE.absY;			
				lockX = 0;
				lockY = 0;
				boxMove = true;
				ox = CBE.offX ? CBE.offX : 10;
				oy = CBE.offY ? CBE.offY : 10;
			}
		}
		else 
			if (!IsChild(CSE, dvHdr) && !IsChild(CSE, dvBdy) && (boxMove))
			{
				// The conditional here fixes flickering between tables cells.
				if ((!IsChild(CBE, CSE)) || (CSE.tagName != 'TABLE'))
				{   			
   					CBE = null;
   					if (ID != null)
  						clearTimeout(ID);
   					FadeOut();
   					ShowSelects();
				}
			}
		LSE = CSE;
	}
	else 
	    if (((IsChild(CSE, dvHdr) || IsChild(CSE, dvBdy)) && (boxMove)))
		{
		    totalScrollLeft = 0;
		    totalScrollTop = 0;
    		
		    iterElem = CSE;
		    while(iterElem)
		    {
			    if(!isNaN(parseInt(iterElem.scrollTop)))
				    totalScrollTop += parseInt(iterElem.scrollTop);
			    if(!isNaN(parseInt(iterElem.scrollLeft)))
				    totalScrollLeft += parseInt(iterElem.scrollLeft);
			    iterElem = iterElem.parentNode;			
		    }
		    if (CBE != null)
		    {
			    boxLeft = Left(CBE) - totalScrollLeft;
			    boxRight = parseInt(Left(CBE) + CBE.offsetWidth) - totalScrollLeft;
			    boxTop = Top(CBE) - totalScrollTop;
			    boxBottom = parseInt(Top(CBE) + CBE.offsetHeight) - totalScrollTop;
			    DoCheck();
		    }
	    }
	
	if (boxMove&&CBE)
	{
		// This added to alleviate bug in IE6 w.r.t DOCTYPE
		bodyScrollTop = document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
		bodyScrollLet = document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft;
		mouseX = evt.pageX ? evt.pageX - bodyScrollLet : evt.clientX - document.body.clientLeft;
		mouseY = evt.pageY ? evt.pageY - bodyScrollTop : evt.clientY - document.body.clientTop;
		if ((CBE) && (CBE.windowLock))
		{
			mouseY < -oy ? lockY = -mouseY - oy : lockY = 0;
			mouseX < -ox ? lockX = -mouseX - ox : lockX = 0;
			mouseY > (SHW()[1] - oDv.offsetHeight - oy) ? lockY = -mouseY+SHW()[1] - oDv.offsetHeight - oy : lockY = lockY;
			mouseX > (SHW()[0] - dvBdy.offsetWidth - ox) ? lockX = -mouseX - ox + SHW()[0] - dvBdy.offsetWidth : lockX = lockX;			
		}
		oDv.style.left = ((fixposx) || (fixposx == 0)) ? fixposx : bodyScrollLet + mouseX + ox + lockX + "px";
		oDv.style.top = ((fixposy) || (fixposy == 0)) ? fixposy : bodyScrollTop + mouseY + oy + lockY + "px";		
		
	}
}

function DoCheck(){	
	if (   (mouseX < boxLeft) || (mouseX  > boxRight) || (mouseY < boxTop) || (mouseY > boxBottom))
	{
		if (!CBE.requireclick)
			FadeOut();
		if (CBE.IEbugfix) 
		{
		    ShowSelects();
		}
		CBE=null;
	}
}

function PauseBox(e){
   e ? evt = e:evt = event;
	boxMove = false;
	evt.cancelBubble = true;
}

function ShowHideBox(e){
	oDv.style.visibility = (oDv.style.visibility != 'visible') ? 'visible' : 'hidden';
}

function HideBox(e){
	oDv.style.visibility = 'hidden';
}

var COL = 0;
var stopfade = false;
function FadeIn(fs){
		ID = null;
		COL = 0;
		oDv.style.visibility = 'visible';
		FadeIn2(fs);
}

function FadeIn2(fs){
		COL = COL + fs;
		COL = (COL > 1) ? 1:COL;
		oDv.style.filter = 'alpha(opacity='+parseInt(100*COL)+')';
		oDv.style.opacity = COL;
		if (COL < 1)
		 setTimeout("FadeIn2("+ fs +")", 20);		
}


function FadeOut(){
	oDv.style.visibility = 'hidden';
	
}

function IsChild(s,d){
	while(s)
	{
		if ( s == d) 
			return true;
		s = s.parentNode;
	}
	return false;
}

var cSrc;
function IsMove(e){
	
	// Hidden infobox
	// if (infoBox) infoBox.style.display = "none";
	
	e ? evt = e:evt = event;
	cSrc = evt.target ? evt.target : evt.srcElement;
	
	if ((!boxMove) && (!IsChild(cSrc, oDv)))
	{
		FadeOut();
		if (CBE && CBE.IEbugfix) 
		{
		    ShowSelects();
		}
		boxMove = true;
		CBE = null;
	}
}

function ShowSelects(){
   var elements = document.getElementsByTagName("select");
   for (i = 0; i < elements.length; i++)
      elements[i].style.visibility = 'visible';
}

function HideSelects(){
   var elements = document.getElementsByTagName("select");
   for (i = 0; i < elements.length; i++)
	  elements[i].style.visibility = 'hidden';
}
//end Tooltip
function DisplayErrors(functionName, errorMessage){
   //alert(functionName + " Error:: " + errorMessage);
}
//Sort data
function SortData(clientID, sourceId){
	try
	{
		var srcOrg = (document.getElementById(sourceId).src).toString();
		var mySRC = srcOrg.split("/");
		var myImage = mySRC[mySRC.length-1];
		if (myImage.toLowerCase() == "asc.gif")
		{
			SortOption(clientID, "asc");
			document.getElementById(sourceId).src = srcOrg.substring(0, srcOrg.length-7) + 'desc.gif';
		}
		else
		{
			SortOption(clientID, "desc");
			document.getElementById(sourceId).src = srcOrg.substring(0, srcOrg.length-8) + 'asc.gif';
		}
		
	}
	catch(ex)
	{
		DisplayErrors("SortData", ex.message);
	}
}
function SortOption(clientID, condition){
	try
	{
		var myObjects = eval(clientID + "ArrayObjects");
		var myResults = new Array();		 
		var objDa = eval(clientID + "ArrayData");
			
		if (condition == "asc")
			objDa = objDa.sort();
		else
			objDa = objDa.reverse();

		for (var i = 0; i < objDa.length; i++)
		{
			var temp = (objDa[i]).split(";=;");
			var e1 = temp[1];
			for (var j = 0; j < myObjects.length; j++)
			{
				var tm = unescape(myObjects[j]);
				if ((tm.indexOf(e1) != -1))
				{
					myResults[i] = myObjects[j];
				}				
			}
		}
		var html = "";
		for (var n = 0; n < myResults.length; n++)
		{	
			html += myResults[n] + "<br>";
		}
		document.getElementById(clientID).innerHTML = html;	
	}
	catch(ex)
	{
		DisplayErrors("SortOption", ex.message);
	}
}
function ChangeImages(sourceId, condition, imageName){
	try
	{
		var myImage = document.getElementById(imageName).innerText;
		if (condition == 1)
		{
			document.getElementById(sourceId).style.backgroundImage = "url(~/wpresources/Bamboo.VirtualMapView/spring.gif)";			
		}
		else
		{
			document.getElementById(sourceId).style.backgroundImage = "url(~/wpresources/Bamboo.VirtualMapView/" + myImage + ")";
		}
	}
	catch(ex)
	{
		DisplayErrors("ChangeImages", ex.message);
	}
}
function VirtualMapViewEditItem(optionID, divID, conID){
    try
    {
        var selectedIndex = document.getElementById(optionID).options.selectedIndex;
        var selectedText = document.getElementById(optionID).options[selectedIndex].text;

        if (selectedText.indexOf("--") != -1)
        {
            var divTag = document.getElementById(divID);        
            document.getElementById(conID).value = selectedText.substring(2, selectedText.length);
            divTag.style.display = "block";
			divTag.style.zIndex = 999;
        }
    }
    catch(ex)
    {
        DisplayErrors("VirtualMapViewEditItem", ex.message);
    }
}
function SetDisabledControl(id){
	var flag = document.getElementById(id).disabled;
	document.getElementById(id).disabled = !flag;
}

