/***********************************************************************************************
* Author:  Dave Bettin (david@accutechsolutions.net)
*
* Date: Apr 16, 1999
*
* Name:    vypcommon.js
*
* Purpose: Common JavaScript functions used across the 
*		   video yellow pages site.
*
* Usage:   <script language="javascript" type="text/javascript" src="#js#/vypcommon.js">
*		   </script>
*
* Notes:
*
* Modification Log:
*	!!! 
*		PLEASE NOTE YOUR CHANGES ON THE MODIFICATION LOG.
*		This will enable us to keep track of fixes and/or enhancements to the code.
*		Also it will also help us troubleshoot errors when they suddenly arise out of the blue.
*	!!!
*	  Date	       Author		  			 Change
*	==========	=============	====================================
*  990605      SRM            Trying to center window in wopen - horiz not working
*
************************************************************************************************/

/***************************************************************************
*
* Purpose: Netscape fix When Netscape resizes it destroys positioned elements
*          Therefore we must reload the page on a resize
*
****************************************************************************/
netscapeCssFixCheckIn()
/***************************************************************************
* Name: netscapeCssFix()
*
* Input: None
*
* Output: None
*
* Purpose: Determines if netscape needs to be reloded
*
****************************************************************************/
function netscapeCssFix() {
  if (document.bugFix.netscapeCssFix.initWindowWidth != window.innerWidth || document.bugFix.netscapeCssFix.initWindowHeight != window.innerHeight) {
    document.location.reload();
  }
}

/***************************************************************************
* Name: netscapeCssFixCheckIn()
*
* Input:  None
*
* Output: None
*
* Purpose: Captures the resize event in Netscape and creates a new object that 
*		   holds al the correct info
*
****************************************************************************/
function netscapeCssFixCheckIn() {
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.bugFix == 'undefined'){
      document.bugFix = new Object;
    }
    if (typeof document.bugFix.scaleFont == 'undefined') {
      document.bugFix.netscapeCssFix = new Object;
      document.bugFix.netscapeCssFix.initWindowWidth = window.innerWidth;
      document.bugFix.netscapeCssFix.initWindowHeight = window.innerHeight;
    }
    window.onresize = netscapeCssFix;
  }
}

/***************************************************************************
* Name: wopen()
*
* Input:  url - Source destination, width - Width of window
*		  height - Height of Window
*
* Output: None
*
* Purpose: Opens an pop up window
*
****************************************************************************/
function wopen(url, width, height)
{
	// const vyp features for every pop up window
	var vypfeat = "scrollbars=yes,resizable=yes,";
	
	// Populate a random name so if user pops up another window it will not reference the same name
	var name = Math.floor(Math.random() * 10000);
	
	// Make sure screen positions in middle of browser window
   var xPos = (screen.width / 2) - (width/2);
   var yPos = (screen.height / 2) - (height/2);

	if (document.layers)
	{
		var pgLeft = "screenX=" + xPos + ",";
		var pgTop = "screenY=" + yPos + ",";
	}
	else
	{
		var pgLeft = "left=" + xPos + ",";
		var pgTop = "top=" + yPos + ",";
	}
	
	// Add width and height features to new window
	var features =  "'menubar,"  + pgLeft + pgTop +  vypfeat + "width=" + width + "," + "height=" + height +  "'";  
   self.name="opener";
	window.open(url, name, features);
}

/***************************************************************************
* Name: produceUrl()
*
* Input: imgName
*
* Output: none
*
* Purpose: produces a query string based on current buscity and then pops it up
*			 in a new window
***************************************************************************/
function produceUrl(imgName)
{
	var url = "searchmap.cfm?img=" + escape(imgName);
	wopen(url, 285, 390);
}

