// Anything in here will be triggered when the page is ready (so all DIV's are present etc.)

$(document).ready(function(){
	populateElement('#searchBox', 'Enter keywords');	

	$('#mycarousel a').hover(
		function() {
			try{
				var thisOne = $(this).children();
				$(thisOne[0]).addClass('img_border');
				$(thisOne[1]).addClass('txt_underline');
			}catch(e){ }
		}, 
		function() {
			try{
				var thisOne = $(this).children();
				$(thisOne[0]).removeClass('img_border');
				$(thisOne[1]).removeClass('txt_underline');
			}catch(e){ }
		}
	);	
});

function populateElement(selector, defvalue) {
    if($.trim($(selector).val()) == "") {
        $(selector).val(defvalue);
    }
  
    $(selector).focus(function() {
        if($(selector).val() == defvalue) {
            $(selector).val("");
        }
    });
    
    $(selector).blur(function() {
        if($.trim($(selector).val()) == "") {
            $(selector).val(defvalue);
        }
    });
 }


// Play list
function addToPlaylist() {
	thePage = document.getElementById('pageWrap');
	pageHeight = thePage.offsetHeight;
	//pageWidth = thePage.offsetWidth;
	pageWidth = document.body.clientWidth;
	
	thePage.innerHTML += '<div id="overlay" style="width:' + pageWidth + 'px; height:' + pageHeight + 'px;"></div>';
	
	formHtml = '<form name="playlist" id="playlist" class="playlist" action="">';
	formHtml += '<p><label for="listTitle">Enter a title for this playlist:</label> <input type="text" name="listTitle" id="listTitle" /></p>';
	formHtml += '<p class="floatLeft">You must be signed in to save a playlist</p>';
	formHtml += '<p class="floatRight"><input type="image" src="img/btnCancel.gif" class="submit" alt="Cancel" onmouseover="this.src=\'img/btnCancelOvr.gif\';" onmouseout="this.src=\'img/btnCancel.gif\';" /><input type="image" src="img/btnSubmit.gif" class="submit" alt="Submit" onmouseover="this.src=\'img/btnSubmitOvr.gif\';" onmouseout="this.src=\'img/btnSubmit.gif\';" /></p>';
	formHtml += '</form>';
	
	thePage.innerHTML += formHtml;
}


function clearForm() {
	var thePage = document.getElementById('pageWrap');
	var overlay = document.getElementById('overlay');
	var playlist = document.getElementById('playlist');
	
	thePage.removeChild(overlay);
	thePage.removeChild(playlist);
}


var firstime = 0;  
  
function changeVideo(videoURL)
{
	 var movie = videoURL;
		if(movie.length > 0)
		{
			var player = document.getElementById('player');
			var kids = player.childNodes;
			for(var i=0; i<kids.length; i++)
			{
				if(kids[i].nodeType ==1)
				{
					player.removeChild(kids[i]);
				}
			}
		
		embd = '<embed type="application/x-shockwave-flash" src="' + movie + '" style="" id="name" name="name" bgcolor="#000000" quality="high" allowfullscreen="true" flashvars="flashVarText=this is passed in via FlashVars" height="320" width="500">';
		
		//player.appendChild(newPlayer);
		player.innerHTML = embd;
		}
}



 // IE6 Background Hover Flicker Fix
 try {
	document.execCommand('BackgroundImageCache',false,true);
	}catch(ignoreme){	
}











