dirname = "";
selected = "";
function loadProfileContent(url,obj) {
	if(obj){
		jQuery(".selected").removeClass("selected");
		jQuery(obj).addClass("selected");
	}
	createCookie("opTab"+dirname,jQuery(obj).attr('title'));

	if(dirname && jQuery(obj).attr('title')) {
		createCookie("redirectCookieFbconnect",account_type+'/'+dirname+'/'+jQuery(obj).attr('title'));
	}
	jQuery('.content1').html('<center><img class="loadingimg" src="'+siteurl+'images/ajax-loader.gif" alt="News is loading.." /></center>');
	jQuery.get(url, function(data) {
		jQuery('.content1').html(data);
		jQuery(".autoUpdate > .updateControl").click(function(){
			updateId = jQuery(this).parent().attr("id").slice(10);
			if(confirm("Are you sure to remove the update?")){
				jQuery(this).html('<img height="16" width="16" class="smallIcon deleteAutoUpdateButton" id="loading" alt="Delete" src="'+siteurl+'images/upload_progress.gif"/>');
				clickbutton = jQuery(this);
				jQuery.get(url+"&update_id="+updateId, function(data) {
					 clickbutton.parents(".updateContent").fadeOut("slow");
				});
			}
			return false;
		});
	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");
		jQuery('.content1').html('');
	});
	if(selected == "shop"){
		return true;
	} else {
		return false;
	}
}

function postCommentMulti(photoID,userID,browser_userID,fbID,fbName,fbImage){
	// alert(browser_userID)

	if(jQuery('#comment_'+photoID).val() == ''){
		jQuery('#errorMessage_'+photoID).html("Please enter your comment.");
		return;
	}
	jQuery('#loadingcommnets_'+photoID).html('<img src="'+siteurl+'images/upload_progress.gif" alt="Posting comments.." />').show();
	var url = siteurl+'ajax/profile/photos.php?action=postcomment&browser_user_id='+browser_userID+'&user_id='+userID+'&photo_id='+photoID+'&fbuser_id='+fbID+'&comment='+jQuery('#comment_'+photoID).val();
	jQuery('#errorMessage_'+photoID).html('');
	jQuery.get(url, function(data) {
			jQuery('#loadingcommnets_'+photoID).html('').hide();
		if(data == 0) {
			jQuery('#errorMessage_'+photoID).html('Please login to post your comment.');
		} else {
			jQuery('.content1').html(data);
			s_update_sizes(); // update image widths

			var id = '#pc_'+photoID;
			// alert(id);
			tog(id);
			goToByScroll(id);
			console.log(data);
		}
	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");
	});

}
function postComment(){
	if(jQuery('#commenttext').val() == ''){
		jQuery('.errorMessage').html("Please enter your comment.");
		return;
	}
	jQuery('.loadingcommnets').html('<img src="'+siteurl+'images/upload_progress.gif" alt="Posting comments.." />').show();
	url = siteurl+'ajax/profile/photos.php?action=postcomment&user_id='+jQuery('#user_id').val()+'&photo_id='+jQuery('#photo_id').val()+
	'&fbuser_id='+jQuery('#fbuser_id').val()+'&comment='+jQuery('#commenttext').val();
	jQuery('.errorMessage').html('');
	jQuery.get(url, function(data) {
			jQuery('.loadingcommnets').html('').hide();
		if(data == 0) {
			jQuery('.errorMessage').html('Please login to post your comment.');
		} else {
			// jQuery('#comments-update').offset().top
			// jQuery('html,body').animate({scrollTop:
			// jQuery('#comments-update').offset().top}, 500);
			// jQuery('#commenttext').attr("value","");

			jQuery('.content1').html(data);
			console.log(data);
		}
	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");
	});

}

function postUserComment(){
	if(jQuery('#commenttext').val() == ''){
		jQuery('.errorMessage').html("Please enter your comment.");
		return;
	}
	jQuery('.loadingcommnets').html('<img src="'+siteurl+'images/upload_progress.gif" alt="Posting comments.." />').show();
	url = siteurl+'ajax/profile/comments.php?action=postcomment&comment_type='+jQuery('#comment_type').val()+
	'&postee_id='+jQuery('#postee_id').val()+'&comment='+jQuery('#commenttext').val();
	jQuery('.errorMessage').html('');
	jQuery.get(url, function(data) {
		jQuery('.loadingcommnets').html('').hide();
		if(data == 0) {
			jQuery('.errorMessage').html('Please login to post your comment.');
		} else {
			jQuery('#comments-update').offset().top
			jQuery('html,body').animate({scrollTop: jQuery('#comments-update').offset().top}, 1000);
			jQuery('#commenttext').attr("value","");
			jQuery('#comments-update').html(data);
		}
	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");
	});

}

function deleteComment(userid,commentid){
	if(confirm('Are you sure you wish to delete this? \nThis cannot be undone!!')){
		url = siteurl+'ajax/profile/comments.php?action=deletecomment&userid='+userid+'&commentid='+commentid;
		jQuery.get(url, function(data) {
			if(data == 0) {
				jQuery('.errorMessage').html('Please login to delete your comment.');
			} else {
				jQuery('#comments-update').html(data);
				// showSuccessMsg("Your comment has been deleted successfully");
			}
		});
		jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");
		});
	}
}

function leaveUpdateComment(update,userid){
	updateId = jQuery(update).parent().next('.updateId').val();
	url = siteurl+'ajax/profile/updates.php?action=comments&updateId='+updateId+'&userid='+userid;
	jQuery('.content1').html('<center><img class="loadingimg" src="'+siteurl+'images/ajax-loader.gif" alt="News is loading.." /></center>');
	jQuery.get(url, function(data) {
		jQuery('.content1').html(data);
		jQuery('html,body').animate({scrollTop: jQuery('.leavecomment_container').offset().top}, 1000);
	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");
		jQuery('.content1').html('');
	});
}

function postUpdatesComment(){
	if(jQuery('#commenttext').val() == ''){
		jQuery('.errorMessage').html("Please enter your comment.");
		return;
	}
	jQuery('.loadingcommnets').html('<img src="'+siteurl+'images/upload_progress.gif" alt="Posting comments.." />').show();
	url = siteurl+'ajax/profile/updates.php?action=postcomment&updateId='+
		jQuery('#update_id').val()+'&userid='+jQuery('#user_id').val()+'&comment='+jQuery('#commenttext').val();;
	jQuery('.errorMessage').html('');
	jQuery.get(url, function(data) {
		jQuery('.loadingcommnets').html('').hide();
		if(data == 0) {
			jQuery('.errorMessage').html('Please login to post your comment.');
		} else {
			jQuery('#comments-update').offset().top
			jQuery('html,body').animate({scrollTop: jQuery('#comments-update').offset().top}, 500);
			jQuery('#commenttext').attr("value","");
			jQuery('#comments-update').html(data);
		}
	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");
		jQuery('.loadingcommnets').html('');
	});

}

function viewUpdateCommentDirectAccess(updateId,userid){
	url = siteurl+'ajax/profile/updates.php?action=comments&updateId='+updateId+'&userid='+userid;
	jQuery('.content1').html('<center><img class="loadingimg" src="'+siteurl+'images/ajax-loader.gif" alt="News is loading.." /></center>');
	jQuery.get(url, function(data) {
		jQuery('.content1').html(data);
	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");
		jQuery('.content1').html('');
	});
}

function viewUpdateComment(update,userid){
	updateId = jQuery(update).parent().prev('.updateId').val();
	url = siteurl+'ajax/profile/updates.php?action=comments&updateId='+updateId+'&userid='+userid;
	jQuery('.content1').html('<center><img class="loadingimg" src="'+siteurl+'images/ajax-loader.gif" alt="News is loading.." /></center>');
	jQuery.get(url, function(data) {
		jQuery('.content1').html(data);
	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");
		jQuery('.content1').html('');
	});
}

function deleteUpdateComment(userid,commentid){
	if(confirm('Are you sure you wish to delete this? \nThis cannot be undone!!')){
		url = siteurl+'ajax/profile/updates.php?action=deletecomment&userid='+userid+'&commentid='+commentid+'&updateId='+jQuery('#update_id').val();
		jQuery.get(url, function(data) {
			if(data == 0) {
				jQuery('.errorMessage').html('Please login to delete your comment.');
			} else {
				jQuery('#comments-update').html(data);
				// showSuccessMsg("Your comment has been deleted successfully");
			}
		});
		jQuery('#notificationBar').ajaxError(function() {
			showNotification("Grrr! bompa is not available at the moment. Please try again later.");
		});
	}
}

function showLoadingInBlock(block){
	block.append('<img class="blockloading" src="../../images/tordateloader.gif" alt="loading.." />');
	block.css("opacity",'0.7');
}
function hideLoadingInBlock(block){
	block.find('.blockloading').hide();
	block.css("opacity",'1');
}

function requestASong(tourid,button){
	showDiv = jQuery(button).parents(".shows_container").next('.requested_songs');
	if(showDiv.is(':visible')){
		showDiv.slideUp();
		return;
	}
	bandid = jQuery("#bandId").val();
	url = siteurl+'ajax/profile/requestasong.php?tour_id='+tourid+'&band_id='+bandid;
	jQuery(".requested_songs:visible").slideUp('fast');
	jQuery.get(url, function(data) {
		jQuery('.rightbtns > .active').removeClass('active');
		jQuery(button).addClass('active');
		showDiv.html(data).slideDown();
	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");
	});
}

function submitSongs(button){
	var $fields = jQuery(button).parents(".requested_songs").find('input[type="checkbox"]:checked');
    if (!$fields.length && !jQuery(button).hasClass("update")) {
        showNotification('You must select at least one song!');
        return false;
	}
	showLoadingInBlock(jQuery(".requested_songs:visible"));
	url = siteurl+'ajax/profile/requestasong.php?action=requestasong';
	jQuery.post(url, jQuery("#songform").serialize(),function(data) {
		hideLoadingInBlock(jQuery(".requested_songs:visible"));
		if(data == 0) {
			showNotification('Please login to request songs.');
		} else {
			jQuery(button).parents(".requested_songs").html(data).slideDown();
		}
	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");

	});
}

function editRequestedSongs(button,tourid){
	showLoadingInBlock(jQuery(".requested_songs:visible"));
	url = siteurl+'ajax/profile/requestasong.php?action=editsong&tourdate_id='+tourid;
	jQuery.get(url,function(data) {
		hideLoadingInBlock(jQuery(".requested_songs:visible"));
		if(data == 0) {
			showNotification('Please login to request songs.');
		} else {
			jQuery(button).parents(".requested_songs").html(data).slideDown();
		}
	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");

	});
}
function goingToThisShow(tourid,button){
	jQuery.get(url,function(data) {
		if(data == 0) {
			showNotification('Please login to attend this show.');
		} else {
			jQuery(button).html("you are attending");
			jQuery(button).removeClass('active');
		}
	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");

	});
}
function toggleGoingShow(tourid,button){
	if(jQuery(button).hasClass("active")){
		url = siteurl+'ajax/profile/addattendingshow.php?action=remove&tourdate_id='+tourid;
	} else {
		url = siteurl+'ajax/profile/addattendingshow.php?tourdate_id='+tourid;
	}
	jQuery.get(url,function(data) {
		message = data.split("|");
		if(message[0]==0) {
			showNotification(message[1]);
		} else {
			if(jQuery(button).hasClass("active")){
				jQuery(button).html("going to this show?");
				jQuery(button).removeClass('active');
			} else {
				jQuery(button).html("attending (remove)");
				jQuery(button).addClass('active');
			}
		}
	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");

	});
}

function readAndReview(tourid,button){
	url = siteurl+'ajax/profile/readandreview.php?tour_id='+tourid;
	showDiv = jQuery(button).parents(".shows_container").next('.gray-container-wrap');
	if(showDiv.is(':visible')){
		showDiv.slideUp();
		return;
	}
	jQuery(".gray-container-wrap:visible").slideUp('fast');
	jQuery.get(url, function(data) {
		jQuery('.rightbtns > .active').removeClass('active');
		jQuery(button).addClass('active');
		showDiv.html(data).slideDown();

		if(document.getElementById("tourdate_id_direct").value != "") {
			document.getElementById("readreview_"+document.getElementById("tourdate_id_direct").value).focus();
			document.getElementById("tourdate_id_direct").value = '';
		}
	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");

	});
}

function postReview(tourid,botton){
	comment = jQuery(".gray-container-wrap:visible").find(".review-text").val();
	rating = jQuery(".gray-container-wrap:visible").find(".rating-value").val();
	if(comment == "" && !rating) {
		showNotification('Please add any review or rate this show');
		return false;
	}
	showLoadingInBlock(jQuery(".gray-container-wrap:visible"));
	url = siteurl+'ajax/profile/readandreview.php?action=postreview&tour_id='+tourid+'&review='+comment+'&rating='+rating;
	jQuery.get(url, function(data) {
		message = data.split("|");
		if(message[0]==0) {
			showNotification(message[1]);
			hideLoadingInBlock(jQuery(".gray-container-wrap:visible"));
			return;
		}
		jQuery(".gray-container-wrap:visible").html(data).slideDown();
		hideLoadingInBlock(jQuery(".gray-container-wrap:visible"));

		// showing confirmation popup for
		showConfirmAddreview(tourid, rating);
	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");
		hideLoadingInBlock(jQuery(".gray-container-wrap:visible"));
	});
}

function updateReview(button){
	jQuery(button).hide();
	jQuery(button).next().show();
	jQuery(button).next().next().hide();
	jQuery(".gray-container-wrap:visible").find(".noneditstar").hide();
	jQuery(".gray-container-wrap:visible").find(".editstar").show();
	jQuery(".gray-container-wrap:visible").find(".query-reviewed").hide();
	jQuery(".gray-container-wrap:visible").find(".editBox").show();
}

function postUpdateReview(tourid,reviewid,button){
	comment = jQuery(".gray-container-wrap:visible").find(".review-text").val();
	rating = jQuery(".gray-container-wrap:visible").find(".rating-value").val();
	if(comment == "" && !rating) {
		showNotification('Please add any review or rate this show');
		return false;
	}
	url = siteurl+'ajax/profile/readandreview.php?action=editreview&tour_id='+tourid+'&review='+comment+'&reviewid='+reviewid+'&rating='+rating;
	showLoadingInBlock(jQuery(".gray-container-wrap:visible"));
	jQuery.get(url, function(data) {
		message = data.split("|");
		if(message[0]==0) {
			showNotification(message[1]);
			hideLoadingInBlock(jQuery(".gray-container-wrap:visible"));
			return;
		}
		jQuery(".gray-container-wrap:visible").html(data).slideDown();
		hideLoadingInBlock(jQuery(".gray-container-wrap:visible"));

		// showing confirmation popup for
		showConfirmAddreview(tourid,rating);
	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");
		hideLoadingInBlock(jQuery(".gray-container-wrap:visible"));
	});
}

function deleteReview(tourid,reviewid,button){
	if(confirm("Are you sure to delete your review on this show ?")){
		showLoadingInBlock(jQuery(".gray-container-wrap:visible"));
		url = siteurl+'ajax/profile/readandreview.php?action=deletereview&tour_id='+tourid+'&reviewid='+reviewid;
		jQuery.get(url, function(data) {
			jQuery(".gray-container-wrap:visible").html(data).slideDown();
			hideLoadingInBlock(jQuery(".gray-container-wrap:visible"));
			jQuery('#pastshowbutton').trigger('click');
		});
		jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");
		hideLoadingInBlock(jQuery(".gray-container-wrap:visible"));
	});
	}
}

function rateThis(button) {
	rating=1;
	jQuery(button).parent().children("a").each(function(){
		if(parseInt(jQuery(button).attr("title")) >= rating){
			jQuery(this).removeClass("notrated").addClass("rated");
		} else {
			if(!jQuery(this).hasClass('cancelrating')){
				jQuery(this).removeClass("rated").addClass("notrated");
			}
		}
		jQuery(".gray-container-wrap:visible").find(".rating-value").val(jQuery(button).attr("title"));
		rating++;
	});
}
function cancelRating(button) {
	jQuery(button).parent().children("a").each(function(){
		if(!jQuery(this).hasClass('cancelrating')){
			jQuery(this).removeClass("rated").addClass("notrated");
		}
	});
}
function loadVenueContent(url) {
	jQuery('#showlist').html('<img class="loadingimg" src="'+siteurl+'images/ajax-loader.gif" alt="loading.." />');
	jQuery.get(url, function(data) {
		jQuery('#showlist').html(data);
		if(document.getElementById("tourdate_id_direct").value != "") {
			readAndReview(document.getElementById("tourdate_id_direct").value,document.getElementById("readreview_"+document.getElementById("tourdate_id_direct").value));
		}

	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");
		jQuery('#showlist').html('');
	});
}

function loadMap(address) {
	var map = new GMap2(document.getElementById("drawmap"));
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	if (geocoder) {
		geocoder.getLatLng( address,
			function(point) {
				if (!point) {
					showNotification(address + " not found");
				} else {
					map.clearOverlays()
					map.setCenter(point, 14);
					var marker = new GMarker(point, {draggable: true});
					map.addOverlay(marker);
					// alert(
					// point.lat().toFixed(5)+"--"+point.lng().toFixed(5));
				}
			}
		);
	}
}

function drawMap() {

	GUnload();
	// jQuery('.get-direction-btn').hide();
	// jQuery('.get-direction-cancel-btn').show();
	geocoder = new GClientGeocoder();
	geocoder.getLatLng( jQuery("#startAddress").val(),function(Point) {
		if (!Point) {
			showNotification("Starting point not found");
			return false;
		} else {
			starPoint = Point;
		}
	});
	geocoder = new GClientGeocoder();
	geocoder.getLatLng( jQuery("#destinationAdress").val(),function(Point) {
		if (!Point) {
			showNotification("Destination not found");
			return false;
		} else {
			endPoint = Point;
		}
	});
	// alert( endPoint.lat().toFixed(5)+"--"+endPoint.lng().toFixed(5));
    var lat1 = starPoint.lat(), lon1 =starPoint.lng();
    var lat2 = endPoint.lat(), lon2 = endPoint.lng();
    // var rhumb = getURLParams().rhumb=='y' ? true : false;

    var d = Math.acos(Math.sin(lat1.toRad())*Math.sin(lat2.toRad()) +
                      Math.cos(lat1.toRad())*Math.cos(lat2.toRad()) *
                      Math.cos(lon2.toRad()-lon1.toRad())) * 6371;

    // create the Google map
    var map = new GMap2(document.getElementById("drawmap"));
   	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());

    // validation...
    if (isNaN(lat1) || isNaN(lon1) || isNaN(lat2) || isNaN(lon2)) {  // invalid
																		// co-ordinates
      map.setCenter(new GLatLng(51.477,0.000), 15);
      jQuery('#coords').html('No co-ordinates given');
      return false;
    }

    // start and end points
    var pt1 = new GLatLng(lat1, lon1);
    var pt2 = new GLatLng(lat2, lon2);

    // route between them (great circle path)
    var route = new GPolyline([pt1, pt2], '#ff0000', 4, 0.5, {geodesic:true});

    // bounds & centre of map
    var bounds = route.getBounds();
    map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds), G_HYBRID_MAP);

    // display of start and end points
    var lbl1 = lat1.toFixed(4) + '�,' + lon1.toFixed(4) + '�';
    var lbl2 = lat2.toFixed(4) + '�,' + lon2.toFixed(4) + '�';

    // add route & start/end markers
    map.addOverlay(route);

    var mk1 = new GMarker(pt1, {title:lbl1});
    GEvent.addListener(mk1, 'click', function() { mk1.openInfoWindowHtml('P1: '+lbl1); });
    map.addOverlay(mk1);
    var mk2 = new GMarker(pt2, {title:lbl2});
    GEvent.addListener(mk2, 'click', function() { mk2.openInfoWindowHtml('P2: '+lbl2); });
    map.addOverlay(mk2);


  }


    var map;
    var gdir;
    var geocoder = null;
    var addressMarker;

    function initializeGdirections() {

			fromAddress = jQuery("#startAddress").val();
			toAddress 	= jQuery("#destinationAdress").val();
			locale 		= 'en_US';


		 if (GBrowserIsCompatible()) {
			map = new GMap2(document.getElementById("drawmap"));
			gdir = new GDirections(map, document.getElementById("directions"));
			GEvent.addListener(gdir, "load", onGDirectionsLoad);
			GEvent.addListener(gdir, "error", handleErrors);

			map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl());
			if (geocoder) {
				geocoder.getLatLng( toAddress,
					function(point) {
						if (!point) {
							showNotification(address+" not found");
						} else {
							map.clearOverlays();
							map.setCenter(point, 14);
							var marker = new GMarker(point, {draggable: true});
							map.addOverlay(marker);
							// alert(
							// point.lat().toFixed(5)+"--"+point.lng().toFixed(5));
						}
					}
				);
			}

			// setDirections(fromAddress, toAddress, "en_US");
		  }

    }
	function onGDirectionsLoad(){
			jQuery("#directions").slideDown('slow');
			jQuery("#hide_directions").show();
	}
	function handleErrors(){
		if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS) {
		 	// alert("No corresponding geographic location could be found for
			// one of the specified addresses. This may be due to the fact that
			// the address is relatively new, or it may be incorrect.\nError
			// code: " + gdir.getStatus().code);
			showNotification("Directions are not available");
		 }
		else if (gdir.getStatus().code == G_GEO_SERVER_ERROR) {
		 	// alert("A geocoding or directions request could not be
			// successfully processed, yet the exact reason for the failure is
			// not known.\n Error code: " + gdir.getStatus().code);
			showNotification("Directions are not available");
		 }

		else if (gdir.getStatus().code == G_GEO_MISSING_QUERY) {
		 	// alert("The HTTP q parameter was either missing or had no value.
			// For geocoder requests, this means that an empty address was
			// specified as input. For directions requests, this means that no
			// query was specified in the input.\n Error code: " +
			// gdir.getStatus().code);

		showNotification("Directions are not available");
		}
		else if (gdir.getStatus().code == G_GEO_BAD_KEY) {
		 	// alert("The given key is either invalid or does not match the
			// domain for which it was given. \n Error code: " +
			// gdir.getStatus().code);
			showNotification("Directions are not available");
		}
		else if (gdir.getStatus().code == G_GEO_BAD_REQUEST) {
		 	// alert("A directions request could not be successfully parsed.\n
			// Error code: " + gdir.getStatus().code);
			showNotification("Directions are not available");
		}
		else if (gdir.getStatus().code == 604) {
		 	// alert("No corresponding geographic location could be found for
			// one of the specified addresses. This may be due to the fact that
			// the address is relatively new, or it may be incorrect.\nError
			// code: " + gdir.getStatus().code);
			showNotification("Directions are not available");
		 }
		else {
		   // alert("An unknown error occurred.");
		   showNotification("An unknown error occurred.");
		}
		hide_directions();
		document.getElementById("drawmap").innerHTML = '';
		loadMap(jQuery("#destinationAdress").val());
		initializeGdirections();


	}


  function drawMapDirection() {
	fromAddress = jQuery("#startAddress").val();
	toAddress 	= jQuery("#destinationAdress").val();
	locale 		= 'en_US';

	geocoder = new GClientGeocoder();
	geocoder.getLatLng( jQuery("#startAddress").val(),function(Point) {
		if (!Point) {
			showNotification("Starting point not found");
			return false;
		} else {
			starPoint = Point;

		}
	});
	geocoder = new GClientGeocoder();
	geocoder.getLatLng( jQuery("#destinationAdress").val(),function(Point) {
		if (!Point) {
			showNotification("Destination not found");
			return false;
		} else {
			endPoint = Point;
		}
	});

	  gdir.load("from: " + fromAddress + " to: " + toAddress,
                { "locale": locale });
  }

  function hide_directions() {
	jQuery("#directions").slideUp('slow');
	jQuery("#hide_directions").hide();
  }

Number.prototype.toRad = function() { return this * Math.PI / 180; }  // convert
																		// degrees
																		// to
																		// radians
Number.prototype.toDeg = function() { return this * 180 / Math.PI; }  // convert
																		// radians
																		// to
																		// degrees
																		// (signed)

function becomeAFanBand(bandId){
	url = siteurl+'ajax/profile/becomeafan.php?band_id='+bandId;
	jQuery.get(url, function(data) {
		message = data.split("|");
		if(message[0]==0) {
			// alert(message[1]);
			showNotification(message[1]);
			return false;
		} else {
			$("#fan_btn").hide();
			$("#fan_msg").html(message[1]);

		}
	});
}

function becomeAFanCloth(clothId){
	url = siteurl+'ajax/profile/becomeafanClothing.php?cloth_id='+clothId;
	jQuery.get(url, function(data) {
			message = data.split("|");
			if(message[0]==0) {
				showNotification(message[1]);
				return;
			} else {
				// $(".becomefan-btn").css({background:
				// 'url('+siteurl+'images/btn_ur-a-fan.png) left bottom',
				// width:'129px'});
				// $(".becomefan-btn").removeAttr("onclick");
				$("#fan_btn").hide();
				$("#fan_msg").html(message[1]);
				// showSuccessMsg(message[1]);
			}

	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");

	});
}

function becomeFanfromLandingPage(bandId){
	url = siteurl+'ajax/profile/becomeafan.php?band_id='+bandId;
	jQuery.get(url, function(data) {
		message = data.split("|");
		if(message[0]==0) {
			showNotification(message[1]);
			return;
		} else {
			showSuccessMsg(message[1]);
		}
	});
	jQuery('#notificationBar').ajaxError(function() {
		showNotification("Grrr! bompa is not available at the moment. Please try again later.");

	});
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function open_attendee_list(tourid) {
	document.getElementById('whoisattending'+tourid).style.display = 'block';
}
function close_attendee_list(tourid) {
	document.getElementById('whoisattending'+tourid).style.display = 'none';
}

function sendReport(obj,comment_type, profile_user_id, id,photo_comment_id) {
		var url='';
		if(comment_type == 'photo_comment') {
			url = siteurl+'ajax/sendReport.php?comment_type='+comment_type+'&profile_user_id='+profile_user_id+'&photo_id='+id+'&photo_comment_id='+photo_comment_id;
		} else if(comment_type == 'quick_update_comment') {
			url = siteurl+'ajax/sendReport.php?comment_type='+comment_type+'&profile_user_id='+profile_user_id+'&quick_update_id='+id;
		}
		jQuery.get(url, function(data) {
			obj.style.display = 'none';
		});
		jQuery('#notificationBar').ajaxError(function() {
			showNotification("Grrr! bompa is not available at the moment. Please try again later.");
		});
}


function twitterShareVenue(tourid,desc,title) {

 var url = jQuery("#venue_link_hid").val()+tourid;
 window.open('http://twitter.com/home?status='+title+' review at: '+url,'','width=800,height=600,scrollbars=1');
}

function myspaceShareVenue(tourid,desc,title) {
 var url = jQuery("#venue_link_hid").val()+tourid;

 window.open('http://www.myspace.com/Modules/PostTo/Pages/?t='+title+'&u='+url+'&c=review at: '+url,'','width=800,height=600,scrollbars=1');
}

function facebookShareVenue(tourid,desc,title) {
 var url = jQuery("#venue_link_hid").val()+tourid;
 window.open('http://www.facebook.com/sharer.php?t='+title+'&u='+url,'','width=800,height=600,scrollbars=1');
}

function addShareImageCode(photo_id) {
	photo_id = photo_id * 99;
	photo_id = photo_id.toString(16).toUpperCase() ;
	jQuery("#commentForm").show();
	jQuery('#shareImageCode').val('<div id="mySharedPhoto"><scrip'+'t type="text/javascript" ' +
		'src="'+siteurl+'include/js/shareImage.js"></scrip'+'t><scrip'+'t type="text/javascript" >'+
		'width = 300; height = 300;  getMysharedImage("'+photo_id+'",width,height); </scrip'+'t></div>');
}
function selectCode(replaceTextArea) {
	replaceTextArea.select();
}


function postAddFanStream() {
	closeConfirmPostFanDiv();
	showSuccessMsg('posted the activity on your favorite sites.');

	var profile_name = jQuery("#post-stream-profile-name").val();
	var profile_type = jQuery("#post-stream-profile-type").val();
	var profile_userid = jQuery("#post-stream-profile-id").val();

	url = siteurl+'ajax/profile/postAddFanStream.php?profile_name='+profile_name+'&profile_type='+profile_type+'&profile_userid='+profile_userid;
	jQuery.get(url, function(data) {
	});
	jQuery('#notificationBar').ajaxError(function() {
	});
}

function closeConfirmPostFanDiv() {
		jQuery("#confirm-postfan-div").hide();
}


function closepostReview() {
	jQuery("#confirm-addreview-div").hide();
}


function showConfirmAddreview(tourid,rating) {

	if(rating > 0) {
		jQuery("#rated_value").val(rating);
	} else {
		jQuery("#rated_value").val(0);
	}

	jQuery("#post-review-tourdateid").val(tourid);
	var twitter_left = jQuery('#twitter'+tourid).offset().left;
	var twitter_top = jQuery('#twitter'+tourid).offset().top;
	jQuery("#confirm-addreview-div").css({left:parseInt(twitter_left-50)+"px", top:parseInt(twitter_top-100)+"px"});
	jQuery("#confirm-addreview-div").show();

}

function postVenueReview() {

	closepostReview();
	showSuccessMsg('posted the activity on your favorite sites.');
	var options = {
		dataType:  'json',
		success:	function(data) {  } ,
		failure: function() {  }
	};
	jQuery('#form-post-review-networks').ajaxSubmit(options);

	if(jQuery("#rated_value").val() > 0){jQuery('#pastshowbutton').trigger('click'); }
}

function print_directions() {
	window.open(siteurl+'map_directions.php?address='+jQuery("#destinationAdress").val()+'&startAddress='+jQuery("#startAddress").val(),"","width=740,scrollbars=yes");
}

function checkUrlForAnchor(url){
	var myFile = url;
	if (myFile.match('#')) { // the URL contains an anchor tag
	  var myAnchor = '' + myFile.split('#')[1];
	  if(isUrl(myAnchor)){
		  return myAnchor;
	  }
	}
}

function loadContent(url){
	console.log(url);
	// jQuery('#content_main').html('<center><img class="loadingimg"
	// src="'+siteurl+'images/ajax-loader.gif" alt="News is loading.."
	// /></center>');
	jQuery.ajax({
		url: url,
		dataType : 'json',
		success: function(data){
			if(data.html){
				jQuery('#content_main').html(data.html);
			}
		}
	});
}
function show_more_photos(offset,limit,profile_id){
	$('#load_more').show('slow');
	$('#show_more_photos_'+offset).hide();
	$.ajax({
		  type: "POST",
		  url: siteurl+'ajax/LoadPhotos.php',
		  data: "offset="+offset+"&limit="+limit+"&profile_id="+profile_id,
		  success: function(data) {
		    $('.content1').append(data);
		    s_update_sizes();
			$('#load_more').hide('slow');
		  },
		  complete: function(){
			  s_update_sizes();
		  }
	});
}

function launch_iframe(url, size){

	if(!size){
		size = 620;
	}
	 var if_height,
	    src = url + '#' + encodeURIComponent( document.location.href ),
	    iframe = $( '<iframe " src="' + src + '" width="' + size + '" height="1000" scrolling="no" frameborder="0"><\/iframe>' )
	      .appendTo( '#iframe' );

	 jQuery.receiveMessage(function(e){
		 if(e.data.indexOf('reset_scroll') >= 0){
			 window.scrollTo(0, 0);
			 //window.scroll(0,0);
			 //console.log('scrollTo');
		    }
		    var h = Number( e.data.replace( /.*if_height=(\d+)(?:&|$)/, '$1' ) ) + 550;
		    if(typeof h == 'number'){
		    	if ( !isNaN( h ) && h > 0 && h !== if_height ) {
		    		iframe.height( if_height = h );
		    	}
		    }

		  });


}

function scroll2topWindow()
{
window.scrollTo(0,0);
}

