﻿
var url=window.location.toString();var base=getUrl();if(url.indexOf("https:")!=-1)
{base=base.replace("http:","https:");}
function getUrl()
{var base="http://www.vacuumworld.co.uk/";if(window.location.toString().indexOf(".co")==-1)
base="http://chrispc/VacuumWorldWeb/";if(window.location.toString().indexOf("https")!=-1)
base=base.replace("http","https");return base;}
var m_imgPfx=base.substring(0,base.length-1);function StringBuilder(value)
{this.strings=new Array("");this.append(value);}
StringBuilder.prototype.append=function(value)
{if(value)
{this.strings.push(value);}}
StringBuilder.prototype.clear=function()
{this.strings.length=1;}
StringBuilder.prototype.toString=function()
{return this.strings.join("");}
function rollover(img_src)
{document.MainImageRollover.src=img_src;}
function windowlocation(href)
{window.location=base+href;}
var offsetfrommouse=[-350,-100];var displayduration=0;var currentimageheight=5;if(document.getElementById||document.all){document.write('<div id="CssPopUp">');document.write('</div>');}
function gettrailobj()
{if(document.getElementById)
return document.getElementById("CssPopUp").style
else if(document.all)
return document.all.trailimagid.style}
function gettrailobjnostyle()
{if(document.getElementById)
return document.getElementById("CssPopUp")
else if(document.all)
return document.all.trailimagid}
function truebody()
{return(!window.opera&&document.compatMode&&document.compatMode!="BackCompat")?document.documentElement:document.body}
function showtrail(width,name,description)
{offsetfrommouse=[-320,-50];document.onmousemove=followmouse;var newHTML=new StringBuilder();newHTML.append('<div class="CssRollOver">');newHTML.append('<div class="speech'+width+'">');newHTML.append('<h5>'+name+'</h5>');newHTML.append('<span>'+description+'</span>');newHTML.append('</div>');newHTML.append('</div>');gettrailobjnostyle().innerHTML=newHTML.toString();gettrailobj().visibility="visible";}
function hidetrail(){gettrailobj().visibility="hidden"
document.onmousemove=""
gettrailobj().left="-500px"}

function showmoreproductinfo(width,image,name,descriptor,paragraph,dimensions, id)
{offsetfrommouse=[-0,-350];document.onmousemove=followmouse;var newHTML=new StringBuilder();newHTML.append('<div class="CssRollOver">');newHTML.append('<div class="speech'+width+'">');newHTML.append('<img src="i/ProductImages/'+image+'" />');newHTML.append('<h5>'+name+'</h5>');newHTML.append('<span><b>'+descriptor+'</b></span><span>Vacuum World Ref:<b>VW'+id+'</b></span>');if(dimensions!="")
newHTML.append(dimensions);newHTML.append('</div>');newHTML.append('</div>');gettrailobjnostyle().innerHTML=newHTML.toString();gettrailobj().visibility="visible";}

function showmoreinfoleft(width,image,name,descriptor,paragraph,dimensions)
{offsetfrommouse=[200,-100];document.onmousemove=followmouse;var newHTML=new StringBuilder();newHTML.append('<div class="CssRollOver">');newHTML.append('<div class="speech'+width+'">');if(image!="")
newHTML.append('<img src="i/ProductImages/'+image+'" />');newHTML.append('<h5>'+name+'</h5>');newHTML.append('<span>'+descriptor+'</span>');newHTML.append(paragraph);if(dimensions!="")
newHTML.append(dimensions);newHTML.append('</div>');newHTML.append('</div>');gettrailobjnostyle().innerHTML=newHTML.toString();gettrailobj().visibility="visible";}

function showmoreinfo(width,image,name,descriptor,paragraph,dimensions)
{offsetfrommouse=[-350,-100];document.onmousemove=followmouse;var newHTML=new StringBuilder();newHTML.append('<div class="CssRollOver">');newHTML.append('<div class="speech'+width+'">');if(image!="")
newHTML.append('<img src="i/ProductImages/'+image+'" />');newHTML.append('<h5>'+name+'</h5>');newHTML.append('<span>'+descriptor+'</span>');newHTML.append(paragraph);if(dimensions!="")
newHTML.append(dimensions);newHTML.append('</div>');newHTML.append('</div>');gettrailobjnostyle().innerHTML=newHTML.toString();gettrailobj().visibility="visible";}


function showimage(width,image)
{offsetfrommouse=[-350,-250];document.onmousemove=followmouse;var newHTML=new StringBuilder();newHTML.append('<div class="CssRollOver">');newHTML.append('<div class="speech'+width+'">');newHTML.append('<img src="i/ProductGallery/'+image+'" />');newHTML.append('</div>');newHTML.append('</div>');gettrailobjnostyle().innerHTML=newHTML.toString();gettrailobj().visibility="visible";}

function showcleanerimage(width,image)
{offsetfrommouse=[-100,-350];document.onmousemove=followmouse;var newHTML=new StringBuilder();newHTML.append('<div class="CssRollOver">');newHTML.append('<div class="speech'+width+'">');newHTML.append('<img src="i/ProductImages/'+image+'" />');newHTML.append('</div>');newHTML.append('</div>');gettrailobjnostyle().innerHTML=newHTML.toString();gettrailobj().visibility="visible";}

function followmouse(e){var xcoord=offsetfrommouse[0]
var ycoord=offsetfrommouse[1]
var docwidth=document.all?truebody().scrollLeft+truebody().clientWidth:pageXOffset+window.innerWidth-15
var docheight=document.all?Math.min(truebody().scrollHeight,truebody().clientHeight):Math.min(window.innerHeight)
if(typeof e!="undefined")
{if(docwidth-e.pageX<300)
{xcoord=e.pageX-xcoord-300;}
else
{xcoord=e.pageX-xcoord-300;}
if(xcoord<0)
xcoord=350;if(docheight-e.pageY<(currentimageheight+200))
{ycoord+=e.pageY-Math.max(0,(200+currentimageheight+e.pageY-docheight-truebody().scrollTop));}
else
{ycoord+=e.pageY;}}
else if(typeof window.event!="undefined"){if(docwidth-event.clientX<300){xcoord=event.clientX+truebody().scrollLeft-xcoord-300;}else{xcoord=event.clientX+truebody().scrollLeft-xcoord-300;}
if(docheight-event.clientY<(currentimageheight+200)){ycoord+=event.clientY+truebody().scrollTop-Math.max(0,(200+currentimageheight+event.clientY-docheight));}else{ycoord+=truebody().scrollTop+event.clientY;}}
var docwidth=document.all?truebody().scrollLeft+truebody().clientWidth:pageXOffset+window.innerWidth-15
var docheight=document.all?Math.max(truebody().scrollHeight,truebody().clientHeight):Math.max(document.body.offsetHeight,window.innerHeight)
if(ycoord<0){ycoord=ycoord*-1;}
gettrailobj().left=xcoord+"px"
gettrailobj().top=ycoord+"px"}
function showTerms()
{var url=base+"Terms.aspx";zzz=window.open(url,'','width=900,height=800,scrollbars=yes,left=200,top=100')
zzz.focus()}

/*
function load()
{if(GBrowserIsCompatible())
{var map=new GMap2(document.getElementById("map"));map.addControl(new GSmallMapControl());map.addControl(new GMapTypeControl());map.setCenter(new GLatLng(55.167475,-1.688731),13);map.setMapType(G_SATELLITE_MAP);var blueIcon=new GIcon(G_DEFAULT_ICON);blueIcon.image="http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";markerOptions={icon:blueIcon};var bounds=map.getBounds();var southWest=bounds.getSouthWest();var northEast=bounds.getNorthEast();var lngSpan=northEast.lng()-southWest.lng();var latSpan=northEast.lat()-southWest.lat();var point=new GLatLng(55.167475,-1.688731);map.addOverlay(new GMarker(point,markerOptions));}}
*/

function load() 
{
  if (GBrowserIsCompatible()) 
  {
    var map = new GMap2(document.getElementById("map"));    
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng(55.167475,-1.688731), 13);        
    map.setMapType(G_SATELLITE_MAP); 
         
          
    // Create a base icon for all of our markers that specifies the
    // shadow, icon dimensions, etc.
    var baseIcon = new GIcon(G_DEFAULT_ICON);
    baseIcon.shadow = "http://chrispc/VacuumWorldImages/GoogleVacuumWorldShadow.png";
    baseIcon.iconSize = new GSize(100, 50);
    baseIcon.shadowSize = new GSize(150, 50);
    baseIcon.iconAnchor = new GPoint(9, 34);
    baseIcon.infoWindowAnchor = new GPoint(9, 2);
              
    // Creates a marker whose info window displays the letter corresponding
    // to the given index.
    function createMarker(point, index) 
    {
        // Create a lettered icon for this point using our icon class
        var letter = String.fromCharCode("A".charCodeAt(0) + index);
        var letteredIcon = new GIcon(baseIcon);
        letteredIcon.image = "http://chrispc/VacuumWorldImages/GoogleVacuumWorld.png";

        // Set up our GMarkerOptions object
        markerOptions = { icon:letteredIcon };
        var marker = new GMarker(point, markerOptions);

        GEvent.addListener(marker, "click", function() 
        {
            marker.openInfoWindowHtml("Marker <b>" + baseIcon + "</b>");
        });
        return marker;
    }     
    /*
    // Create our "tiny" marker icon
    var blueIcon = new GIcon(G_DEFAULT_ICON);
    blueIcon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";                    
    // Set up our GMarkerOptions object
    markerOptions = { icon:blueIcon };
    */
    
    var bounds = map.getBounds();
    var southWest = bounds.getSouthWest();
    var northEast = bounds.getNorthEast();
    var lngSpan = northEast.lng() - southWest.lng();
    var latSpan = northEast.lat() - southWest.lat();
    var point = new GLatLng(55.167475,-1.688731);   
    map.addOverlay(createMarker(point, 1)); 
    map.addOverlay(new GMarker(point, markerOptions));
  }  
}

function BuyNow(id)
{ window.open(base + 'BuyNow.aspx?BuyNowID=' + id, 'mywindow') }

function GetPage() {
    alert("GetPage OK");
    PageMethods.Message("inbound", Success, Failure);   
}
function Success(result, userContext, methodName)
{
    alert("Success"); alert(result); 
}

function Failure(error, userContext, methodName)
{ 
    alert("Failure"); alert(error.get_message()); 
}


