// Webcko Mootools Related

// BLOG PAGINATION
function commentpage(id, page) {
	var url = '?ajax=commentpage&id='+id+'&page='+page;
	new Ajax(url, {
			 method: 'get',
			 update: $('blog_comments'),
			 evalScripts: true
	}).request();
	return false;
}

// BLOG COMMENT RATINGS
function thumbsup(id) {
	var url = '?ajax=thumbsup&id='+id;
	new Ajax(url, {
			 method: 'get',
			 evalScripts: true
	}).request();
	return false;
}

function thumbsdown(id) {
	var url = '?ajax=thumbsdown&id='+id;
	new Ajax(url, {
			 method: 'get',
 			 evalScripts: true
	}).request();
	return false;
}

// START ITINERARY
function i_add(id,type) {
	// perform ajax request and update i_status
	var mUrl = '?ajax=i_add&id='+id+'&type='+type;
	new Request({
			 url: "/index.php", 
			 data: {"ajax":"i_add", "id":id, "type":type},
			 method: 'get',
			 onSuccess: function(responseText, responseXML) {
				myArray = responseText.split(/[^0-9]+/);
				if (Browser.name == "ie" && Browser.version < 9)
					myCount="("+myArray[0]+")";
				else
					myCount="("+myArray[1]+")";
				$('count').innerHTML=myCount;
			 	$("side-panel").getElement("iframe").src = "/page/itinerary";
				$('side-panel-tab').set('styles', {
					textDecoration:'blink'
				});
			 }
	}).send();
	return false;
}

function i_list_remove(id,type) {
	// perform ajax request and update i_status
	var url = '?ajax=i_list_remove&id='+id+'&type='+type;
	new Request({
			 url: "/index.php",
			 data: {"ajax":"i_list_remove","id":id,"type":type},
			 method: 'get',
			 onSuccess: function(responseText, responseXML) {$('i_listing').innerHTML = responseText;}
	}).send();
	return false;
}

function i_shortlist_remove(sid) {
	// perform ajax request and update i_status
	var url = '?ajax=i_shortlist_remove&id='+sid;
	new Ajax(url, {
			 method: 'get',
			 update: $('i_listing')
	}).request();
	
	// update the map now
	var url = '?ajax=i_map_refresh';
	new Ajax(url, {
			method: 'get',
			update: $('i_map')
	}).request();
	
	return false;
}

function i_remove(sid) {
	// perform ajax request and update i_status
	var url = '?ajax=i_remove&id='+sid;
	new Ajax(url, {
			 method: 'get',
			 update: $('i_status')
	}).request();
	return false;
}

function i_view() {
	// redirect the user to the view page
	document.location = '/page/itinerary';
	return false;
	
	// display a listing of stores to the user
	var url = '?ajax=i_view';
	new Ajax(url, {
			 method: 'get',
			 update: $('i_status')
	}).request();
	return false;
}

function i_list_clear() {
	// perform ajax request and update i_status
	var url = '?ajax=i_list_clear';
	new Ajax(url, {
			 method: 'get',
			 update: $('i_listing'),
			 onComplete: document.location = '/page/events'
	}).request();
	return false;
}

function i_print() {
	if ( confirm('Press OK to print this page') )
		window.print();
	return false;
}
// END ITINERARY

window.addEvent('domready', function() {

	// slide_nav
	try {
		/* hover side menu thing */
		var list = $$('.slide_nav li');
		list.each(function(element) {
			var fx = new Fx.Styles(element, {duration:200, wait:false});
		 
			element.addEvent('mouseenter', function(){
				fx.start({
					'padding-left': 25
				});
			});
		 
			element.addEvent('mouseleave', function(){
				fx.start({
					'padding-left': 10
				});
			});

		});	
	} catch (e) {
		
	}	

	// dim_image
	try {
		/* hover side menu thing */
		var list = $$('.dim_image');
		list.each(function(element) {
			var fx = new Fx.Styles(element, {duration:300, wait:false});
		 
			element.addEvent('mouseenter', function(){
				fx.start({
					'opacity': .9
				});
			});
		 
			element.addEvent('mouseleave', function(){
				fx.start({
					'opacity': .3
				});
			});

			element.setStyle('opacity','.3');
		});	
	} catch (e) {
		
	}
});
