/*
@description Global front-end javascript functions

@author	Bryan Gullan
@created 2006-05-18

@dependsOn 
@basedOn 

@modified
*/

function clearsearchbox() {
	if(document.getElementById('searchinput').value == "Enter search term"){
		document.getElementById('searchinput').value = '';
	}
}

function email_to_friend(page) {
	window.open('/applications/send_to_friend/compose.rm?id='+page,'Email','width=380,height=550,scrollbars=0');
}

function post_comment(page) {
	window.open('/applications/comments/comments.rm?article_id='+page,'Comment','width=380,height=550,scrollbars=0');
}

function findVideoPopupLinks(){
	popupLinks = YAHOO.util.Dom.getElementsByClassName("launch-video","a");
	for(i=0;i<popupLinks.length;i++){
		popupLinks[i].onclick=function(e){
			var ids = this.href.replace(/http:\/\/([^\/]*)\/applications\/mediaplayer\/video.rm\?media_id=/,""); //get the media and page ids
			ids = ids.split("&id="); // split the two ids; they're either side of the '&id='
			window.open('/applications/mediaplayer/video.rm?media_id='+ids[0]+'&id='+ids[1],'Video console','width=450,height=450,scrollbars=1');
			YAHOO.util.Event.preventDefault(e);
		}
	}
}

YAHOO.util.Event.addListener(window,'load',findVideoPopupLinks);
