﻿//
// Jomiro-core v0.1b
// 
// *************************************************
// Copyright 2008, Jomito.com
// 
// No code from this file may be copied without the
// written approval of the Jomito.com founders.
// 
// *************************************************
/*
function toggleAdvSrc() {
    var myVerticalSlide = new Fx.Slide('AdvancedSearch');

	$('toggleAdvSrc').addEvent('click', function(e){
		e.stop();
		myVerticalSlide.toggle();
	});
	
	// When Vertical Slide ends its transition, we check for its status
	// note that complete will not affect 'hide' and 'show' methods
	myVerticalSlide.addEvent('complete', function() {
		$('vertical_status').set('html', status[myVerticalSlide.open]);
	});
}*/

function AreYouSure(url,lcid) {
     if (confirm('Er du sikker?')) { document.location=url; }
}

function ShowUserConditions() {
    
}

function ShowItem(id) {
    window.location.href='/Item/?id='+id;
}

function changecolor(id, color) {
    element = document.getElementById(id);
    event.cancelBubble = true;
    oldcolor = element.currentStyle.background;
    element.style.background = color;
} 

function SubmitComment(itemid) {
    var reqAddComment = new Request.HTML({url:'/PageComponents/CommentBox.aspx', 
		onSuccess: function(html) {
			$('CommentBox').set('text', '');
			$('CommentBox').adopt(html);
		},
		onFailure: function() {
			$('CommentBox').set('text', 'Der opstod en fejl.');
		}
    }).post($('AddCommentForm'));	
	reqAddComment.send();
}

function AddAsFriend(UserID) {
        var reqAddAsFriendRequest = new Request.HTML({url:'/PageComponents/AddAsFriend.aspx?id='+UserID, 
	        onSuccess: function(html) {
		        $('LayerAddAsFriend').set('text', '');
		        $('LayerAddAsFriend').adopt(html);
	        },
	        onFailure: function() {
		        $('LayerAddAsFriend').set('text', 'Der opstod en fejl.');
	        }
        });
    	reqAddAsFriendRequest.send();
}

function LoadFriendRequests(mode,key) {
        var reqFriendRequests = new Request.HTML({url:'/PageComponents/FriendRequests.aspx?mode='+mode+'&key='+key, 
	        onSuccess: function(html) {
		        $('LayerFriendRequests').set('text', '');
		        $('LayerFriendRequests').adopt(html);
	        },
	        onFailure: function() {
		        $('LayerFriendRequests').set('text', 'Der opstod en fejl.');
	        }
        });
    	reqFriendRequests.send();
}

function LoadComments(itemid) {
	// We can use one Request object many times.
	var reqCommentbox = new Request.HTML({url:'/PageComponents/CommentBox.aspx?ItemID='+itemid, 
		onSuccess: function(html) {
			// Clear the text currently inside the results div.
			$('CommentBox').set('text', '');
			// Inject the new DOM elements into the results div.
			$('CommentBox').adopt(html);
		},
		//Our request will most likely succeed, but just in case, we'll add an
		//onFailure method which will let the user know what happened.
		onFailure: function() {
			$('CommentBox').set('text', 'Der opstod en fejl.');
		}
	});
	
	reqCommentbox.send();
}


function LoadTagCloud() {
	// We can use one Request object many times.
	var reqTagCloud = new Request.HTML({url:'/PageComponents/TagCloud.aspx', 
		onSuccess: function(html) {
			// Clear the text currently inside the results div.
			$('TagCloud').set('text', '');
			// Inject the new DOM elements into the results div.
			$('TagCloud').adopt(html);
		},
		//Our request will most likely succeed, but just in case, we'll add an
		//onFailure method which will let the user know what happened.
		onFailure: function() {
			$('TagCloud').set('text', 'Der opstod en fejl.');
		}
	});
	reqTagCloud.send();
}

function LoadRating(itemid, rate) {
	// We can use one Request object many times.
	var reqItemRating = new Request.HTML({url:'/PageComponents/ItemRating.aspx?id='+itemid+'&rate='+rate, 
		onSuccess: function(html) {
			// Clear the text currently inside the results div.
			$('ItemRatingLayer').set('text', '');
			// Inject the new DOM elements into the results div.
			$('ItemRatingLayer').adopt(html);			
		},
		//Our request will most likely succeed, but just in case, we'll add an
		//onFailure method which will let the user know what happened.
		onFailure: function() {
			$('ItemRatingLayer').set('text', 'The request failed.');
		}
	});
	
	reqItemRating.send();
}