/* 
 This file was created with Dashcode.  
 You may not edit this file.
 */

//
// Function: load()
// Called by HTML body element's onload event when the web application is ready to start
//
function load()
{
    dashcode.setupParts();
    hideLocationBar();
}

function hideLocationBar()
{
document.getElementById("header").style.visibility = "visible";
window.scrollTo(0, 1); // pan to the bottom, hides the location bar
}

function load()
{
    dashcode.setupParts();
    document.getElementById("header").style.visibility = "visible";
window.scrollTo(0, 1); // pan to the bottom, hides the location bar
}

function getLocationSearch()
{
navigator.geolocation.getCurrentPosition(getSearch, error, {enableHighAccuracy: true});
}

function getSearch(position)
{
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;

var searchFieldValue = document.getElementById("searchfield");
searchFieldValue = searchFieldValue.value;

location = "http://maps.google.com/maps?f=d&source=s_d&saddr="+latitude+longitude+"&daddr="+searchFieldValue;
}

function error()
{
alert("Please reload the page and accept the location request to get directions to places near you.");
}

function getLocationGas(event)
{
    navigator.geolocation.getCurrentPosition(getGas, error, {enableHighAccuracy: true});
}

function getGas(position)
{
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;

location = "http://maps.google.com/maps?f=d&source=s_d&saddr="+latitude+longitude+"&daddr=gas stations -7-eleven";
}


function getLocationCoffee(event)
{
    navigator.geolocation.getCurrentPosition(getCoffee, error, {enableHighAccuracy: true});
}

function getCoffee(position)
{
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;

location = "http://maps.google.com/maps?f=d&source=s_d&saddr="+latitude+longitude+"&daddr=Starbucks|Peet's";
}

function getLocationPharmacy(event)
{
    navigator.geolocation.getCurrentPosition(getPharmacy, error, {enableHighAccuracy: true});
}

function getPharmacy(position)
{
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;

location = "http://maps.google.com/maps?f=d&source=s_d&saddr="+latitude+longitude+"&daddr=Pharmacy";
}


function getLocationATM(event)
{
    navigator.geolocation.getCurrentPosition(getATM, error, {enableHighAccuracy: true});
}

function getATM(position)
{
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;

location = "http://maps.google.com/maps?f=d&source=s_d&saddr="+latitude+longitude+"&daddr=ATM";
}

function getLocationFood(event)
{
    navigator.geolocation.getCurrentPosition(getFood, error, {enableHighAccuracy: true});
}

function getFood(position)
{
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;

location = "http://maps.google.com/maps?f=d&source=s_d&saddr="+latitude+longitude+"&daddr=Restaurant";
}

function getLocationGroceries(event)
{
    navigator.geolocation.getCurrentPosition(getGroceries, error, {enableHighAccuracy: true});
}

function getGroceries(position)
{
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;

location = "http://maps.google.com/maps?f=d&source=s_d&saddr="+latitude+longitude+"&daddr=Groceries";
}

function showInfo(event)
{
    var tryConfirm = window.confirm("Places v1.0, created by gizmosachin Web Apps. Icon by misecia on Twitter. Click OK to visit our website.");
    if(tryConfirm)
    {
    var websiteURL = "http://bit.ly/UqJOM"
    location = websiteURL
    }
}


function leaveFeedback(event)
{
var websiteURL = "mailto:stickieswebapp@gmail.com?SUBJECT=Feedback about Places"
location = websiteURL
}

onorientationchange=checkOrientation

function checkOrientation(){
	if(window.orientation == -90 || window.orientation == 90){
		
    }
    
    if(window.orientation == 0){
		//document.getElementById('header').style.width = "100px";
	}
hideLocationBar();
}