PreloadImages()

function PreloadImages()
{
	var img;
	
	img = new Image();
	
	img.setAttribute("src","/assets/i/video/playlist1.png");
	img.setAttribute("src","/assets/i/video/playlist2.png");
	img.setAttribute("src","/assets/i/video/playlist3.png");
	img.setAttribute("src","/assets/i/video/tick0.png");
	img.setAttribute("src","/assets/i/video/tick1.png");
	img.setAttribute("src","/assets/i/video/tick2.png");
	img.setAttribute("src","/assets/i/video/tick3.png");
	img.setAttribute("src","/assets/i/video/thumbs_up.png");
	img.setAttribute("src","/assets/i/video/thumbs_down.png");

	
	img = null;
}

function AJAX( objLink, strErrorCall )
{
	var strTargetURL
	
	Initialize();
											
	// Check XMLHTTP support
	if( blnSupportsXMLHTTP )
	{
		strTargetURL = AddValueToURL( objLink.getAttribute("href"), "ajax=1" )
		return SendXMLHTTP( strTargetURL, strErrorCall );
	}
	else
	{
		return true;
	}		
}

//Start of Favorite Request Part
function VideoRemoved( intMemberId )
{
	var tempFunction = function(){
		if( document.getElementById( "video_link_" + intMemberId ) )
		{
			document.getElementById( "video_link_" + intMemberId ).setAttribute("href","/video/ax_video_add.cfm?vid=" + intMemberId + "&amp;url=" + escape(document.location.href) );
			document.getElementById( "video_img_" + intMemberId ).setAttribute("src","/assets/i/video/tick0.png");
			document.getElementById( "video_img_" + intMemberId ).setAttribute("alt","Add to Blacklist");
		};
	}
	setTimeout( tempFunction, 500);
}
function VideoAdded( intMemberId )
{
	var tempFunction = function(){
		if( document.getElementById( "video_link_" + intMemberId ) )
		{
			document.getElementById( "video_link_" + intMemberId ).setAttribute("href","/video/ax_video_remove.cfm?vid=" + intMemberId + "&amp;url=" + escape(document.location.href) );
			document.getElementById( "video_img_" + intMemberId ).setAttribute("src","/assets/i/video/tick2.png");
			document.getElementById( "video_img_" + intMemberId ).setAttribute("alt","Remove from Blacklist");
		};
	}
	setTimeout( tempFunction, 500);
}

function VideoError( intMemberId )
{
	var tempFunction = function(){
		if( document.getElementById( "video_link_" + intMemberId ) )
		{
			document.getElementById( "video_link_" + intMemberId ).removeAttribute("href" );
			document.getElementById( "video_link_" + intMemberId ).removeAttribute("onClick" );
			document.getElementById( "video_img_" + intMemberId ).setAttribute("src","/assets/i/video/tick3.png");
			document.getElementById( "video_img_" + intMemberId ).setAttribute("alt","Remove from Blacklist");
		};
	}
	setTimeout( tempFunction, 500);
}

function VideoLoading( intMemberId )
{
	if( document.getElementById( "video_link_" + intMemberId ) )
	{
		document.getElementById( "video_link_" + intMemberId ).setAttribute("href","");
		document.getElementById( "video_img_" + intMemberId ).setAttribute("src","/assets/i/video/tick1.png");
		document.getElementById( "video_img_" + intMemberId ).setAttribute("alt","Saving");
	};
}

function VideoToggle( objLink, intMemberId ) 
{
			
	var blnReturn, strImageURL, strAbortText;
	strImageURL = document.getElementById( "video_img_" + intMemberId ).getAttribute("src")

	if( strImageURL.substring( strImageURL.length-9, strImageURL.length ) == "tick1.png" )
		return false;
		
	if( strImageURL.substring( strImageURL.length-9, strImageURL.length ) == "tick0.png" )
	{
		strAbortText = "VideoRemoved( "+ intMemberId +" );"
	}
	else
	{
		strAbortText = "VideoAdded( "+ intMemberId +" );"
	}
	
	blnReturn = AJAX( objLink, strAbortText  );
	
	// Only do if bln return is false ( as blnReturn indicates AJAX was successful )
	if( ! blnReturn )
	{
		VideoLoading( intMemberId );					
	}
	
	return blnReturn;
}




function VideoVoteUpAdded( intMemberId )
{
	var tempFunction = function(){
		if( document.getElementById( "video_link_u" + intMemberId ) )
		{
			document.getElementById( "video_link_d" + intMemberId ).removeAttribute("href" );
			document.getElementById( "video_link_d" + intMemberId ).removeAttribute("onMouseOver" );
			document.getElementById( "video_link_d" + intMemberId ).removeAttribute("onMouseOut" );
			document.getElementById( "video_img_u" + intMemberId ).setAttribute("src","/assets/i/video/thumbs_up_voted.png");
			document.getElementById( "video_img_d" + intMemberId ).setAttribute("src","/assets/i/video/thumbs_down_white.png");
			document.getElementById( "video_img_u" + intMemberId ).setAttribute("alt","Remove from Blacklist");
		};
	}
	setTimeout( tempFunction, 500);
}
function VideoVoteUpError( intMemberId )
{
	var tempFunction = function(){
		if( document.getElementById( "video_link_u" + intMemberId ) )
		{
			document.getElementById( "video_link_u" + intMemberId ).removeAttribute("href" );
			document.getElementById( "video_link_u" + intMemberId ).removeAttribute("onClick" );
			document.getElementById( "video_img_u" + intMemberId ).setAttribute("src","/assets/i/video/thumbs_up_error.png");
			document.getElementById( "video_img_u" + intMemberId ).setAttribute("alt","Remove from Blacklist");
		};
	}
	setTimeout( tempFunction, 500);
}
function VideoVoteUpLoading( intMemberId )
{
	if( document.getElementById( "video_link_u" + intMemberId ) )
	{
		document.getElementById( "video_link_u" + intMemberId ).removeAttribute("href" );
		document.getElementById( "video_link_u" + intMemberId ).removeAttribute("onMouseOver" );
		document.getElementById( "video_link_u" + intMemberId ).removeAttribute("onMouseOut" );
		document.getElementById( "video_img_u" + intMemberId ).setAttribute("src","/assets/i/video/thumbs_up_wait.png");
		document.getElementById( "video_img_u" + intMemberId ).setAttribute("alt","Saving");
	};
}
function VideoVoteUpToggle( objLink, intMemberId ) 
{
			
	var blnReturn, strImageURL, strAbortText;
	strImageURL = document.getElementById( "video_img_u" + intMemberId ).getAttribute("src")

	if( strImageURL.substring( strImageURL.length-19, strImageURL.length ) == "thumbs_up_voted.png" )
		return false;
		
	if( strImageURL.substring( strImageURL.length-13, strImageURL.length ) == "thumbs_up.png" )
	{
		strAbortText = "VideoVoteUpAdded( "+ intMemberId +" );"
	}
	
	blnReturn = AJAX( objLink, strAbortText  );
	
	// Only do if bln return is false ( as blnReturn indicates AJAX was successful )
	if( ! blnReturn )
	{
		VideoVoteUpLoading( intMemberId );					
	}
	
	return blnReturn;
}


function VideoVoteDownAdded( intMemberId )
{
	var tempFunction = function(){
		if( document.getElementById( "video_link_d" + intMemberId ) )
		{
			document.getElementById( "video_link_u" + intMemberId ).removeAttribute("href" );
			document.getElementById( "video_link_u" + intMemberId ).removeAttribute("onMouseOver" );
			document.getElementById( "video_link_u" + intMemberId ).removeAttribute("onMouseOut" );
			document.getElementById( "video_img_d" + intMemberId ).setAttribute("src","/assets/i/video/thumbs_down_voted.png");
			document.getElementById( "video_img_u" + intMemberId ).setAttribute("src","/assets/i/video/thumbs_up_white.png");
			document.getElementById( "video_img_d" + intMemberId ).setAttribute("alt","Remove from Blacklist");
		};
	}
	setTimeout( tempFunction, 500);
}
function VideoVoteDownError( intMemberId )
{
	var tempFunction = function(){
		if( document.getElementById( "video_link_d" + intMemberId ) )
		{
			document.getElementById( "video_link_d" + intMemberId ).removeAttribute("href" );
			document.getElementById( "video_link_d" + intMemberId ).removeAttribute("onClick" );
			document.getElementById( "video_img_d" + intMemberId ).setAttribute("src","/assets/i/video/thumbs_down_error.png");
			document.getElementById( "video_img_d" + intMemberId ).setAttribute("alt","Remove from Blacklist");
		};
	}
	setTimeout( tempFunction, 500);
}
function VideoVoteDownLoading( intMemberId )
{
	if( document.getElementById( "video_link_d" + intMemberId ) )
	{
		document.getElementById( "video_link_d" + intMemberId ).removeAttribute("href" );
		document.getElementById( "video_link_d" + intMemberId ).removeAttribute("onMouseOver" );
		document.getElementById( "video_link_d" + intMemberId ).removeAttribute("onMouseOut" );
		document.getElementById( "video_img_d" + intMemberId ).setAttribute("src","/assets/i/video/thumbs_down_wait.png");
		document.getElementById( "video_img_d" + intMemberId ).setAttribute("alt","Saving");
	};
}
function VideoVoteDownToggle( objLink, intMemberId ) 
{
			
	var blnReturn, strImageURL, strAbortText;
	strImageURL = document.getElementById( "video_img_d" + intMemberId ).getAttribute("src")

	if( strImageURL.substring( strImageURL.length-21, strImageURL.length ) == "thumbs_down_voted.png" )
		return false;
		
	if( strImageURL.substring( strImageURL.length-15, strImageURL.length ) == "thumbs_down.png" )
	{
		strAbortText = "VideoVoteDownAdded( "+ intMemberId +" );"
	}
	
	blnReturn = AJAX( objLink, strAbortText  );
	
	// Only do if bln return is false ( as blnReturn indicates AJAX was successful )
	if( ! blnReturn )
	{
		VideoVoteDownLoading( intMemberId );					
	}
	
	return blnReturn;
}


function VideoFavoriteAdded( intMemberId )
{
	var tempFunction = function(){
		if( document.getElementById( "video_link_f" + intMemberId ) )
		{
			toggleLayer('favoriteForm');
		};
	}
	setTimeout( tempFunction, 500);
}

function VideoFavoriteToggle( objLink, intMemberId ) 
{
			
	var blnReturn, strImageURL, strAbortText;

		strAbortText = "VideoFavoriteAdded( "+ intMemberId +" );"
	
	blnReturn = AJAX( objLink, strAbortText  );
	
	// Only do if bln return is false ( as blnReturn indicates AJAX was successful )
	//if( ! blnReturn )
	//{
	//	VideoVoteDownLoading( intMemberId );					
	//}
	
	return blnReturn;
}




//Start of Quicklist Request Part
function VideoQuicklistRemoved( intMemberId )
{
	var tempFunction = function(){
		if( document.getElementById( "video_link_qr" + intMemberId ) )
		{
			
		};
	}
	setTimeout( tempFunction, 500);
}
function VideoQuicklistAdded( intMemberId )
{
	var tempFunction = function(){
		if( document.getElementById( "video_link_q" + intMemberId ) )
		{
			document.getElementById( "video_link_q" + intMemberId ).removeAttribute("href" );
			document.getElementById( "video_link_q" + intMemberId ).removeAttribute("onClick" );
			document.getElementById( "video_img_q" + intMemberId ).removeAttribute("onMouseOver" );
			document.getElementById( "video_img_q" + intMemberId ).removeAttribute("onMouseOut" );
			document.getElementById( "video_img_q" + intMemberId ).setAttribute("src","/assets/i/video/playlist3.png");
			document.getElementById( "video_img_q" + intMemberId ).setAttribute("alt","Remove from Blacklist");
		};
	}
	setTimeout( tempFunction, 500);
}

function VideoQuicklistError( intMemberId )
{
	var tempFunction = function(){
		if( document.getElementById( "video_link_q" + intMemberId ) )
		{
			document.getElementById( "video_link_q" + intMemberId ).removeAttribute("href" );
			document.getElementById( "video_link_q" + intMemberId ).removeAttribute("onClick" );
			document.getElementById( "video_img_q" + intMemberId ).setAttribute("src","/assets/i/video/playlist2.png");
			document.getElementById( "video_img_q" + intMemberId ).setAttribute("alt","Remove from Blacklist");
		};
	}
	setTimeout( tempFunction, 500);
}

function VideoQuicklistLoading( intMemberId )
{
	if( document.getElementById( "video_link_q" + intMemberId ) )
	{
		document.getElementById( "video_link_q" + intMemberId ).setAttribute("href","");
		document.getElementById( "video_img_q" + intMemberId ).setAttribute("src","/assets/i/video/playlist2.png");
		document.getElementById( "video_img_q" + intMemberId ).setAttribute("alt","Saving");
	};
}

function VideoQuicklistToggle( objLink, intMemberId ) 
{
			
	var blnReturn, strImageURL, strAbortText;
	strImageURL = document.getElementById( "video_img_q" + intMemberId ).getAttribute("src")

	if( strImageURL.substring( strImageURL.length-9, strImageURL.length ) == "playlist3.png" )
		return false;
		
	if( strImageURL.substring( strImageURL.length-9, strImageURL.length ) == "playlist1.png" )
	{
		strAbortText = "VideoQuicklistRemoved( "+ intMemberId +" );"
	}
	else
	{
		strAbortText = "VideoQuicklistAdded( "+ intMemberId +" );"
	}
	
	blnReturn = AJAX( objLink, strAbortText  );
	
	// Only do if bln return is false ( as blnReturn indicates AJAX was successful )
	if( ! blnReturn )
	{
		VideoQuicklistLoading( intMemberId );					
	}
	
	return blnReturn;
}


function VideoQuicklistRemoveToggle( objLink, intMemberId ) 
{
			
	var blnReturn, strAbortText;

		strAbortText = "VideoQuicklistRemoved( "+ intMemberId +" );"

	
	blnReturn = AJAX( objLink, strAbortText  );
	
	// Only do if bln return is false ( as blnReturn indicates AJAX was successful )
	if( ! blnReturn )
	{
		VideoQuicklistLoading( intMemberId );					
	}
	deleteRow(objLink);
	return blnReturn;
}



function AddValueToURL( strUrl, strValue )
{
	strUrl = String(strUrl)
	if( strUrl.indexOf("?",0) < 0 )
	{
		strUrl = strUrl + "?"
	} 
	if( strUrl.charAt( strUrl.length-1 ) != "&" && strUrl.charAt( strUrl.length-1 ) != "?" ) 
	{
		strUrl = strUrl + "&"
	}
	strUrl = strUrl + strValue	
	return strUrl;
}