//#########################################################################################
//# Copyright (C) 2008 ChosenList.com, Inc. All Rights Reserved.
//# Author        : Scott Wilfong (swilfong@exodusweb.com)
//# Inception     : January 30, 2008
//# Contributers  : ???
//#////////////////////////////////////////////////////////////////////////////////////////
//# Change Log
//#    2008-01-30 > by Scott Wilfong
//#               >  
//#########################################################################################

	//******************************************************************************//
	//* Usage       : AjaxFavorites();
	//* Purpose     : This script handles the ajax request for adding to favorites
	//*             : URLs outside of this site
	//******************************************************************************//
	function AjaxFavorites(id, type){
		//create ajax object
		var MyAjaxEngine = new powerHTTP();
		
		//begin handling loading
			MyAjaxEngine.loading = function() {
			};
		//end handling loading	
		
		//begin handling response
			MyAjaxEngine.complete = function(response) {
				if(MyAjaxEngine.was_successful()) {
					switch(response.text){
						case "added":
							alert("This video has been added to your favorites.");
							break;
						case "existing":
							alert("You have already added this video to your favorites.");
							break;
						default:
							alert("Unable to add this video to your favorites.\r\nPlease try again later.");
							break;
					}
				}
				else {
					var ErrorWindow = window.open('','Error','status=no,scrollbars=yes,resizable=yes,width=640,height=480');
					ErrorWindow.document.write(response.text);
				}
			};
		//end handling response		
		
		//begin execute request
			
			//call the aspx page with the parameters
			MyAjaxEngine.post("/video_player.aspx?r=favorite&t=" + type + "&i=" + id, "");
			return false;
		//end execute request	
	}

	//******************************************************************************//
	//* Usage       : AjaxFlag();
	//* Purpose     : This script handles the ajax request for adding to favorites
	//*             : URLs outside of this site
	//******************************************************************************//
	function AjaxFlag(id, type){
		//create ajax object
		var MyAjaxEngine = new powerHTTP();
		
		//begin handling loading
			MyAjaxEngine.loading = function() {
			};
		//end handling loading	
		
		//begin handling response
			MyAjaxEngine.complete = function(response) {
				if(MyAjaxEngine.was_successful()) {
					switch(response.text){
						case "added":
							alert("You have flagged this video.");
							break;
						case "existing":
							alert("You have already flagged this video.");
							break;
						default:
							alert("Unable to flag this video.\r\nPlease try again later.");
							break;
					}
				}
				else {
					var ErrorWindow = window.open('','Error','status=no,scrollbars=yes,resizable=yes,width=640,height=480');
					ErrorWindow.document.write(response.text);
				}
			};
		//end handling response		
		
		//begin execute request
			
			//call the aspx page with the parameters
			MyAjaxEngine.post("/video_player.aspx?r=flag&t=" + type + "&i=" + id, "");
			return false;
		//end execute request	
	}

	//******************************************************************************//
	//* Usage       : AjaxRating();
	//* Purpose     : This script handles the ajax request for adding to favorites
	//*             : URLs outside of this site
	//******************************************************************************//
	function AjaxRating(id, type, rating){
		//create ajax object
		var MyAjaxEngine = new powerHTTP();
		
		//begin handling loading
			MyAjaxEngine.loading = function() {
			};
		//end handling loading	
		
		//begin handling response
			MyAjaxEngine.complete = function(response) {
				if(MyAjaxEngine.was_successful()) {
					switch(response.text){
						case "added":
							alert("You have rated this video.");
							break;
						case "existing":
							alert("You have already rated this video.");
							break;
						default:
							alert("Unable to rate this video.\r\nPlease try again later.");
							break;
					}
				}
				else {
					var ErrorWindow = window.open('','Error','status=no,scrollbars=yes,resizable=yes,width=640,height=480');
					ErrorWindow.document.write(response.text);
				}
			};
		//end handling response		
		
		//begin execute request
			
			//call the aspx page with the parameters
			MyAjaxEngine.post("/video_player.aspx?r=rate&t=" + type + "&i=" + id + "&s=" + rating, "");
			return false;
		//end execute request	
	}

	//******************************************************************************//
	//* Usage       : AjaxShare();
	//* Purpose     : This script handles the ajax request for adding to favorites
	//*             : URLs outside of this site
	//******************************************************************************//
	function AjaxShare(id, type, email){
		//create ajax object
		var MyAjaxEngine = new powerHTTP();
		
		document.$('loading').style.display = "block";

		//begin handling loading
			MyAjaxEngine.loading = function() {
			};
		//end handling loading	
		
		//begin handling response
			MyAjaxEngine.complete = function(response) {
				document.$('loading').style.display = "none";
				if(MyAjaxEngine.was_successful()) {
					switch(response.text){
						case "added":
							alert("This video has been sent to" + email + ".");
							break;
						default:
							alert("Unable to send this video to " + email + ".\r\nPlease try again later.");
							break;
					}
				}
				else {
					var ErrorWindow = window.open('','Error','status=no,scrollbars=yes,resizable=yes,width=640,height=480');
					ErrorWindow.document.write(response.text);
				}
			};
		//end handling response		
		
		//begin execute request
			
			//call the aspx page with the parameters
			MyAjaxEngine.post("/video_player.aspx?r=share&t=" + type + "&i=" + id + "&e=" + email, "");
			return false;
		//end execute request	
	}
