//These functions are necessary for Proper Google Map operation
var map;
var gdir;
var sierra='5400 Date Ave, Sacramento, CA';
var allloaded=false;
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GMapTypeControl());
map.enableDoubleClickZoom();
gdir = new GDirections(map, document.getElementById("directions"));
GEvent.addListener(gdir, "error", notifyError);

showMeTheWay(document.getElementById('fromAddress').value);
}
loadUstream();
}
function showMeTheWay(fromAddress) {
gdir.load("from: " + fromAddress + " to: " + sierra,
{ "locale": "en_US" });
allloaded++;


}

function notifyError(){
if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
alert("Error:"+gdir.getStatus().code+"\n\nThis location is unknown to GoogleMaps. Please be more specific, or try a location that is more well-known.\n\nThanks,\n\nSierra Crew");
else alert("Error:"+gdir.getStatus().code+"\n\nAn error occured while processing your location request. Please make sure the input box is not empty, or try again.\n\nThanks,\n\nSierra Crew");
}
function directionPopup(fromLoc) {
divireplace("getDirection","<img src=\"/assets/images/uploaded/ajax-loader-google.gif\" />");

window.open( "pages/popwindow.asp?popLocation="+fromLoc, "myWindow",
"status = 1, height = 400, width = 305, resizable = 0, scrollbars=1, menubar=1" )
showMeTheWay(document.getElementById('fromAddress').value);
divireplace("getDirection","<input type=\"submit\" value=\"Show me the way!\" name=\"submitbutton\" />");
}
//This function produces virtual tour with no boxes
function virtualtour(){
document.write('<object width="300" height="300" align="middle" data="/pages/sierra_tour.swf" wmode="transparent" allownetworking="internal" allowscriptaccess="never" type="application/x-shockwave-flash">');
document.write('<param value="never" name="allowScriptAccess"/>');
document.write('<param value="internal" name="allowNetworking"/>');
document.write('<param value="wmode" name="tansparent" />');
document.write('<param value="pages/sierra_tour.swf" name="movie"/>');
document.write('<param value="high" name="quality"/>');
document.write('</object>');
allloaded++;

}
//This function produces the videohowto with no boxes
function howtovids(){
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="670" height="125" id="HowToVideos" align="middle">');
document.write('<param name="allowScriptAccess" value="sameDomain" />');
document.write('<param name="movie" value="/pages/assist_vids.swf" />');
document.write('<param value="wmode" name="tansparent" />');
document.write('<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />');
document.write('<embed src="/pages/assist_vids.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="670" height="125" name="HowToVideos" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write('</object>');
}

//This function produces the Ustream flash without boxes
function ustreamvid(){

document.write('<div class="inner-left"><div align="center"><embed pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"\n type="application/x-shockwave-flash" wmode="transparent" quality="high" src="http://ustream.tv/.VHCx3SEPxKHv8GqI,uzkw.usc"\n height="300" width="380"></embed></div></div>');
}
//This function shows the how-to videos
function howtoPopup(video,title){
window.open( "pages/pophowto.asp?videoid="+video+"&title="+title, "myWindow",
"status = 1, height = 470, width = 430, resizable = 0, scrollbars=1, menubar=0" );

}
//Controls UPS Tracker
function popMapper(number){
divireplace("trackload","<br /><img src='/assets/images/uploaded/ajax-loader-ups.gif' /><br /><br />");
popuptracker=window.open( 'http://track.packagemapping.com?access_key=cy006mjpwnxs8k1v82j5bjspkt3x524x&logos=none&radios=none&shipper=ups&action=track&tracknum='+number, "myWindow",
"status = 1, height = 800, width = 500, resizable = 1, scrollbars=1, menubar=1" )
divireplace("trackload","<div style=\"text-align: center; margin-bottom: 10px; margin-top: 10px;\"><a class=\"upsbutton\" href=\"#\" onClick=\"popMapper(document.getElementById('number').value);return false;\">Track My Order</a></div>");
}



//taken from main site so accessible on extras
function divireplace(id,d) {
el = document.getElementById(id);
el.innerHTML = d;
}

//handles embeding Youtube Videos

function writevideo(vidid){
document.write('<object width="400" height="350">');
document.write('<param name="movie" value="http://www.youtube.com/v/'+vidid+'=1"></param>');
document.write('<param name="wmode" value="transparent"></param>');
document.write('<param value="true" name="play"/>');
document.write('<embed src="http://www.youtube.com/v/'+vidid+'&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" width="400" height="350"></embed>');
document.write('</object>');;
}

function loadUstream(){
divireplace("uvideo","<div class='inner-left'><div align='center'><embed pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' wmode='transparent' quality='high' src='http://ustream.tv/.VHCx3SEPxKHv8GqI,uzkw.usc' height='300' width='380'></embed></div></div>");
}

//http://www.youtube.com/jp.swf?video_id=hamN7CMZw9w&eurl=&iurl=http%3A//img.youtube.com/vi/hamN7CMZw9w/default.jpg&t=OEgsToPDskLdNpRtQRSAFC6VdeB8tWAe
/*
document.write('<object width="400" height="350">');
document.write('<param name="movie" value="http://www.youtube.com/v/'+vidid+'=1"></param>');
document.write('<param name="wmode" value="transparent"></param>');
document.write('<param value="true" name="play"/>');
document.write('<embed src="http://www.youtube.com/v/'+vidid+'&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" width="400" height="350"></embed>');
document.write('</object>');
*/

function confirmSelection(user,id,action){
	answer=confirm("Are you sure?")
	if(answer){
		if(action=="moveGear"){
			ajaxLoader('functions/ajax-deleteGear.asp?user='+user+'&id='+id+'&action='+action,'wantit','GET','');
			ajaxLoader('functions/ajax-deleteGear.asp?user='+user+'&id='+id+'&action=reload','haveit','GET','');
		}else if(action=="addFriend"){
			ajaxLoader('functions/ajax-addFriend.asp?PF='+user+'&id='+id+'','noreturn','Get','');
		}else if(action=="deleteLink"){
			ajaxLoader('functions/ajax-deleteLink.asp?PF='+id+'&id='+user+'','sitelist','Get','');
		}else{
			ajaxLoader('functions/ajax-deleteGear.asp?user='+user+'&id='+id+'&action='+action,action,'GET','');
		}
	}
}

function fetchProfile(url,memberid,mailTo){
	if (memberid==2){
		Lightview.show({
		  href: '/includes/top-login.asp?nox=true',
		  rel: 'ajax',
		  options: {
			  topclose: true,
			width: 300,
			height: 170
		  }
		});
	} else {
		if (url!=""){
			url=url+"?PF="+memberid+"&sendTo="+mailTo
			document.location=url;
		}
	}
}