// JavaScript Document
var map = null;
var icon = null;
google.load("maps", "2");// load maps api

function createMap(lat,long,pt){
	icon = new GIcon();
	icon.image = "http://www.thisplaceiknow.com/images/mapicons/tack.png";
	icon.iconSize = new GSize(35, 35);
	icon.iconAnchor = new GPoint(17, 35);
	icon.infoWindowAnchor = new GPoint(5, 1);
	
	smallIcon = new GIcon(icon);
	smallIcon.image = "http://www.thisplaceiknow.com/images/mapicons/tack_green.png";
	smallIcon.infoWindowAnchor = new GPoint(5, 1);
	smallIcon.iconSize = new GSize(20, 20);
	smallIcon.shadowSize = new GSize(32, 20);
	smallIcon.iconAnchor = new GPoint(10, 20);

	map = new GMap2(document.getElementById("map"));

	if (lat==0){
		map.setCenter(new google.maps.LatLng(lat,long), 1);
	} else {
		map.setCenter(new google.maps.LatLng(lat,long), 10);		
	}
	map.addControl(new GSmallMapControl());
	if (pt){//if there is a marker 
		mainPoint();
	}
	
	//otherPoints();
}


function updateVidPics(type,size,id,page){
	pars = "p="+page+"&placeID="+id+"&size="+size+"&type="+type;
	url = "/places/showVidPics.cfm";
	xhr = new Ajax.Updater('vidPic',url,{method:'get', parameters:pars, evalScripts:true});
}

function createMarker(point, title, id, mark, pic) {

	var html = "<div style=\"width:200;\" align=\"center\">" + title + "<br><img src = '"+pic+"' height='100'></div>";
	marker[mark] = new PdMarker(point, smallIcon);
	marker[mark].setTooltip(html);
	marker[mark].setOpacity(100);
	
	// Show this marker's index in the info window when it is clicked.
	GEvent.addListener(marker[mark], 'mouseover', function() {
		//marker[mark].openInfoWindowHtml(html, 200);
	});  
	GEvent.addListener(marker[mark], 'mouseout', function() {
		//map.closeInfoWindow()
	});  
	GEvent.addListener(marker[mark], 'click', function() {
		location.href = "http://www.thisplaceiknow.com/place_view.cfm?placeID=" + id;
	}); 

	return marker[mark];
}

function addComment(){
	url = '/ajax/placeView_refreshComments.cfm';
	pars = 'placeID=' + $('placeID').value + "&userID=" + $('userID').value + "&comment=" + $('comment').value;
	new Ajax.Updater('comments',url,{method:'post',postBody:pars});
	hidePopupForm();
}
function refreshBeenThere(placeID){
	url = '/ajax/placeView_beenThereRefresh.cfm';
	pars = "placeID="+placeID;
	new Ajax.Updater('beenThere',url,{method:'get',parameters:pars});
	hidePopupForm();
}
var rankTimeout;
function rankHover(rank,canRate){
	clearTimeout(rankTimeout);
	for (i=1;i<=rank;i++){
		//alert($('rank_'+i));
		$('rank_'+i).src = "/images/compass_rank_over.gif";
	}
	for (i=rank+1;i<=5;i++){
		$('rank_'+i).src = "/images/compass_rank.gif";
	}
	if(canRate){
		$('numOfRatings').innerHTML = "Click to rate!";
	}
}

function rankOut(currentRank){
	if(currentRank == 0){
		currentRank = 1;
	}
	rankTimeout = setTimeout(function(){
																				for (i=1;i<=5;i++){
																					$('rank_'+i).src = "/images/compass_rank_over.gif";
																				}
																				for (i=currentRank+1;i<=5;i++){
																					$('rank_'+i).src = "/images/compass_rank.gif";
																				}
																				$('numOfRatings').innerHTML = tempRatingText;
																		},100)
}
function rankPlace(placeID,rank,userID){
	url = '/ajax/placeView_updateRank.cfm';
	pars = 'rank='+rank+'&placeID='+placeID;
	new Ajax.Updater('rating',url,{postBody:pars,method:'post'});
	//alert(rank);
}
/*
function showTip(type,id,e){
	//mousePos = getMouseXY();
	var IE = document.all?true:false

	// If NS -- that is, !IE -- then set up for mouse capture
	if (!IE) document.captureEvents(Event.MOUSEMOVE)
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  

	$('toolTip').innerHTML = '';

	url = "ajax/placeView_userToolTip.cfm";
	pars = "userID=" + id;
	new Ajax.Updater('toolTip',url,{parameters:pars,method:'get'});

	//alert(tempX);
	$('toolTip').style.display = 'block';
	$('toolTip').style.left = (tempX+30) + 'px';
	$('toolTip').style.top = (tempY-50) + 'px';
	
}
function hideTip(){
	$('toolTip').style.display = 'none';
}
*/
