﻿function makeMaxWin(url)
{
	var vheight = screen.height - 200;
	var vwidth = screen.width - 100;
	makeWin(url, vheight, vwidth)
}

function makeWin(tUrl, strheight, strwidth) {
	agent = navigator.userAgent;
	windowName = "DefinitionWindow";
	
	var vwidth = strwidth;
	var vheight = strheight;
	var vtop = ((screen.height - vheight)/2);
	var vleft = ((screen.width - vwidth)/2); 
	params  = "";
	params += "toolbar=0,";
	params += "location=0,";
	params += "directories=0,";
	params += "status=0,";
	params += "menubar=0,";
	params += "scrollbars=1,";
	params += "resizable=1,";
	params += "width=" + vwidth + ",";
	params += "height=" + vheight + ",";
	params += "top=" + vtop + ",";
	params += "left=" + vleft;
	
	win = window.open(tUrl, windowName, params);
	if (agent.indexOf("Mozilla/2") != -1 && agent.indexOf("Win") == -1) {
	    win = window.open(url, windowName , params);
	}
	if (!win.opener) {
	    win.opener = window;
	}
}

function showItemLayer(Layer)
{	
    //Hide all
    for (i = 1; i < 21; i++)
    {
        if (document.getElementById('divItem' + i) != null)
        {
        	document.getElementById('divItem' + i).style.display = "none";
            //Turn off class
            if (document.getElementById('liItem' + i) != null)
            	document.getElementById('liItem' + i).className = "";
        }
        else
            break;
    }

    //Show 1 layer and set class to "highlight"
    if (document.getElementById('div' + Layer) != null)
        document.getElementById('div' + Layer).style.display = "block";	
    if (document.getElementById('li' + Layer) != null)
        document.getElementById('li' + Layer).className = "highlight";
}


var mapCounter = 0;

function showLocation(latitude, longitude, description)
{
    showLocation(latitude, longitude, description, "/Common/Images/custom/pushpin.gif");
}

function showLocation(latitude, longitude, description, pushPin)
{
    var icon = new GIcon();
    icon.image = pushPin;
    icon.iconSize = new GSize(47, 24);
    icon.iconAnchor = new GPoint(6, 20);
    icon.infoWindowAnchor = new GPoint(5, 1);

    var point = new GLatLng(latitude, longitude);
    var marker = new GMarker(point, icon);
    GEvent.addListener(marker, "click", 
        function() 
        {
            marker.openInfoWindowHtml(description);
        }
    );
    map.addOverlay(marker);
    if (mapCounter == 0)
        marker.openInfoWindowHtml(description);
    mapCounter++;
}

function centerAndDisplayLocation(latitude, longitude, description)
{
    centerAndDisplayLocation(latitude, longitude, description, "/Common/Images/custom/pushpin.gif");
}

function centerAndDisplayLocation(latitude, longitude, description, pushPin)
{
    var icon = new GIcon();
    icon.image = pushPin;
    icon.iconSize = new GSize(47, 24);
    icon.iconAnchor = new GPoint(6, 20);
    icon.infoWindowAnchor = new GPoint(5, 1);

    var point = new GLatLng(latitude, longitude);
    var marker = new GMarker(point, icon);
    GEvent.addListener(marker, "click", 
        function() 
        {
            marker.openInfoWindowHtml(description);
        }
    );
    map.addOverlay(marker);
    marker.openInfoWindowHtml(description);
    map.setCenter(new GLatLng(latitude, longitude), 13);
}

function centerAndDisplayLocationZoom(latitude, longitude, description, pushPin, zoom)
{
    var icon = new GIcon();
    icon.image = pushPin;
    icon.iconSize = new GSize(47, 24);
    icon.iconAnchor = new GPoint(6, 20);
    icon.infoWindowAnchor = new GPoint(5, 1);

    var point = new GLatLng(latitude, longitude);
    var marker = new GMarker(point, icon);
    GEvent.addListener(marker, "click", 
        function() 
        {
            marker.openInfoWindowHtml(description);
        }
    );
    map.addOverlay(marker);
    marker.openInfoWindowHtml(description);
    map.setCenter(new GLatLng(latitude, longitude), zoom);
}

function changePhoto(ddlID, imageID)
{
    var index = document.getElementById(ddlID).selectedIndex - 1;
    if (smallPhotos[ddlID] != null) {
        if (smallPhotos[ddlID][index] != null)
        {
            if (smallPhotos[ddlID][index] != '')
            {
                document.getElementById(imageID).src = '/Common/Images/custom/products/' + smallPhotos[ddlID][index];
            }
        }
    }
}

function checkFormSubmit(form) {
    if (typeof (Page_ClientValidate) == 'function') {
        Page_ClientValidate();
    }
    return Page_IsValid;
}

function checkFormSubmit(form, group) {
    if (typeof (Page_ClientValidate) == 'function') {
        Page_ClientValidate(group);
    }
    return Page_IsValid;
}


function showLocation(ele, latitude, longitude, description, locationID, locationIndex, pushPin) {

    document.getElementById('LocationID').value = locationID;
    document.getElementById('LocationIndex').value = locationIndex;
    document.getElementById('divSelected').innerHTML = description;
    
    if (typeof (pushPin) != "undefined" && pushPin != "") {
        var icon = new GIcon(G_DEFAULT_ICON);
        icon.image = pushPin;
        icon.iconSize = new GSize(36, 28);
        icon.iconAnchor = new GPoint(18, 14);
        icon.infoWindowAnchor = new GPoint(18, 14);
    }
    else {
        var icon = new GIcon(G_DEFAULT_ICON);
    }

    var point = new GLatLng(latitude, longitude);
    var marker = new GMarker(point, icon);
    GEvent.addListener(marker, 'click',
        function() {
            marker.openInfoWindowHtml(description);
        }
    );
    map.addOverlay(marker);
    marker.openInfoWindowHtml(description);
    map.setCenter(new GLatLng(latitude, longitude), 13);

    if (ele.id != undefined) {
        $(".selectedLocation").each(function(item) { $(this).removeClass("selectedLocation"); });
        $(ele).addClass("selectedLocation");
    }
}
