/**
* @author Bumblebee
*/
var idx_img = 0;
var tmman = null;
var BmapPointsAll = [];
var g_type = '';
if (typeof(console) == 'undefined')
{
console = function(){
this.log = function(asd)
{
};
};
}
// getPageScroll() by quirksmode.com
function getPageScroll() {
var xScroll, yScroll;
if (self.pageYOffset) {
yScroll = self.pageYOffset;
xScroll = self.pageXOffset;
} else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
yScroll = document.documentElement.scrollTop;
xScroll = document.documentElement.scrollLeft;
} else if (document.body) {// all other Explorers
yScroll = document.body.scrollTop;
xScroll = document.body.scrollLeft;
}
return new Array(xScroll,yScroll)
}
// Adapted from getPageSize() by quirksmode.com
function getPageHeight() {
var windowHeight;
if (self.innerHeight) { // all except Explorer
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowHeight = document.body.clientHeight;
}
return windowHeight;
}
$(document).ready
(
function()
{
// if we in lost password page
if ($('#lost_password').length != 0)
{
var loader = jQuery('
')
.css({position: "relative", top: ($('#email_restore').height()/2 - 10) + "px", left: ($('#email_restore').width()/2 - 30) + "px", 'z-index':"300"})
.hide()
.appendTo("#email_restore");
$.validator.setDefaults({
submitHandler:
function ()
{
loader.show();
$.ajax({
type:"POST",
url:"lostpass.php",
data:'email=' + $('#email_restore').val(),
success: function(data)
{
loader.hide();
$('#lost_password').html('You will recieeve password soon');
}
});
return false;
}
});
$("#lost_password").validate({
rules: {
email_restore: {
required: true,
email: true
}
},
messages: {
email_restore: "Please enter a valid email address"
}
});
}
// if we have login menu
if ($("#loginscreen").length != 0)
{
$("#loginscreen > div > input").title();
$("#loginscreen > button.login").livequery('click',
function ()
{
if ($(this).prev().find("input[name=password]").val() != "password"
&& $(this).prev().find("input[name=password]").val() != ""
&& $(this).prev().find("input[name=email]").valid_email())
{
$(this).css('background', 'url(images/ajax_loader_login.gif) center center no-repeat');
obj = $(this);
$.ajax({
type:"POST",
url:"login.php",
data:'email=' + $(this).prev().find("input[name=email]").val() + '&password=' + $(this).prev().find("input[name=password]").val(),
success: function(data)
{
data = jQuery.trim(data);
if (data != "100")
{
obj.prev().find("input[name=password]").hide();
obj.prev().find("input[name=email]").hide();
obj.prev().find("input[name=password]").after('Edit your locationsProfile');
//obj.prev().find("input[name=password]").after('Profile & locationsLogout');
obj.removeClass('login');
obj.addClass('logged');
obj.attr('style','');
obj.attr('title', 'logout');
if ($("#markItUp").length != 0)
{
$("#submit_comment").removeAttr('disabled');
$("#submit_comment").parent().next().remove();
}
}
else
{
alert ("Please enter valid email and/or pasword.\nYou can get a new password from the link at the bottom of the page");
obj.attr('style','');
}
}
});
}
else
{
alert("Please enter valid email and/or pasword.\nYou can get a new password from the link at the bottom of the page");
}
}
);
$("#loginscreen > button.logged").livequery('click',
function ()
{
$(this).css('background', 'url(images/ajax_loader_login.gif) center center no-repeat');
obj = $(this);
$.ajax({
type:"POST",
url:"login.php",
data:'logout=true',
success: function(data)
{
data = jQuery.trim(data);
obj.prev().find("input[name=password]").show();
obj.prev().find("input[name=email]").show();
//obj.prev().find("input[name=password]").after('Edit your locationsProfile');
obj.prev().find("a").hide();
obj.removeClass('logged');
obj.addClass('login');
obj.attr('title', '');
if ($("#markItUp").length != 0)
{
$("#submit_comment").attr('disabled', 'disabled');
$("#submit_comment").parent().after('');
}
obj.attr('style','');
},
error: function(data)
{
obj.attr('style','');
}
});
}
);
$("#loginscreen a[rel='logout']").livequery('click',
function ()
{
$(this).css('background', 'url(images/ajax_loader_login.gif) center center no-repeat');
obj = $("#loginscreen > button");
$.ajax({
type:"POST",
url:"login.php",
data:'logout=true',
success: function(data)
{
data = jQuery.trim(data);
obj.prev().find("input[name=password]").show();
obj.prev().find("input[name=email]").show();
//obj.prev().find("input[name=password]").after('Edit your locationsProfile');
obj.prev().find("a").remove();
obj.removeClass('logged');
obj.addClass('login');
obj.attr('title', '');
if ($("#markItUp").length != 0)
{
$("#submit_comment").attr('disabled', 'disabled');
$("#submit_comment").parent().after('');
}
obj.attr('style','');
},
error: function(data)
{
obj.attr('style','');
}
});
return false;
}
);
}
// if we have instructions options
if ($("#instructions").length != 0 || $("#tips").length != 0)
{
$("#control-container > div.icon > a").facebox();
$("#control-container > div.icon > a[href*=instructions]").click();
}
// if we have lostpassword facebox
if ($("#lostpass").length != 0)
{
$("a[rel=facebox]").facebox();
$("#email a[rel=facebox]").click(
function()
{
var loader = $('#facebox #lostpass > div.loader');
$('#facebox form.lost_password .sbtn').click(
function (){
$('#facebox form.lost_password').submit();
return false;
}
);
$.validator.setDefaults({
submitHandler:
function ()
{
loader.show();
$.ajax({
type:"POST",
url:"lostpass.php",
data:'email=' + $('#facebox form.lost_password input[name=email_restore]').val(),
success: function(data)
{
loader.hide();
$('#facebox form.lost_password').html('You will recieeve password soon');
}
});
return false;
}
});
$("#facebox form.lost_password").validate({
rules: {
email_restore: {
required: true,
email: true
}
},
messages: {
email_restore: "Please enter a valid email address"
}
});
}
);
}
$('#key_long > .key-cell > .g_graffiti').click(
function()
{
changeTypeMarkers('graffiti');
}
);
$('#key_long > .key-cell > .g_gallery').click(
function()
{
changeTypeMarkers('gallery');
}
);
$('#key_long > .key-cell > .g_painting').click(
function()
{
changeTypeMarkers('painting');
}
);
$('#key_long > .key-cell > .g_stickers').click(
function()
{
changeTypeMarkers('stickers');
}
);
$('#key_long > .key-cell > .g_stencil').click(
function()
{
changeTypeMarkers('stencil');
}
);
$('#key_long > .key-cell > .g_sculpture').click(
function()
{
changeTypeMarkers('sculpture');
}
);
$('#key_long > .key-cell > .g_installation').click(
function()
{
changeTypeMarkers('installation');
}
);
$('#key_long > .key-cell > span:hidden').click(
function()
{
BmapPoints = [];
BmapPoints = BmapPoints.concat(BmapPointsAll);
mgr.clearMarkers();
mgr.addMarkers(getStreetArtMarkers(1), 1);
mgr.addMarkers(getStreetArtMarkers(2), 2);
mgr.addMarkers(getStreetArtMarkers(3), 3);
mgr.addMarkers(getStreetArtMarkers(4), 4);
mgr.refresh();
$(this).hide();
$(this).prev().show();
$(this).prev().prev().show();
}
);
$('#key_long > .key-cell > span').hover(
function()
{
$(this).css('text-decoration', 'underline');
},
function()
{
$(this).css('text-decoration', 'none');
}
);
if ( $('#key_long > .key-cell').length != 0 )
{
BmapPointsAll = [];
BmapPointsAll = BmapPointsAll.concat(BmapPoints);
}
if ($("#imagecarousel").length != 0)
{
$("#imagecarousel > ul").html('');
jQuery('#imagecarousel').jcarousel({
// Uncomment the following option if you want items
// which are outside the visible range to be removed
// from the DOM.
// Useful for carousels with MANY items.
// itemVisibleOutCallback: {onAfterAnimation: function(carousel, item, i, state, evt) { carousel.remove(i); }},
itemLoadCallback: mycarousel_itemLoadCallback,
scroll: 9,
visible: 9
});
}
if ($("#markItUp").length != 0)
{
// Add markItUp! to your textarea in one line
$('#markItUp').markItUp(mySettings);
// You can add content from anywhere in your page
$('.quote > .add').click(function() {
obj = $(this);
text = '[quote="' + comments[$(this).attr('href').replace("#_","")].text +'"]';
text+= $(this).next().html();
text+= '[\/quote]';
$.markItUp( { openWith:'[quote="' + comments[$(this).attr('href').replace("#_","")].name +'"]',
closeWith:'[\/quote]',
placeHolder: comments[$(this).attr('href').replace("#_","")].text
}
);
return false;
});
// And you can add/remove markItUp! whenever you want
$('.toggle').click(function() {
if ($("#markItUp.markItUpEditor").length === 1) {
$("#markItUp").markItUpRemove();
$("span", this).text("get markItUp! back");
} else {
$('#markItUp').markItUp(mySettings);
$("span", this).text("remove markItUp!");
}
return false;
});
}
if ($('#comment-section').length != 0)
{
setTimeout(changeImage , 6000);
}
if ($("#submit_comment").length != 0)
{
$("#submit_comment").click(
function ()
{
var button = $(this);
button.css('background', 'url(images/ajax_loader_login.gif) center center no-repeat');
button.attr('disabled', 'disabled');
var url='data=';
if ($("#markItUp").length != 0)
{
//var dd = new Object();
//dd.data = $("#markItUp").val();
//dd.data = escape(dd.data);
//dd.data = $.toJSON(dd.data);
//dd.location_id = $("#loc_id").val();
url += escape($("#markItUp").val());
url += '&location_id=' + $("#loc_id").val();
}else
if ($("body > .postbody").length != 0)
{
window.top.window.document.getElementById('submit_comment').click();
return false;
}
$.ajax({
type:"POST",
url:"comment.php",
data: url,
success: function(data)
{
data = jQuery.trim(data);
$(".markItUpPreviewFrame").remove();
$("#markItUp").val("");
if ($('#comment-section > div.comment:last').length != 0)
{
$('#comment-section > div.comment:last').after(data);
}
else
{
$('#comment-section > div.section_title').after(data);
}
button.css('background', '');
button.removeAttr('disabled');
}
});
}
);
}
if ($("#profile").length != 0 || $('#edit_location').length != 0)
{
if (user_editable)
{
$("#image-info > div.user_name").editable("update_user.php", {
indicator : "",
tooltip : "Click to edit...",
event : "mouseover",
style : "inherit",
//id : 'user_name',
name : 'user_name'
});
$("#image-info > div.user_location").editable("update_user.php", {
indicator : "",
tooltip : "Click to edit...",
event : "mouseover",
style : "inherit",
//id : 'user_location',
name : 'user_location'
});
$('.add_location').click(
function()
{
document.location.href = 'add_location.php';
}
);
$('.add_location_btn').click(
function()
{
document.location.href = 'add_location.php';
}
);
$('.my_profile_btn').click(
function()
{
document.location.href = 'profile.php';
}
);
//$('a.show_add_location').click(
// function()
if ($('.add_unmapped_location').length != 0)
{
/*if ($('body > .add_unmapped_location').length == 0)
{
var obbj = $('.add_unmapped_location');
$('.add_unmapped_location').clone(true).appendTo('body');
obbj.remove();
}
$('.add_unmapped_location').css({
top: getPageScroll()[1] + (getPageHeight() / 10),
left: 385.5,
'text-align': 'left'
}).show().css('left', $(window).width() / 2 - ($('.add_unmapped_location').width() / 2));
if ($('facebox_overlay').length == 0)
$("body").append('')
$('#facebox_overlay').hide().addClass("facebox_overlayBG")
.css('opacity', $.facebox.settings.opacity)
.click(function() { $(document).trigger('close.facebox') })
.fadeIn(200);
*/
$('#uploadForm').ajaxForm({
beforeSubmit: function(a,f,o) {
if ($('#type').val() != '' && $('#title').val() != '' && $('#description').val() != '')
{
o.dataType = 'json';
$('#f1_upload_process').show();
$('#uploadForm').hide();
}
else
{
alert('Please fill all fields!');
return false;
}
},
success: function(data) {
var photos = [];
for (var y=0; y < data.length; y++)
{
if (data[y].result == 1)
{
photos.push(data[y].new_name);
}
else
{
if (typeof(data[y].error) != 'undefined' )
{
if (data[y].error != '')
{
alert(data[y].error)
$('#f1_upload_process').hide();
return false;
}
}
}
}
$('#uploadForm').hide();
$('#uploadForm').after('Files uploaded successfully');
var video = '';
var name = escape(document.getElementById("name").value);
var email = escape(document.getElementById("your_email").value);
var type = document.getElementById("type").value;
var title = escape(document.getElementById("title").value);
var description = escape(document.getElementById("description").value);
var myfile = objToString(photos);
var lat = 0;
var lng = 0;
var url = "name=" + name + "&email=" + email + "&type=" + type + "&title=" + title + "&description=" + description + "&lat=" + lat + "&lng=" + lng + "&myfile=" + myfile + '&video=' + video; // photo;
//console.log(url);
$.ajax({
type:"POST",
url:"http://www.streetartlocator.com/putsql.php",
data:url,
dataType: 'json',
success: function(data_resp)
{
$('#f1_upload_process').hide();
$('#uploadForm').show();
$('#uploadForm').html('');
$('#type').val('');
$('#title').val('');
$('#description').val('');
$('.multi').MultiFile({
accept:'gif|jpg|jpeg', STRING: {
remove:'Remove',
selected:'Selected: $file',
denied:'Please select $ext!',
duplicate:'You have selected duplicate:\n$file!'
}
});
/*var loc_html = '\
';*/
if ($("#profile").length != 0)
{
var point = new Object();
point.description = unescape(description);
point.embed = "";
point.id = data_resp.location_id;
point.lat = 0.0;
point.lng = 0.0;
point.on_wall = 1;
var ph = new Object();
ph.photo = basepath + 'thumb/r' + photos.pop();
point.photos = [ph];
point.published = 1;
point.title = unescape(title);
point.type = type;
BmapPoints.push(point);
changePageMyLocations(currentPage);
}
//$('.tagged_photos').before(loc_html);
//$('.unmapped_photos').show();
//console.log(data_resp);
//marker.closeInfoWindow();
//$('.add_unmapped_location').hide();
$('#uploadForm').next('span').remove();
jQuery.facebox('Your location was added');
}
});
}
});
$('.multi').MultiFile({
accept:'gif|jpg|jpeg', STRING: {
remove:'Remove',
selected:'Selected: $file',
denied:'Please select $ext!',
duplicate:'You have selected duplicate:\n$file!'
}
});
//return false;
}
//);
//$("a[rel=facebox]").facebox();
}
}
if ($('#edit_location').length != 0)
$('#edit_location .location_info > .form_line > button.sbtn').click(
function()
{
var type = $('#type_loc').val();
var title = $('#title_loc').val();
var description = $('#description_loc').val();
var published = 1;
if ($('#published_loc').attr('checked'))
{
published = 1;
}
else
{
published = 0;
}
if (type == '')
{
jQuery.facebox('Please select type of location');
}
if (title == '')
{
jQuery.facebox('Please enter title of location');
}
title = escape(title);
description = escape(description);
var url = 'type=' + type + '&title=' + title + '&description=' + description + '&id=' + BmapPoints[0].id + '&published=' + published;
$.ajax({
type:"POST",
url:"update_sql.php",
data:url,
success: function(data)
{
data = jQuery.trim(data);
if (data != "100")
{
jQuery.facebox('Changes saved');
BmapPoints[0].type = $('#type_loc').val();
BmapPoints[0].title = unescape(title);
BmapPoints[0].description = unescape(description);
map.clearOverlays();
createMarker(new GLatLng(BmapPoints[0].lat, BmapPoints[0].lng), BmapPoints[0], 0);
}
else
{
jQuery.facebox('Changes NOT saved');
$('#type_loc').val(BmapPoints[0].type);
$('#title_loc').val(BmapPoints[0].title);
$('#description_loc').val(BmapPoints[0].description);
}
},
error: function()
{
jQuery.facebox('Changes NOT saved');
$('#type_loc').val(BmapPoints[0].type);
$('#title_loc').val(BmapPoints[0].title);
$('#description_loc').val(BmapPoints[0].description);
}
});
}
);
if ($('#edit_location').length != 0)
$('#edit_location .my_locations > .image_container > .loc_options > .item > .img_opts_delete').livequery('click', function(){
if (confirm('You are about to delete image!')) {
var block = $(this).parent().parent().parent();
var img_id = block.find('img').attr('id');
img_id = img_id.replace('img-', '');
var img_src = block.find('img').attr('src');
var del = [];
del.push(parseInt(img_id));
var url = 'id=asd987987asd9879asdfsdakjf&op=delete_files&delete_files=' + jQuery.toJSON(del);
$.ajax({
type: "POST",
url: "update_sql.php",
data: url,
success: function(data)
{
data = jQuery.trim(data);
if (data != "100")
{
for (var i = 0; i < BmapPoints[0].photos.length; i++)
{
if (BmapPoints[0].photos[i].photo == img_src)
{
BmapPoints[0].photos.splice(i, 1);
break;
}
}
block.toggle("slide",
{
direction: "down"
}, 2000,
function(){
block.remove();
}
);
}
else
{
jQuery.facebox('Changes NOT saved');
}
},
error: function(){
jQuery.facebox('Changes NOT saved');
}
});
}
});
if ($('#edit_location').length != 0)
$('#edit_location .add_location_image > .form_line > #uploadForm').ajaxForm({
beforeSubmit: function(a,f,o) {
o.dataType = 'json';
$('#f1_upload_process').show();
$('#uploadForm').hide();
},
success: function(data) {
var photos = [];
for (var y=0; y < data.length; y++)
{
if (data[y].result == 1)
{
photos.push(data[y].new_name);
}
else
{
if (typeof(data[y].error) != 'undefined' )
{
if (data[y].error != '')
{
alert(data[y].error)
$('#f1_upload_process').hide();
return false;
}
}
}
}
$('#uploadForm').hide();
$('#uploadForm').after('Files uploaded successfully');
var myfile = objToString(photos);
var url = "embed=&new_files=" + myfile + '&id=' + BmapPoints[0].id;
$.ajax({
type:"POST",
url:"http://www.streetartlocator.com/update_sql.php",
data:url,
dataType: 'json',
success: function(data_resp)
{
$('#f1_upload_process').hide();
$('#uploadForm').show();
$('#uploadForm').html('');
$('.multi').MultiFile({
accept:'gif|jpg|jpeg', STRING: {
remove:'Remove',
selected:'Selected: $file',
denied:'Please select $ext!',
duplicate:'You have selected duplicate:\n$file!'
}
});
BmapPoints[0].photos = BmapPoints[0].photos.concat(data_resp);
for (var i=0; i< data_resp.length; i++)
{
var loc_html = '\
\
\
\
\
\
';
$('#edit_location .my_locations > .image_container:last').after(loc_html);
}
$('#edit_location .my_locations > .image_container:hidden').toggle("slide",
{
direction: "up"
}, 2000
);
jQuery.facebox('Your photo(s) was added
Note, that images may not appear while you don\'t reload page.');
$('#uploadForm').next('span').remove();
}
});
}
});
$('#edit_location .sym_tab_photos').click(
function(){
$('#edit_location .add_location_image > .form_line').hide();
$('#edit_location .add_location_image > .sym_tab_photos').show();
$('#edit_location .sym_tabs > .sym_tab').removeClass('sym_tab_active');
$('#edit_location .sym_tabs > .sym_tab_photos').addClass('sym_tab_active');
}
);
$('#edit_location .sym_tab_youtube').click(
function(){
$('#edit_location .add_location_image > .form_line').hide();
$('#edit_location .add_location_image > .sym_tab_youtube').show();
$('#edit_location .sym_tabs > .sym_tab').removeClass('sym_tab_active');
$('#edit_location .sym_tabs > .sym_tab_youtube').addClass('sym_tab_active');
}
);
$('#edit_location .sym_tab_flickr').click(
function(){
$('#edit_location .add_location_image > .form_line').hide();
$('#edit_location .add_location_image > .sym_tab_flickr').show();
$('#edit_location .sym_tabs > .sym_tab').removeClass('sym_tab_active');
$('#edit_location .sym_tabs > .sym_tab_flickr').addClass('sym_tab_active');
}
);
if ($('#edit_location').length != 0)
$('#edit_location .add_location_image > .form_line > #uploadYouTube').ajaxForm({
beforeSubmit: function(a,f,o) {
o.dataType = 'json';
$('#f1_yt_upload_process').show();
$('#uploadYouTube').hide();
},
success: function(data) {
var photos = [];
for (var y=0; y < data.length; y++)
{
if (data[y].result == 1)
{
photos.push(data[y].new_name);
}
else
{
if (typeof(data[y].error) != 'undefined' )
{
if (data[y].error != '')
{
alert(data[y].error)
$('#f1_upload_process').hide();
return false;
}
}
}
}
$('#uploadYouTube').hide();
$('#uploadYouTube').after('Files uploaded successfully');
var myfile = objToString(photos);
var embed = escape($('#uploadYouTube > input[name="video"]').val());
var del_ph = [];
for (var j=0; j');
BmapPoints[0].photos = BmapPoints[0].photos.concat(data_resp);
$('#edit_location .my_locations > .image_container').remove();
var loc_html = '\
\
\
\
\
\
';
$('#edit_location .my_locations').prepend(loc_html);
$('#uploadYouTube > input[name="video"]').val('');
jQuery.facebox('Your photo(s) was added
Note, that images may not appear while you don\'t reload page.');
$('#uploadYouTube').next('span').remove();
}
});
}
});
if ($('#edit_location .add_location_image > .form_line > #uploadForm').length != 0)
{
$('.multi').MultiFile({
accept:'gif|jpg|jpeg', STRING: {
remove:'Remove',
selected:'Selected: $file',
denied:'Please select $ext!',
duplicate:'You have selected duplicate:\n$file!'
}
});
}
if ($(".vertical_return_home").length != 0)
{
//ie hack
html = "" + $(".vertical_return_home").html() + "
";
obj = $(".vertical_return_home");
obj.before(html);
obj.remove();
$(".vertical_return_home").css('left', '-40px');
if ($('#edit_location').length != 0)
$(".vertical_return_home").css('top', '90px');
$(".vertical_return_home").click(
function ()
{
document.location.href = 'index.php';
}
);
}
if ($("#profile > .profile_locations > div > .locations_container > a > .location_options > .item > span").length != 0)
$('#profile > .profile_locations > div > .locations_container > a > .location_options > .item > span').livequery('click',
function (e)
{
var obj = $(this);
var img = obj.parent().parent().parent().find('img');
var img_id = img.attr('id');
img_id = img_id.replace('img-','');
if ($(this).html() == 'Unpublish')
{
//console.log("published=0&id="+img_id);
$.ajax({
type:"POST",
url:"update_sql.php",
data: "published=0&id="+img_id,
success: function(data)
{
img.toggleClass('unpublished');
obj.html('Publish');
//console.log(data);
}
});
}
if ($(this).html() == 'Publish')
{
//console.log("published=1&id="+img_id);
$.ajax({
type:"POST",
url:"update_sql.php",
data: "published=1&id="+img_id,
success: function(data)
{
img.toggleClass('unpublished');
obj.html('Unpublish');
//console.log(data);
return false;
}
});
}
if ($(this).html() == 'Untag It')
{
if (confirm('You are about to delete tag of location'))
{
$.ajax({
type: "POST",
url: "tag_photo.php",
data: 'delete=true&location_id=' + img_id,
success: function(data){
data = jQuery.trim(data);
if (data != "") {
jQuery.facebox(data);
$('#img-' + img_id).parent().parent().remove();
}
return false;
}
});
}
}
return false;
}
);
if ($(".location_container > .loc_options > .item > span").length != 0)
$('.location_container > .loc_options > .item > span.publish_opts').livequery('click',
function(e){
var obj = $(this);
var img = obj.parent().parent().parent().find('img');
var img_id = img.attr('id');
img_id = img_id.replace('img-', '');
if ($(this).html() == 'Hide') {
$.ajax({
type: "POST",
url: "update_sql.php",
data: "published=0&id=" + img_id,
success: function(data){
img.toggleClass('unpublished');
obj.html('Show');
obj.removeClass('show');
obj.removeClass('hide');
obj.addClass('show');
img_id = parseInt(img_id);
for (var i = 0; i< BmapPoints.length; i++)
{
if (BmapPoints[i].id == img_id)
{
BmapPoints[i].published = 0;
break;
}
}
}
});
}
if ($(this).html() == 'Show') {
$.ajax({
type: "POST",
url: "update_sql.php",
data: "published=1&id=" + img_id,
success: function(data){
img.toggleClass('unpublished');
obj.html('Hide');
obj.removeClass('show');
obj.removeClass('hide');
obj.addClass('hide');
for (var i = 0; i< BmapPoints.length; i++)
{
if (BmapPoints[i].id == img_id)
{
BmapPoints[i].published = 1;
break;
}
}
return false;
}
});
}
return false;
}
);
if ($(".location_container > .loc_options > .item > span.untag").length != 0)
$('.location_container > .loc_options > .item > span.untag').livequery('click',
function(e){
var obj = $(this);
var img = obj.parent().parent().parent().find('img');
var img_id = img.attr('id');
img_id = img_id.replace('img-', '');
if ($(this).html() == 'Remove')
{
if (confirm('You are about to delete tag of location'))
{
$.ajax({
type: "POST",
url: "tag_photo.php",
data: 'delete=true&location_id=' + img_id,
success: function(data){
data = jQuery.trim(data);
if (data != "") {
jQuery.facebox(data);
$('#img-' + img_id).parent().parent().remove();
}
return false;
}
});
}
}
return false;
}
);
if ($(".location_container > .loc_options > .item > span.map_it").length != 0)
$('.location_container > .loc_options > .item > span.map_it').livequery('click',
function(e){
var obj = $(this);
var img = obj.parent().parent().parent().find('img');
var img_id = img.attr('id');
img_id = parseInt(img_id.replace('img-', ''));
for (var i = 0; i < BmapPoints.length; i++) {
if (BmapPoints[i].id == img_id) {
createMarker(map.getCenter(), BmapPoints[i], i);
currentIndex = i;
savePosInDB(new GMarker(map.getCenter()), BmapPoints[i].id + '_-1');
obj.parent().remove();
break;
}
}
return false;
}
);
$('a[rel="tag_it"]').click(
function()
{
addTag($('#loc_id').val());
return false;
}
);
$('a[rel="on_wall"]').click(
function()
{
var loc = $('#loc_id').val();
var on_wall = $(this).attr('href');
on_wall = on_wall.replace('#', '');
var obj = $(this);
$.ajax({
type:"POST",
url:"on_the_wall.php",
data:'location_id=' + loc + '&on_wall=' + on_wall,
success: function(data)
{
if (data != "")
{
//console.log(data);
}else{
if (parseInt(on_wall) == 1)
{
$('.location_street_status > img').attr('src', 'images/icon_still_on_street.png');
}else{
$('.location_street_status > img').attr('src', 'images/icon_no_longer_street.png');
}
}
}
});
return false;
}
);
$(document).pngFix();
$("a[rel=popup]").click(
function()
{
var uri = $(this).attr('href');
window.open(uri, 'StreetArtLocator V2', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=800');
return false;
}
);
jQuery.each(jQuery.browser, function(i, val) {
if(i=="msie" && val && jQuery.browser.version.substr(0,1)=="6")
{
$('#add_our > ul').css('margin-left', '25px');
$('#add_our > ul > li').css('list-style-position', 'outside');
alert("To get the best out of our site we recommend you upgrade your browser");
}
});
}
);
changeTypeMarkers = function(type)
{
if (g_type != '')
{
$('span.g_' + g_type).prev().show();
$('span.g_' + g_type).show();
$('span.g_' + g_type).next().hide();
}
g_type = type;
$.ajax({
type:"POST",
url:"scripts/get_type_markers.php",
data:'type=' + type,
dataType: 'json',
success: function(data)
{
if (data.length > 0)
{
BmapPoints = [];
BmapPoints = BmapPoints.concat(data);
mgr.clearMarkers();
mgr.addMarkers(getStreetArtMarkers(1), 1);
mgr.addMarkers(getStreetArtMarkers(2), 2);
mgr.addMarkers(getStreetArtMarkers(3), 3);
mgr.addMarkers(getStreetArtMarkers(4), 4);
mgr.refresh();
$('span.g_' + type).prev().hide();
$('span.g_' + type).hide();
$('span.g_' + type).next().show();
}
}
});
}
addTag = function(loc)
{
$.ajax({
type:"POST",
url:"tag_photo.php",
data:'location_id=' + loc,
success: function(data)
{
data = jQuery.trim(data);
if (data != "")
{
jQuery.facebox(data);
}
}
});
}
removeTag = function(loc)
{
$.ajax({
type:"POST",
url:"tag_photo.php",
data:'delete=true&location_id=' + loc,
success: function(data)
{
data = jQuery.trim(data);
if (data != "")
{
jQuery.facebox(data);
}
}
});
}
chimage = function (id)
{
/*$("#img_" + id).parent().parent().find('div:gt(0)').toggle("slide",
{
direction: "right"
}, 2000);*/
$("#img_" + id).parent().parent().siblings().fadeOut('slow', function(){$("#img_" + id).parent().parent().css('width', '100%');});
//$("#img_" + id).parent().css('width', '100%');
$("#img_"+id).hide();
$('.location_options').css('display', 'none');
$("#img_"+id).parent().next().find("#f1_upload_form_"+id).show();
}
saveimage = function (id, image_id)
{
if ($("#title_"+image_id).val() == "")
{
alert("Please enter the title ");
return false;
}
$("#f1_upload_form_"+id).hide();
$("#f1_upload_process_"+id).show();
$("form[name=aForm" + id + "]").submit();
return true;
}
savedata = function (id, index)
{
var type = $("#type_"+id).val();
var title = escape($("#title_"+id).val());
var description = escape($("#description_"+id).val());
var url = "type=" + type + "&title=" + title + "&description=" + description + "&id=" + id; // photo;
$.ajax({
type:"POST",
url:"update_sql.php",
data:url,
success: function(data)
{
data = jQuery.trim(data);
if (data != "100")
{
BmapPoints[index].type = $("#type_"+id).val();
BmapPoints[index].title = $("#title_"+id).val();
BmapPoints[index].description = $("#description_"+id).val();
currentMarker.closeInfoWindow();
map.removeOverlay(currentMarker);
createMarker(new GLatLng(BmapPoints[index].lat, BmapPoints[index].lng), BmapPoints[index], index);
jQuery.facebox('Changes saved');
}
else
{
jQuery.facebox('Please log in to change location');
}
}
});
};
cancel_change_image = function(idz)
{
$("#img_" + idz).parent().parent().css('width', '');
//$("#img_" + idz).parent().parent().find('div:gt(0)').fadeIn('slow');
$("#img_" + idz).parent().parent().siblings().fadeIn('slow');
$('.location_options').css('display', '');
/*toggle("slide",
{
direction: "right"
}, 2000);*/
$("#f1_upload_form_"+idz).hide();
$("#img_"+idz).show();
return false;
};
function mycarousel_itemLoadCallback(carousel, state)
{
// Check if the requested items already exist
if (carousel.has(carousel.first, carousel.last)) {
return;
}
jQuery.get(
'dynamic_image.php',
{
first: carousel.first,
last: carousel.last
},
function(xml) {
mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, xml);
},
'xml'
);
};
function mycarousel_itemAddCallback(carousel, first, last, xml)
{
// Set the size of the carousel
carousel.size(parseInt(jQuery('total', xml).text()));
jQuery('image', xml).each(function(i) {
carousel.add(first + i, mycarousel_getItemHTML(jQuery(this).text()));
});
};
/**
* Item html creation helper.
*/
function mycarousel_getItemHTML(url)
{
var array;
array = url.split(';;;');
return '';
}
saveavatar = function ()
{
$("#upload_form").hide();
$("#upload_process").show();
$("form[name=aForm]").submit();
return true;
};
savepassword = function ()
{
$("#facebox #change_password_box").css('position' , 'relative');
var loader = jQuery('')
.css({position: "absolute", top: ($('#change_password_box').height()/2 - 10) + "px", left: ($('#change_password_box').width()/2 - 30) + "px", 'z-index':"300"})
.hide()
.appendTo("#facebox #change_password_box");
newpass = $("#facebox #change_password_box > div > input[name=new_password]").val();
if (newpass != $("#facebox #change_password_box > div > input[name=compare_password]").val())
{
alert ("Please enter same passwords");
return false;
}
loader.show();
$.ajax({
type:"POST",
url:"update_user.php",
data:"user_password=" + escape(newpass) + "&oldpass=" + escape($("#facebox #change_password_box > div > input[name=password]").val()),
success: function(data)
{
data = jQuery.trim(data);
if (data != "100")
{
//$("#facebox a.close").click();
jQuery.facebox('Password saved');
}
else
{
//$("#facebox a.close").click();
jQuery.facebox('Please log in to change password');
}
loader.remove();
}
});
return true;
};
send_to_friend = function ()
{
$("#facebox .send_box .response").html('');
if ($("#facebox .send_box input[name='emails']").val() == '' ||
$("#facebox .send_box input[name='emails']").val() == 'enter email or emails separated by comma')
{
$("#facebox .send_box .response").html('Please enter at least one email');
return false;
}
var width = $("#facebox .send_box form").width();
var height = $("#facebox .send_box form").height();
$("#facebox .send_box form").hide();
$("#facebox .send_box").css({'background': 'url(images/loader.gif) no-repeat center center', 'width': width + 'px', 'height': height + 'px'});
var url = 'emails=' + escape($("#facebox .send_box input[name='emails']").val());
url += '&message=' + escape($("#facebox .send_box textarea[name='text']").val());
if ($("#facebox .send_box input[name='location_id']").length != 0)
{
url += '&loc_id=' + escape($("#facebox .send_box input[name='location_id']").val());
}
$.ajax({
type:"POST",
url:"send_to_friend.php",
data:url,
success: function(data)
{
data = jQuery.trim(data);
if (data != "100")
{
//$("#facebox a.close").click();
jQuery.facebox('Your email was sent');
}
$("#facebox .send_box").css({'background': ''});
}
});
return false;
};
changeImage = function() {
if (point_photos && point_photos.length > 1)
{
idx_img++;
if (idx_img >= point_photos.length)
{
idx_img = 0;
}
$('#image-container > a > .comment-image').animate( { opacity: "0.4" }, { queue:false, duration:2000 } )
.animate( { width: point_photos[idx_img].width + "px", height: point_photos[idx_img].height + "px" }, { queue:false, duration:1500 } )
.parent().animate( { width: point_photos[idx_img].width + "px", height: point_photos[idx_img].height + "px" }, { duration:1500 } )
.find('img').attr('src', point_photos[idx_img].photo)
.animate( { opacity: "1" }, { duration:2000 } );
//$('#image-container > .comment-image').attr('src', point_photos[idx_img].photo);
setTimeout(changeImage, 6000);
}else{
if ($('#image-container > object').length != 0)
{
$('#image-container > object').width($('#image-container').width() + 'px');
$('#image-container > object').height($('#image-container').height() + 'px');
$('#image-container > object > embed').width($('#image-container').width() + 'px');
$('#image-container > object > embed').height($('#image-container').height() + 'px');
}
$('#image-container > a > .comment-image').attr('src', point_photos[0].photo);
}
var offset = 0;
offset += parseInt($('#image-info').height());
offset += parseInt($('#map-container').height());
offset += parseInt($('#map-container').css('margin-top'));
offset += parseInt($('#map-container').next().height());
offset += parseInt($('#map-container').next().css('margin-top'));
offset += parseInt($('#map-container').next().next().height());
offset += parseInt($('#map-container').next().next().css('margin-top'));
offset += parseInt($('#map-container').next().next().next().height());
offset += parseInt($('#map-container').next().next().next().css('margin-top'));
var img_height = parseInt($('#image-container').height());
$('#image-container').css('margin-bottom', '0px');
if (img_height < offset)
{
$('#image-container').css('margin-bottom', (offset - img_height) + 'px');
}
$('#image-container').css('background', '');
};
changeImageGMap = function() {
if (tmman)
{
clearTimeout(tmman);
}
if ($('.map_bubble > .img_section > a').length > 1)
{
idx_img++;
if (idx_img >= $('.map_bubble > .img_section > a').length)
{
idx_img = 0;
}
$('.map_bubble > .img_section > a').each(
function()
{
$(this).hide();
}
);
$('.map_bubble > .img_section > a:eq(' + idx_img + ')').show();
tmman = setTimeout(changeImageGMap, 6000);
}
};
regFaceboxProc = function()
{
$("#facebox .err_ms").remove();
if ($("#facebox #reg_email").valid_email())
{
var button_text = $("#facebox .button > button").text();
$("#facebox .button > button").html('');
$("#facebox .button > button").css('background', '#000 url(images/ajax_loader_login.gif) center center no-repeat');
$("#facebox .button > button").attr('disabled', 'disabled');
var url = 'email=' + escape($("#facebox .reg_inline > .input_line > input[name='reg_email']").val());
url += '&name=' + escape($("#facebox .reg_inline > .input_line > input[name='reg_name']").val());
$.ajax({
type: "POST",
url: "register.php",
data: url,
cache: false,
dataType: 'json',
success: function(data)
{
if (data.error)
{
error = jQuery('' + data.message + '
')
.css({'color': 'red', 'text-align': 'center'});
$("#facebox .button").before(error);
}
else
{
jQuery.facebox('You will recieve email soon');
}
$("#facebox .button > button").css({'background': ''});
$("#facebox .button > button").html(button_text);
$("#facebox .button > button").attr('disabled', '');
}
});
//alert( $("#facebox .reg_inline > .input_line > input[name='reg_name']").val() + " " + $("#facebox .reg_inline > .input_line > input[name='reg_email']").val() );
}
else
{
error = jQuery('Please enter valid email adress
')
.css({'color': 'red', 'text-align': 'center'});
$("#facebox .button").before(error);
}
return false;
};
changePageMyLocations = function(arg)
{
$(".pagination").pagination(BmapPoints.length, {
items_per_page:8,
current_page: arg,
callback:function(argv)
{
currentPage = argv;
changePageMyLocations(argv);
return false;
}
});
var page_photos = [];
var del = 1;
if (arg < 1)
{
del = 0;
}
page_photos = page_photos.concat(BmapPoints);
page_photos = page_photos.slice( (arg * 8) , (arg * 8) + 8 );
if (user_editable)
map.clearOverlays();
$('.my_locations > .location_container').remove();
for (var i=0;i < page_photos.length;i++)
{
if (user_editable)
if (page_photos[i].lat != 0 && page_photos[i].lng != 0)
{
createMarker(new GLatLng(page_photos[i].lat, page_photos[i].lng), page_photos[i], i);
}
var htm = ' \
\
';
if (user_editable)
{
htm += '\
\
\
' + ((page_photos[i].published) ? 'Hide' : 'Show') + ' \
\
';
if (page_photos[i].lat == 0 && page_photos[i].lng == 0) {
htm += '
\
Map \
';
}
htm += '
';
}
htm += '\
';
if ($('.my_locations > .location_container').length == 0)
{
$('.my_locations').prepend(htm);
}
else
{
$('.my_locations > .location_container:last').after(htm);
}
}
}
// helper
function objToString(o) {
var s = '{';
for (var p in o)
s += '"' + p + '":"' + escape(o[p]) + '",';
s = s.substr(0, s.length -1);
return s + '}';
}
// helper
function elementToString(n, useRefs) {
var attr = "", nest = "", a = n.attributes;
for (var i=0; a && i < a.length; i++)
attr += ' ' + a[i].nodeName + '="' + a[i].nodeValue + '"';
if (n.hasChildNodes == false)
return "<" + n.nodeName + "\/>";
for (var i=0; i < n.childNodes.length; i++) {
var c = n.childNodes.item(i);
if (c.nodeType == 1) nest += elementToString(c);
else if (c.nodeType == 2) attr += " " + c.nodeName + "=\"" + c.nodeValue + "\" ";
else if (c.nodeType == 3) nest += c.nodeValue;
}
var s = "<" + n.nodeName + attr + ">" + nest + "<\/" + n.nodeName + ">";
return useRefs ? s.replace(//g,'>') : s;
}