// These values are used by JavaScript that lives in the RNT answer copy.
var isKMobileDomain = document.location.hostname.indexOf("kmobile") > -1;
var isOfotoDomain = document.location.hostname.indexOf("ofoto")>-1;

/**
 * Simple Search Form validation.  Checks to see that "terms" is not null.
 * If terms is not null, this function just submits the form.
 */
function searchFormSubmit(sMessage) {
      if (document.rightnow.terms.value == "" || document.rightnow.terms.value == null) {
            alert(sMessage);
            document.rightnow.terms.focus();
        } else {        	                     
			 document.forms['rightnow'].submit(); 
        }
} 

function searchFormSubmit(sMessage, action) {
       document.rightnow.action = "";    	                     
       if (document.rightnow.terms.value == "" || document.rightnow.terms.value == null) {
            alert(sMessage);
            document.rightnow.terms.focus();
        } else { 
        	document.rightnow.action = action;   
        	ContextualHelpLinkRNT(document.rightnow.action+"&terms="+document.rightnow.terms.value);
       		return false;                                    
        }
} 
function ContextualHelpPopup(popupAnswerURL, windowHeight, windowWidth, toolbar) {

        var height    = "425";
        var width     = "390";

        if (windowHeight) {
                height = windowHeight;
        }
        if (windowWidth) {
                width = windowWidth;
        }

        var left      = Math.floor( (screen.width - width) / 2);
        var top      = Math.floor( (screen.height - height) / 2);

        // If the window contains a toolbar, subtract 50 from location of the
        // top of the window to accomodate the size of the toolbar, so that
        // the window will still be centered in the screen.

        if (toolbar) {
                top = top - 50;
        }

        var winParams = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width + ",scrollbars,resizable";
        if (toolbar) {
                winParams = winParams + ",toolbar";
        }
        msgWindow     = window.open('','targetname',winParams);
        
        msgWindow.location.href = popupAnswerURL;
        
        if (msgWindow.opener == null) msgWindow.opener = self;

} 
function ContextualHelpPopupRNT(popupAnswerURL, windowHeight, windowWidth, toolbar) {

        var height    = "486";
        var width     = "578";

        if (windowHeight) {
                height = windowHeight;
        }
        if (windowWidth) {
                width = windowWidth;
        }

        var left      = Math.floor( (screen.width - width) / 2);
        var top      = Math.floor( (screen.height - height) / 2);

        // If the window contains a toolbar, subtract 50 from location of the
        // top of the window to accomodate the size of the toolbar, so that
        // the window will still be centered in the screen.

        if (toolbar) {
                top = top - 50;
        }

        var winParams = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width + ",scrollbars,resizable";
        if (toolbar) {
                winParams = winParams + ",toolbar";
        }
        msgWindow     = window.open('','targetname',winParams);
        
        msgWindow.location.href = popupAnswerURL;
        if (msgWindow.opener == null) msgWindow.opener = self;

} 
function ContextualHelpLinkRNT(popupAnswerURL, windowHeight, windowWidth, toolbar) {
        var height    = "600";
        var width     = "800";

        if (windowHeight) {
                height = windowHeight;
        }
        if (windowWidth) {
                width = windowWidth;
        }

        var left      = Math.floor( (screen.width - width) / 2);
        var top      = Math.floor( (screen.height - height) / 2);

        // If the window contains a toolbar, subtract 50 from location of the
        // top of the window to accomodate the size of the toolbar, so that
        // the window will still be centered in the screen.

        if (toolbar) {
                top = top - 50;
        }

        var winParams = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width + ",scrollbars,resizable";
        if (toolbar) {
                winParams = winParams + ",toolbar";
        }
        msgWindow     = window.open('','targetname',winParams);
        
        msgWindow.location.href = popupAnswerURL;        
        if (msgWindow.opener == null) msgWindow.opener = self;

} 


function GalleryLinksPopup(popupAnswerURL, windowHeight, windowWidth, toolbar) {

        var height    = "500";
        var width     = "500";

        if (windowHeight) {
                height = windowHeight;
        }
        if (windowWidth) {
                width = windowWidth;
        }

        var left      = Math.floor( (screen.width - width) / 2);
        var top      = Math.floor( (screen.height - height) / 2);

        // If the window contains a toolbar, subtract 50 from location of the
        // top of the window to accomodate the size of the toolbar, so that
        // the window will still be centered in the screen.

        if (toolbar) {
                top = top - 50;
        }

        var winParams = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width + ",scrollbars,resizable";
        if (toolbar) {
                winParams = winParams + ",toolbar";
        }
        msgWindow     = window.open('','targetname',winParams);
        
        msgWindow.location.href = popupAnswerURL;
        if (msgWindow.opener == null) msgWindow.opener = self;

} 

/**
        
        Note that RNT answers may be displayed in HelpAnswer.jsp
        or in HelpAnswerPopup.jsp.  Links from HelpAnswerPopup.jsp should
        load content in the parent ofoto.com window, and leave the popup
        open.  Links from HelpAnswer.jsp should just reload in the same
        window.
        
        Creates an URL with a query
        string that contains the "ofotoaddtoken".  This is
        to maintain session state for non-cookied users.

        The first argument to linkToOFoto is the href.
        The second argument may be a string of params, or an anchor.
        The third argument is assumed to always be an anchor.
        
*/

function OpenCenteredWindow(url, windowHeight, windowWidth) {

        var height    = "425";
        var width     = "390";

        if (windowHeight) {
                height = windowHeight;
        }
        if (windowWidth) {
                width = windowWidth;
        }

        var left      = Math.floor( (screen.width - width) / 2);
        var top       = Math.floor( (screen.height - height) / 2);
        var winParams = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width + ",scrollbars,resizable";
        msgWindow     = window.open('','targetname',winParams);
        
        msgWindow.location.href = url;
        
        if (msgWindow.opener == null) 
                msgWindow.opener = self;

        return false;
        
} 	


 

