var isW3C = (document.getElementById) ? true : false;
var isAll = (document.all) ? true : false;
var isOperaMac = (navigator.userAgent.indexOf('Opera') != -1 && navigator.platform.indexOf('MacPPC') != -1 ) ? true : false;
var HSCALE=0.9;
var VSCALE=0.9;
var urlAddress = "http://www.prescription-europe.com/";
var pageName = "Prescription-Europe.com";

function addToFavorites()
{
 if (window.external)
 {window.external.AddFavorite(urlAddress,pageName)}
 else{alert("Sorry! Your browser doesn't support this function.");}
}

function centeredPopup(url, name, noChrome, width, height)
{
	var features;
	var popupDimensions=defaultPopupDims();
	
	//availheight and width mostly for Opera interoperability 
	var myAvailWidth=getAvailWidth();
	var myAvailHeight=getAvailHeight();

	if( url )
	{
		//handle calls using the old Mplus popup window javascript
		if(url=="#")
		{
			url='';
		}
		
		if(!name)
		{
			name="TheNewWin";
		}

		//ensure width bounds checking, if it doesn't have a value, give it the default
		if( isNaN(width) )
		{
	  	width=popupDimensions.width;
		}

		if(width > myAvailWidth || width < 0)
		{
			width=parseInt(myAvailWidth * HSCALE);
		}
		
		//check whether this will be a chromeless window 
		if( noChrome == true 
		|| noChrome == "true" 
		|| noChrome == "True" 
		)
		{
			features='toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' + width + ',';
		}
		else
		{
			features='toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' + width+ ',';
		}
		
		//if height wasn't defined get default
		//note: default height for IE will be 0, IE doesn't give us sufficient info
		//to calculate parent window dimensions
		if(!height)
		{
			height=popupDimensions.height;
		}

		//check the height attrib, ensure it doesn't exceed viewable real estate
		//if so, the reduce it to VSCALE set by script designer.
		if(height > myAvailHeight || height < 1)
		{
			height=parseInt(myAvailHeight * VSCALE -100)
		}
		else
		{
			if( isOperaMac )
			{
				height=parseInt(myAvailHeight *VSCALE);
			}
		}

		features+='height='+height+',';
		features += getCenteredCoords(myAvailWidth,myAvailHeight,width,height);
		
		popUpWin = window.open(url, name, features);

		if( window.focus && !isOperaMac)
		{
			popUpWin.focus();
		}
		return false;
	}
	return true;
}		

//workaround for Opera in MDI mode, must calc the "real" availWidth.
function getAvailWidth()
{
	var myWidth=screen.availWidth;
	
	if(self.screenX && self.screenLeft && (self.screenX != self.screenLeft) )
	{
		myWidth = myWidth - self.screenLeft + self.screenX;		
	}
	
	return myWidth;
}

function getAvailHeight()
{
	var myHeight=screen.availHeight;
	
	if(self.screenY && self.screenTop && (self.screenY != self.screenTop) )
	{
		myHeight = myHeight - (self.screenTop - self.screenY);		
	}
	return myHeight;
}

function getCenteredCoords(myAvailWidth, myAvailHeight, width, height)
{
	var coords="";
	var top, left;

	if(width)
	{
		left=parseInt(.5 * (myAvailWidth - width) );
		if(left < 0)
			left=0;
		coords+='left='+left+',screenX='+left;
		
		//calculate the centered position for height only if we have a value for it
		if(height)
		{
		
			top=parseInt(0.5* (myAvailHeight - height) );
			if(top < 0)
				top=0;
			coords += ',top='+top+',screenY='+top;
		}

		return coords;
	}
	return;	
}

function defaultPopupDims()
{
	//first set an absolute fallback value, in case the object sniffing breaks due to weird
	//browsers
	var dims = new Object();
	dims.width = 580;
	dims.height = 400;

	//work out the width and height of Netscape 4.x, Mozilla, & Opera 7.x Browser 
	if( !isNaN( window.innerWidth)  && window.innerWidth > 0  ) 
	{
			//Non-IE browsers e.g. Netscape, Opera, Safari, etc.
			dims.width = parseInt(window.innerWidth * HSCALE);
			dims.height = parseInt(window.innerHeight * VSCALE);
	}
	else
	{
		if( document.documentElement && document.documentElement.offsetWidth )
		{
			//IE 6+, and any IE Compatible Browsers that supports the documentElement properties
			dims.width = parseInt(document.documentElement.offsetWidth * HSCALE);
			dims.height = parseInt(document.documentElement.offsetHeight * VSCALE);
		}
		else
		{
			if( document.body && document.body.offsetWidth)
			{
				//IE 4 and above compatible
				dims.width = parseInt(document.body.offsetWidth * HSCALE);
				dims.height = parseInt(document.body.offsetHeight * VSCALE);
			}
		}
	}
	return dims;
}


//these functions are deprecated, they are here to ensure nothing breaks during the transition
//after all instances have been removed in the code, they will be removed.

function openNakedWin(windowName) 
{
	centeredPopup('#', windowName, true);
	return true;
}

//end deprecated functions

image1 = new Image(); image2 = new Image(); image3 = new Image(); image4 = new Image(); image5 = new Image(); image6 = new Image(); image7 = new Image();

