﻿ /***************************************************************************************************
  * Purpose:   Common JavaScript source file for IT Hotline
  * 
  * Author:    Michel Humair
  * Copyright: IT Hotline, 2010
  * Date:      23/06/2010
  * Last edit: 04/07/2010 
  *
  * function openWindow(strUrl,intWinWidth,intWinHeight)
  *   Purpose: open a new window for external link
  *   Parameters: strUrl        = Url to open
  *               intWinWidth   = Window width of Window to open if 0 default size windows is opened
  *               intWinHeight  = Window height of Window to open
  *
  * function redirect()	
  *   Purpose: redirect to old site to login (login has not yet been moved to new site)
  *
  * function checkOpenUrl(strPageLink, strLinkText)
  *   Purpose: do not reload the page if the page is already open but highlight the link text
  *            on the page instead
  *   Parameters: strPageLink   = the page to link to
  *               strLinkText   = the link text of the link clicked 
  ***************************************************************************************************
 */ 

// open a new window for external link 
function openWindow(strUrl,intWinWidth,intWinHeight) 
{
	// use default full size window
	if (intWinWidth == 0) {
		intWinWidth = screen.width - 10 
		intWinHeight = screen.height - 75 
	}		
	newWin = window.open(strUrl,"info","resizable=yes,scrollbars=yes,width=" + intWinWidth  + ",height=" + intWinHeight + ",top=0,left=0")  		
	newWin.focus() // to enable replay if already opened	
} 
// redirect to old site to login
function redirect()	
{
  alert("You are redirected to our old site to login, sorry!");
  openWindow("default.asp", 0, 0);
}
// do not reload the page if hte page is laready open but highlight the link text
// on the page instead 
function checkOpenUrl(strPageLink, strLinkText)
{
  var strBackColor = "#fecf33"
  // get current open page name - if we have a match don't reload
  if ((window.location.pathname.indexOf(strPageLink)) != -1)
  {
    // reset background of all header elements in content div 
    switch (strPageLink)
    {
      case "webDesign.htm":
        document.getElementById("web-design").style.backgroundColor = ""; 
        document.getElementById("software").style.backgroundColor = ""; 
        document.getElementById("db-design").style.backgroundColor = "";
        document.getElementById("payment-gateway").style.backgroundColor = "";   
        break; 
      case "bookkeeping_services.htm":
        document.getElementById("payables").style.backgroundColor = ""; 
        document.getElementById("bank-rec").style.backgroundColor = ""; 
        document.getElementById("gst").style.backgroundColor = "";
        document.getElementById("payroll").style.backgroundColor = "";  
        document.getElementById("backup").style.backgroundColor = ""; 
        document.getElementById("after-hours").style.backgroundColor = ""; 
        document.getElementById("setup").style.backgroundColor = "";
        document.getElementById("partner").style.backgroundColor = "";  
        break;   
    }
    // highlight text in current page for the link text passed
    document.getElementById(strLinkText).style.backgroundColor = strBackColor;    
    return false; //stop page re-load
  }
  else
    return true; //link to page in link clicked   
}
