// JavaScript Document

/////////// START WINDOW ADD EVENT
window.addEvent('domready', function() {

/////////////////////////////////////////////////////////////////////////////////////////////////// PRELOAD IMAGES
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
MM_preloadImages('images/bkgnd_logo_anime.gif');
MM_preloadImages('images/bkgnd_mastheadTag_anime.gif');
MM_preloadImages('images/bkgnd_masthead_animeOver.gif');
MM_preloadImages('twitter/twitter_closed_ov.png');



/////////////////////////////////////////////////////////////////////////////////////////////////// FADE APPEAR EFFECT
function dogAppear(dataA, dataB){
var myFx = new Fx.Style(dataA, 'opacity').start(0,1);
var myFx = new Fx.Style(dataB, 'opacity').start(0,1);
}

function dogFade(dataA, dataB){
var myFx = new Fx.Style(dataA, 'opacity').start(1,0);
var myFx = new Fx.Style(dataB, 'opacity').start(1,0);
}
							
/////////////////////////////////////////////////////////////////////////////////////////////////// FORMS

hidediv('streetLoginError');
$('streetLogin').addEvent('submit', function(e) {
	    new Event(e).stop();
		showdiv('streetLoginError');
		var log = $('streetLoginError').empty().addClass('ajax-loading');
			this.send({
					  update: log,
					  onComplete: function() {
						  log.removeClass('ajax-loading');
						  $('streetLogin').reset();
	                  }
	        });
});


/////////////////////////////////////////////////////////////////////////////////////////////////// FLASH INSERT FUNCTIONS
function insertFlashFeaturedAudio(receiveAudioDataUrl, receiveAudioDataArtist, receiveAudioDataTrack){
var so = new SWFObject("flash/featuredArtist_audio.swf", "featuredArtist_audio", "273", "44", "8");
   			so.addParam("allowScriptAccess", "sameDomain");
   			so.addParam("menu", "false");
   			so.addParam("wmode", "transparent");
   			so.addParam("quality", "high");
				so.addVariable("audioINITurl", receiveAudioDataUrl);
				so.addVariable("audioINITartist", receiveAudioDataArtist);
				so.addVariable("audioINITtrack", receiveAudioDataTrack);
   			so.write("boxMedia");
}

//////////////////////////////////////// DATA
function triggerData(){
var receiveAudioDataUrl = document.getElementById('DATAContainer').getAttribute('audioDATAurl');
var receiveAudioDataArtist = document.getElementById('DATAContainer').getAttribute('audioDATAartist');
var receiveAudioDataTrack = document.getElementById('DATAContainer').getAttribute('audioDATAtrack');

////// AUTO START MUSIC STATUS:ON
//showdiv('boxFeaturedArtistAudioList');
var newTimer = insertFlashFeaturedAudio(receiveAudioDataUrl, receiveAudioDataArtist, receiveAudioDataTrack).delay(2000);
}


//////////////////////////////////////// TRIGGERS
var newTimer = triggerData().delay(1000);


/////////////////////////////////////////////////////////////////////////////////////////////////// TOOL TIPS

var toolTips = new Tips($$('.Tips'), {
	initialize:function(){
		this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 200, wait: false}).set(0);
	},
	onShow: function(toolTip) {
		this.fx.start(1);
	},
	onHide: function(toolTip) {
		this.fx.start(0);
	}

});

/* FORM TIPS */
var formTips = new Tips($$('.formTips'), {
	className: 'custom',
	fixed: true,
	initialize:function(){
		this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 300, wait: false}).set(0);
	},
	onShow: function(toolTip) {
		this.fx.start(1);
	},
	onHide: function(toolTip) {
		this.fx.start(0);
	}
});
/* LOGIN TIPS */
var formTips = new Tips($$('.loginTips'), {
	className: 'login',
	fixed: true,
	initialize:function(){
		this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 300, wait: false}).set(0);
	},
	onShow: function(toolTip) {
		this.fx.start(1);
	},
	onHide: function(toolTip) {
		this.fx.start(0);
	}
});

/* FORM TIPS ALT */
var altTips = new Tips($$('.altTips'), {
	className: 'alt',
	initialize:function(){
		this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 0, wait: false}).set(0);
	},
	onShow: function(toolTip) {
		this.fx.set(1);
	},
	onHide: function(toolTip) {
		this.fx.set(0);
	}
});

/* EXTRA LINKS TIPS */
var extraTips = new Tips($$('.extraTips'), {
	className: 'extra',
	initialize:function(){
		this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 300, wait: false}).set(0);
	},
	onShow: function(toolTip) {
		this.fx.start(1);
	},
	onHide: function(toolTip) {
		this.fx.start(0);
	}
});



/////////// END WINDOW ADD EVENT
});

/////////////////////////////////////////////////////////////////////////////////////////////////// GOOGLE MAPS

var map = null;
var geocoder = null;

    function initialize() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(40.753692,-73.992576), 13);
		map.setMapType(G_SATELLITE_MAP);
		
		map.addControl(new GSmallZoomControl());
		//map.addControl(new GMapTypeControl());
		
        geocoder = new GClientGeocoder();
      }
    }
		
		
    function plotEventToMap(dogAddress, dogInfo, dogIconID, dogShadowID, dwnSwitch, dwnTitle, dwnFile) {
      if (geocoder) {
        geocoder.getLatLng(
          dogAddress,
          function(point) {
            if (!point) {
              map.setCenter(new GLatLng(40.753692,-73.992576), 13);
            } else {
              map.setCenter(point, 13);
			  
	var baseIcon = new GIcon();
	baseIcon.shadow = "googleMaps/googleMapsMarkerShadow.png";
	baseIcon.iconSize = new GSize(99, 65);
	baseIcon.shadowSize = new GSize(99, 65);
	baseIcon.iconAnchor = new GPoint(9, 65);
	baseIcon.infoWindowAnchor = new GPoint(9, 2);
	baseIcon.infoShadowAnchor = new GPoint(18, 25);
		
	
	function createMarker(point, index) {
		
  		var dogIcon = new GIcon(baseIcon);
  		dogIcon.image = "googleMaps/"+dogIconID+".png";
		dogIcon.shadow = "googleMaps/"+dogShadowID+".png";

  		// Set up our GMarkerOptions object
  		markerOptions = { icon:dogIcon };
  		var marker = new GMarker(point, markerOptions);
		
		if (dwnSwitch == "no"){
		var infoBoxOptions = {
        "content": dogInfo,
        "offsetHorizontal": 19,
        "offsetVertical": -157,
        "height": 93,
        "width": 180,
        "className": "infoBox"
      	};
		}
		if (dwnSwitch == "yes"){
		var infoBoxOptions = {
        "content": dogInfo +'<br/>'+'Downloads: <a href="downloads/'+dwnFile+'">'+dwnTitle+'</a>',
        "offsetHorizontal": 19,
        "offsetVertical": -157,
        "height": 93,
        "width": 180,
        "className": "infoBox"
      	};
		}
		if (dwnSwitch == "email"){
		var infoBoxOptions = {
        "content": dogInfo +'<br/>'+'<a href="mailto:'+dwnFile+'">'+dwnTitle+'</a>',
        "offsetHorizontal": 19,
        "offsetVertical": -157,
        "height": 93,
        "width": 180,
        "className": "infoBox"
      	};
		}
		
	
		var infoBox = new InfoBox(point, infoBoxOptions);
      	marker.infoBox = infoBox;
		
		if (map.infoBox) {
          map.removeOverlay(map.infoBox);
        }
        map.infoBox = marker.infoBox;
        map.addOverlay(map.infoBox);
		
		
		GEvent.addListener(marker, "click", function() {
   
		if (map.infoBox) {
          map.removeOverlay(map.infoBox);
        }
        map.infoBox = marker.infoBox;
        map.addOverlay(map.infoBox);
		
  		});
	
  		return marker;
		
	}
		  
	map.addOverlay(createMarker(point, 13));
	
            }
          }
    );
		
		
      }
    }

setTimeout(function(){initialize();}, 300);
setTimeout(function(){
plotEventToMap('649 8th Avenue, New York, NY', 'Doghouse Records, Located in NYC', 'googleMapsMarker','googleMapsMarkerShadow', 'no');
}, 1300);