//This file is used in default.aspx
function process_form(action) {
	var msg = "";

	document.forms[0].action.value=action

	if (msg=="")
		document.forms[0].submit();
	else
		alert(msg);

}

function ChangeLayout(ArticleID)
{
	location.href = "ArticleContentNew.aspx?ArticleID=" + ArticleID		

}

function PreviewChanges(ArticleID)
{
	window.open("default.aspx?Mode=Preview&ArticleID=" + ArticleID)		

}


function CallSearch(ArticleID, ModuleID, OpenInNewWindow)
{
	var strEval
	strEval = document.getElementById('Module' + ModuleID + '_strSearchKeyword' + ModuleID).value;
	if (OpenInNewWindow == 1)
		window.open("PerformSearch.aspx?ArticleID=" + ArticleID + "&ModuleID=" + ModuleID + "&Keywords=" + escape(strEval));		
	else
		location.href = "PerformSearch.aspx?ArticleID=" + ArticleID + "&ModuleID=" + ModuleID + "&Keywords=" + escape(strEval);		

}


function CallNews(ArticleID, OpenInNewWindow)
{
	if (OpenInNewWindow == 1)
		window.open("default.aspx?ArticleID=" + ArticleID);		
	else
		location.href = "default.aspx?ArticleID=" + ArticleID ;		

}

function CallAdvert(strURL)
{
	window.open(strURL);		

}


function SetAction(action)

{
	document.forms[0].action.value=action

}

function ResubmitFormWithEdit(ArticleID)

{
	location.href = "default.aspx?Mode=BusyEditing&ArticleID=" + ArticleID

}

function FontHelp()
{
	window.open('FontHelp.htm', 'Help', 'toolbar=no,width=300,height=450,resizable, scrollbars');
}

function AddComments(ArticleID)
{
	var strURL 
	strURL = "WorkflowComments.aspx?ArticleID=" + ArticleID
	window.open(strURL, 'Comments', 'toolbar=no,width=600,height=600,resizable, scrollbars');
}


function PrintForm(sURL)
{
	var oWnd = window;	
	var oDoc = oWnd.document;	
	var strIFrame = "<iframe id='printHiddenFrame' name='printHiddenFrame' width='0' height='0'></iframe>";
	var strHFrame = "<frameset name=test onload='printMe.focus();printMe.print();' rows=\"100%\">" +
				"<frame name=printMe src=\""+sURL+"\">" +
				"</frameset>";

	if( oWnd.printHiddenFrame == null){
	  if (document.body.insertAdjacentHTML) {
	    //IE only
        oDoc.body.insertAdjacentHTML("beforeEnd", strIFrame);
         var framedoc = oWnd.printHiddenFrame.document;
         framedoc.open();
         framedoc.write(strHFrame);
         framedoc.close();
      } else if( typeof( document.body.innerHTML ) != 'undefined' ) {
         document.body.innerHTML += strIFrame;
         var framedoc = oWnd.printHiddenFrame.document;
         framedoc.open();
         framedoc.write(strHFrame);
         framedoc.close();
      } else {
        //use the old code
        var wndPrint = window.open(sURL, 'Print', 'toolbar=no,width=700,height=600,resizable, scrollbars');
        wndPrint.setTimeout('window.print();window.close();',1000);
      }
    } else {
      oWnd.printHiddenFrame.focus();
      oWnd.printHiddenFrame.print();
    }

}

function GoToAttributes(ArticleID)

{
	location.href = "ArticleAttributeEdit.aspx?Function=Workflow&ArticleID=" + ArticleID

}

function CheckKey(evt)
{
	if (evt.keyCode == 13)
	{
	
		//CallSearch(ArticleID, ModuleID, 1)
		
		if (!document.all && document.getElementById) {
			evt.preventDefault();
			evt.stopPropagation();
		}
		evt.cancelBubble = true;
		evt.returnValue = false;
		return false;

	}
}

function HandleSearch(evt, ArticleID, ModuleID, OpenInNewWindow)
{
	if (evt.keyCode == 13)
	{
	
		CallSearch(ArticleID, ModuleID, OpenInNewWindow)
		
		if (!document.all && document.getElementById) {
			evt.preventDefault();
			evt.stopPropagation();
		}
		evt.cancelBubble = true;
		evt.returnValue = false;
		return false;

	}
}



function CallLogin(ModuleID, CurrentPage)
{

	var strUID;
	strUID = document.getElementById('Module' + ModuleID + '_strLoginName' + ModuleID).value;

	var strPassword;
	strPassword = document.getElementById('Module' + ModuleID + '_strPassword').value;
	location.href = "Login.aspx?RedirectURL=" + CurrentPage + "&UID=" + strUID + "&PWD=" + strPassword;
	return false;
}


function HandleLogin(evt, ModuleID, CurrentPage)
{
	if (evt.keyCode == 13)
	{
	
		CallLogin(ModuleID, CurrentPage)
		
		if (!document.all && document.getElementById) {
			evt.preventDefault();
			evt.stopPropagation();
		}
		evt.cancelBubble = true;
		evt.returnValue = false;
		return false;

	}
}

function ReferFriendOpen(strURL, intArticleID)
{
	
	window.open('ReferAFriend.aspx?Article=' + intArticleID + '&' + strURL, 'Help', 'toolbar=no,width=580,height=380,resize=no, scrollbar=no');
}


