﻿
    var detect = navigator.userAgent.toLowerCase();
	var OS,browser,version,total,thestring,hideit;

	if (checkIt('konqueror'))
	{
		browser = "Konqueror";
		OS = "Linux";
	}
	else if (checkIt('safari')) browser = "Safari"
	else if (checkIt('omniweb')) browser = "OmniWeb"
	else if (checkIt('opera')) browser = "Opera"
	else if (checkIt('webtv')) browser = "WebTV"
	else if (checkIt('icab')) browser = "iCab"
	else if (checkIt('firefox')) browser = "FireFox"
	else if (checkIt('msie')) browser = "Internet Explorer"
	else if (!checkIt('compatible'))
	{
		browser = "Netscape Navigator"
		version = detect.charAt(8);
	}
	else browser = "An unknown browser";

	if (!version) version = detect.charAt(place + thestring.length);

	if (!OS)
	{
		if (checkIt('linux')) OS = "Linux";
		else if (checkIt('x11')) OS = "Unix";
		else if (checkIt('mac')) OS = "Mac"
		else if (checkIt('win')) OS = "Windows"
		else OS = "an unknown operating system";
	}

	function checkIt(string)
	{
		place = detect.indexOf(string) + 1;
		thestring = string;
		return place;
	}

	hideit=false;
	
	if (browser=='Safari') {hideit=false;}
	if (browser=='Opera') {hideit=false;}
	if (browser=='WebTV') {hideit=true;}
	if (browser=='Internet Explorer' && OS=='Mac') {hideit=true;}

		var map = null;
		
		function OnPageLoad()
		{	
		   	if (hideit== true) {				
				var c = document.getElementById('maphider');
				c.style.visibility='hidden';
				c.style.display='none';
			}
			
			map = new VEMap('mapcontainer');
			map.onLoadMap = fnLoadCollection;			
			map.LoadMap(
				new VELatLong(48.6044,-100.2977), 
				3, 'r', false );
		}
		
		function fnLoadCollection()
		{
            AddPins();
		}
		
		function AddPin(title, description, latitude, longitude) {
		
		    var iconpath = "http://www.dreamylinens.com/mapstar.gif";
		                                  
            description = description + 
            "<br/><a href='javascript:map.SetCenterAndZoom(new VELatLong(" +
                latitude + "," + longitude + "),15);scroll(0,200);'>Zoom to Street Level</a><br>";
                            
		    
		    var shape = new VEShape(VEShapeType.Pushpin, new VELatLong(latitude,longitude));          
		    shape.SetTitle(title);          
		    shape.SetDescription(description);  
		    shape.SetCustomIcon(iconpath);                  
		    map.AddShape(shape);
		}
		
		
		function FindLoc()
        {
            try
            {
                map.Find(null, document.getElementById('txtWhere').value);
            }
            catch(e)
            {
                //alert(e.message);
            }
        }
		
		

		

		
		function ParseURL(inline) {
			
			var url = "";
			
			var posit = inline.indexOf('<a href');
			if (posit>0) {
				posit= inline.indexOf("'",posit+1)+1;
				var posit2 = inline.indexOf("'",posit+2);
				url= inline.substr(posit, posit2-posit);
			}
			
			return url;
		}
		
		function ParseAddress(inline) {
			
			//alert(inline);
			var addr = replaceString(inline,'&#10;','<br>');
			addr = replaceString(inline,'&#60;BR&#47;&#62;','<br>');
			
			var posit = addr.indexOf('<p>');
			if (posit>0) {
				addr= addr.substr(0, posit);;
			}
			
			return addr;
		}
		
		function ParseName(inline) {
			var title=inline;
			var posit = 0;
			posit = inline.indexOf('</a>');
			if (posit>0) {
				title = inline.substring(posit+4);
			}
			return title;
		}
		
	function replaceString(sString, sReplaceThis, sWithThis) { 
    if (sReplaceThis != "" && sReplaceThis != sWithThis) {
      var counter = 0;
      var start = 0;
      var before = "";
      var after = "";
      while (counter<sString.length) {
        start = sString.indexOf(sReplaceThis, counter);
        if (start == -1){
         break;
         } else {
           before = sString.substr(0, start);
           after = sString.substr(start + sReplaceThis.length, sString.length);
           sString = before + sWithThis + after;
           counter = before.length + sWithThis.length;
          }
        }
      }
   return sString;
  }

  