//-----------------------------------------------------------------------------------------------------------------------
//  Filename			:	articleinc.js
//-----------------------------------------------------------------------------------------------------------------------
//  Project			    :	Living Library
//  Language			:	JavaScript
//  Author			    :	N/A
//  Date of creation	:	N/A
//  ----------------------------------------------------------------------------------------------------------------------
//  Descriptions
//
//  Revisions           :
//  Date                Name                                Description
//  30-Nov-2007         Jibu                                function named ShowFlash removed from this file(Defect ID:36128) 
//-----------------------------------------------------------------------------------------------------------------------

var winTips
var dictpage='';
var temptitle;
function fnTips()
{
    winTips = window.open('/help/media/animtips.htm','winTips','width=300,height=250,scrollbars=yes,resizable=yes,location=n0')
}


function getMeaning() {

	
	var word;
	var width=440;
    var height=244;
    var resize=0;
    var scroll=1;
    var title=0;
	xposition=0; yposition=0;
	var center=1;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
        }      
    args = "width=" + width + ","
    + "height=" + height + ","
    + "location=0,"
    + "menubar=0,"
    + "resizable=" + resize + ","
    + "scrollbars=" + scroll + ","
    + "status=0,"
    + "titlebar=" + title + ","
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only
    
   word=Trim(document.getElementById('srcdic').value);
  
	
	if (word != '')
	{
		dictpage=window.open("meaning.asp?text="+word,"Dictionary",args)
	}
	else
	{
		alert("Please type a word and click 'GO' ");
		return;
		
	}
	
		
}
function Trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}
function GetText(word)
{

	var word;
	
	if (navigator.userAgent.indexOf("MSIE") > 0) // //IE 4+
		word = document.selection.createRange().text;
	else //NS4+
		word=document.getSelection();
		
	return word;
	
}
function GetArticles(strArticleID,blnHighlight,Find,FromPage,RMModuleID)
	{
		if (typeof(Find) == 'undefined')
			document.frmPerformSearch.action="article.asp?RMArticleID="+strArticleID+"&blnHighlight="+ blnHighlight;
		else 
			if ((FromPage != '') || (Find ==''))
				document.frmPerformSearch.action="article.asp?RMArticleID="+strArticleID+"&blnHighlight="+ blnHighlight + "&pageFrom="+FromPage +"&RMModuleID="+ RMModuleID;
			else
				document.frmPerformSearch.action="article.asp?RMArticleID="+strArticleID+"&Find="+Find+"&blnHighlight="+ blnHighlight;
		document.frmPerformSearch.submit();
		event.returnValue = false;	
	}
function browsethisdayinhistory(strUserText,strHeading,intMonth,intYear,intDay)
{
if (document.getElementById('tempHeading'))
	document.getElementById('tempHeading').value=strHeading;
if (document.getElementById('tempBrowseText'))
	document.getElementById('tempBrowseText').value= "'" +strUserText + "' " + strUserText;
document.frmThisDay.action ="browseaction.asp?SearchSections=Title Only&LL_SearchType=0&PageFrom=onthisday&mlcMonth=" +intMonth+ "&mlcYear=" +intYear+ "&mlcDay=" +intDay;
document.frmThisDay.submit();
if (navigator.userAgent.indexOf("Safari") > 0 )
	{
		event.returnValue = false;
	}
	else
	{
		var oEvent = (navigator.appName == "Netscape")?arguments.callee.caller.arguments[0] : event;
		if (navigator.appName == "Microsoft Internet Explorer") 
			event.returnValue = false;
		else
			oEvent.preventDefault();
	}
}	
function GoBack()
{
	document.frmPerformSearch.action="backtolist.asp";
	document.frmPerformSearch.submit();
	event.returnValue = false;	
}	
function StrReplace(strString, strReplace, strWith)
{
	var i=0, strSource = strString;
	while ((i = strSource.indexOf(strReplace,i)) != -1)
		if(i) strSource = strSource.substring(0, i) + strWith + strSource.substring(i + strReplace.length, strSource.length)
		else strSource = strWith + strSource.substring(i + strReplace.length, strSource.length);
	return strSource;
}
function escapeVal(strtext,replaceWith)
{ 
	strtext = escape(strtext); 
	for(i=0; i<strtext.length; i++)
	{
		if(strtext.indexOf("%0D%0A") > -1)
		{ 
			strtext =strtext.replace("%0D%0A",replaceWith);
		}
		else if(strtext.indexOf("%0A") > -1)
		{
			strtext = strtext.replace("%0A",replaceWith);
		}
		else if(strtext.indexOf("%0D") > -1)
		{ 
			strtext = strtext.replace("%0D",replaceWith);
		}

	}
	strtext = unescape(strtext);
	return strtext;
}
function ChangeTitle()
{
 //this is to replace the title with entity converted title
    if(document.getElementById("heading").innerText)
		{
			document.title = escapeVal(document.getElementById("heading").innerText,''); 							 
		}
   else
		{
		//document.title = document.getElementById("heading").innerHTML.replace(/(<script[^>]*?>.*?<\/script>)|[\r\n]/gi,"").replace(/­<[\/\!]*?[^<>]*?>/g,"");				
		temptitle = document.getElementById("heading").innerHTML.replace(/(<script[^>]*?>.*?<\/script>)|[\r\n]/gi,"").replace(/­<[\/\!]*?[^<>]*?>/g,"");		
		temptitle = StrReplace(temptitle,'<I>','');
		temptitle = StrReplace(temptitle,'</I>','');
		temptitle = StrReplace(temptitle,'<i>','');
		temptitle = StrReplace(temptitle,'<b>','');
		temptitle = StrReplace(temptitle,'</b>','');
		temptitle = StrReplace(temptitle,'</i>','');
		temptitle = StrReplace(temptitle,'–','-');
		temptitle = StrReplace(temptitle,'<span class="spnEnt">','');
		temptitle = StrReplace(temptitle,'</span>','');		
		temptitle = StrReplace(temptitle,'<div class="spnSmallCaps">','');
		temptitle = StrReplace(temptitle,'</div>','');		
		document.title = temptitle;					
		}		
}
function Addshortcut(strArticleID)
{
	var strArticleName;
	temptitle = document.title;	
	temptitle = StrReplace(temptitle,'#','');
	temptitle = StrReplace(temptitle,'&','');
	temptitle = StrReplace(temptitle,'<','');
	temptitle = StrReplace(temptitle,'>','');
	temptitle = StrReplace(temptitle,'+','');
	temptitle = StrReplace(temptitle,'%','');
	temptitle = StrReplace(temptitle,'`','');
	temptitle = StrReplace(temptitle,'/','');
	temptitle = StrReplace(temptitle,'\\','');
	document.getElementById("hdnEntityHeading").value = temptitle;
	document.frmPerformSearch.action="p_add_shortcuts.asp?RMArticleID=" +strArticleID;
	document.frmPerformSearch.submit();	
	event.returnValue = false;		
}

function ClosechildWind()
{
	if (dictpage && dictpage.open && !dictpage.closed) dictpage.close();		
}
    