// Get site section type
function getSectionType(){
	for(x in sectionTypes){
		if(currentStateIs("section", sectionTypes[x]))	
			return sectionTypes[x];
	}
	
	return false;
}

// Check to see if the given section/page is currently being used
function currentStateIs(type, target){
	return $j('#container').hasClass(type+target);
}

// Set rollover effects for all buttons with a .buttonhover div 
function setRollovers(){
	$j(".buttonhover").each(function(i) {		
		$j(this).parent().mouseover(function(){
			if(!currentStateIs("page", $j(this).attr("id")) && !$j(this).hasClass("ignore_hover"))
				$j(this).children(".buttonhover").show();
		});
		
		$j(this).parent().mouseout(function(){
			if(!currentStateIs("page", $j(this).attr("id")) && !$j(this).hasClass("ignore_hover"))
				$j(this).children(".buttonhover").hide();
		});		
	});
}

// Faded transition between two elements
function transition(current, target, infunc, outfunc, duration){
	$j(current).animate({
		opacity: 0
	}, {
		duration: duration,
		queue: false,
		complete: outfunc
	});

	$j(target).animate({
		opacity: 1
	}, {
		duration: duration,
		queue: false,
		complete: infunc
	});	
}

function scroll(source, duration, resetpoint){
	var width = source.width();
	
	source.animate({
		left: (width*-1)
	}, {
		easing: "linear",
		duration: duration,
		queue: false,
		complete: function() { 
			$j(this).css("left", resetpoint+"px");			
			scroll(source, duration, resetpoint); 
		}
	});
}

function startFlowplayer(){
	
	var controls = {
			autoHide: false,
			all: false,
			play: true,
			scrubber: true,
			mute: true,
			fullscreen: true,
			background: "#FAFAFA",
			buttonColor: "#626262",
			buttonOverColor: "#EFD31D"
	};

	$j("a[href$=.flv]").each(function(){
		$f($j(this).attr("id"), assetPath+"flowplayer/flowplayer.commercial-3.2.2.swf", {
			key: '#@8659122dbe68a1c9638',
			
			// don't start automcatically
			clip: {
				autoPlay: true,
				autoBuffering: true
			},
				
			// disable default controls
			plugins: {controls: controls}
	
		});	
	});
	
	$j("a[href$=.mp4]").each(function(){
		$f($j(this).attr("id"), assetPath+"flowplayer/flowplayer.commercial-3.2.2.swf", {
			key: '#@8659122dbe68a1c9638',
	
			// don't start automcatically
			clip: {
				autoPlay: true,
				autoBuffering: true
			},
				
			// disable default controls
			plugins: {controls: controls}
	
		});	
	});
	
	//controls['autoHide'] = false;
	controls['fullscreen'] = false;
	
	$j("a[href$=.mp3]").each(function(){

		$f($j(this).attr("id"), assetPath+"flowplayer/flowplayer.commercial-3.2.2.swf", {
			key: '#@8659122dbe68a1c9638',	
	
			// don't start automcatically
			clip: {
				autoPlay: false
			},
			plugins: {
				audio: {
					url: assetPath+"flowplayer/flowplayer.audio.swf"
				},
				controls: controls
			}	
	
		});	
	});	
}

function accept_friend_request (id,params){
	$j("#friend"+id).hide();
	$j.ajax({
		type: "GET",
		url: "/?func=users_friends/accept",
		data: params,
		dataType: "text/html",
		success: function(data){

		}
	});
}   

function ignore_friend_request (id,params){
	$j("#friend"+id).hide();
    $j.ajax({
		type: "GET",
		url: "/?func=users_friends/delete",
		data: params,
		dataType: "text/html"
   	});
}
   
function delete_friends (id,params){
	$j("#friend"+id).hide();
   	$j.ajax({
		type: "GET",
		url: "/?func=users_friends/delete",
		data: params,
		dataType: "text/html"
   	});
} 

