// /_scripts/global.js
window.onerror = onError;

var w3c = (document.getElementById) ? 1:0
var ns4 = (document.layers) ? 1:0
var ie4 = (document.all) ? 1:0
var pc	= (navigator.platform.indexOf('Win') == 0) ? 1:0;
var mac	= (navigator.platform.indexOf('Mac') == 0) ? 1:0;

//===============================================================================================================================================================
//=     FUNCTION:       onError() 
//=     PARAMETERS:     sMessage as string is the error reason 
//=						sUrl as string is the URL that raised the error 
//=						sLine is the line number of the error 
//=     RETURNS:        integer 
//=     PURPOSE:        All javascript errors are directed to this funciton by window.error 
//=						The true return value supresses any browser javascript errors. 
//=     AUTHOR:         Steve Jansen, Byte Interactive <stj@byteinteractive.com> 
//=     DATE:           Decmeber 11th, 2000 
//===============================================================================================================================================================
function onError(sMessage, sURL, sLine) 
{ 
        var sPrompt; 
        sPrompt = "________________________________________________________\n\n" 
        sPrompt += "A client-side javascript error has occured.\n" 
        sPrompt += "________________________________________________________\n\n" 
        sPrompt += "Line:\t" + sLine + "\n" 
        sPrompt += "Reason:\t" + sMessage + "\n" 
        sPrompt += "URL:\t" + sURL + "\n" 
                
                
        //test to see if this is the development site 
      	if (location.href.indexOf('byteinteractive.com') > 0) 
                window.alert(sPrompt); 
                
        return true; 
 } 

//===============================================================================================================================================================
//=	FUNCTION: 	onLoad()
//=	PARAMETERS:	none
//=	RETURNS:	true
//=	PURPOSE:	Event handler for onload of all pages
//=	AUTHOR:		Steve Jansen, Byte Interactive <stj@byteinteractive.com>
//=	DATE:		November 29th, 2000
//===============================================================================================================================================================
function onLoad()
{ 
	cacheImages();	//function to cache all rollover images
	//window.status = 'Welcome To ';
	return true;
}

//===============================================================================================================================================================
//=	FUNCTION: 	onResize()
//=	PARAMETERS:	none
//=	RETURNS:	true
//=	PURPOSE:	Event handler for resize of all pages in IE4+
//=	AUTHOR:		Steve Jansen, Byte Interactive <stj@byteinteractive.com>
//=	DATE:		November 29th, 2000
//===============================================================================================================================================================
function onResize()
{ 
	if (w3c)
		location.reload();
	return;
}

//===============================================================================================================================================================
//=	FUNCTION: 	cacheImages()
//=	PARAMETERS:	none
//=	RETURNS:	null
//=	PURPOSE:	Used for JavaScript rollovers.  This function preloads (caches) all "on" state images.
//=				Call this function from the body onload event.
//=	AUTHOR:		Steve Jansen, Byte Interactive <stj@byteinteractive.com>
//=	DATE:		November 30th, 2000
//===============================================================================================================================================================
function cacheImages()
{
	var i;
	
	var oImages = new Array(document.images.length);			//array of image objects
	//reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/\_off\.(gif|jpg)/) > 0 )
		{	
			oImages[i] = new Image();
			oImages[i].src = document.images[i].src.replace("_off.", "_on.");
		}
	}
	return;
}

//===============================================================================================================================================================
//=	FUNCTION: 	setImage()
//=	PARAMETERS:	oImage (Image Object)
//=	RETURNS:	null
//=	PURPOSE:	Used for JavaScript rollovers.  This function changes the src of oImage to the "on" state
//=	AUTHOR:		Steve Jansen, Byte Interactive <stj@byteinteractive.com>
//=	DATE:		November 30th, 2000
//===============================================================================================================================================================
function setImage(oImage)
{
	var i;

	//first reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/\_on\.(gif|jpg)/) )
			document.images[i].src.replace("_on.", "_off.");
	}
	
	//now set the image to be in the "on" state		
	oImage.src = oImage.src.replace("_off.", "_on.");
				
	return;
}

//===============================================================================================================================================================
//=	FUNCTION: 	clearImages()
//=	PARAMETERS:	oImage (Image Object)
//=	RETURNS:	null
//=	PURPOSE:	Used for JavaScript rollovers.  This function resets all images to their "off" state upon the mouseout event
//=	AUTHOR:		Steve Jansen, Byte Interactive <stj@byteinteractive.com>
//=	DATE:		November 30th, 2000
//===============================================================================================================================================================
function clearImages()
{
	var i;
	
	//reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/\_on\.(gif|jpg)/) > 0 )
			document.images[i].src = document.images[i].src.replace("_on.", "_off.");
	}
	return;
}

//===============================================================================================================================================================
//=	FUNCTION: 	openWindow()
//=	PARAMETERS:	url, name, w, h, rs, scr, cen
//=	RETURNS:	null
//=	PURPOSE:	Used for opening a new window with set properties
//=	AUTHOR:		David Alperovich, Byte Interactive <dalperovich@byteinteractive.com>
//= UPDATED:	David Whalen, Byte Interactive <david.whalen@byteinteractive.com>
//=	DATE:		December 11, 2001
//===============================================================================================================================================================
function openWindow(url, name, width, height, resize, scroll, center)
{
	var sParams = '';
	name = (name == null) ? '' : name;

	sParams += 'width=' + width;
	sParams += ',height=' + height;
	sParams += (resize || resize == 'true') ? ',resizable=yes' : ',resizable=no';
	sParams += (scroll || scroll == 'true') ? ',scrollbars=yes' : ',scrollbars=no';
	sParams += (center || center == 'true') ? ',left=' + ((screen.width - width) / 2) : '';
	sParams += (center || center == 'true') ? ',top=' + ((screen.height - height) / 2) : '';

	window.name = 'opener';
	var popupWin = window.open(url, name, sParams);
	popupWin.focus();
	return;
}

//===============================================================================================================================================================
//  FUNCTION:   getDHTMLObj
//  ARGUMENTS:  theStr - String to decode
//  PURPOSE:    Return a DHTML object, based on browser version
//  RETURNS:    Object
//  AUTHOR:     David Whalen <dw@byteinteractive.com>
//  DATE:       October 25, 2001
//===============================================================================================================================================================
function getDHTMLObj(objName)
{
	if (document.getElementById)
		return document.getElementById(objName);
	else if (document.all)
		return document.all[objName];
	else if (document.layers)
		return document.layers[objName];
	else
		return null;
} 

//Popup New Window with Large Image
function popWin (sImage) {	
		var ImageName = sImage.src;
		var NewImage = ImageName.split("/");
				
		newWin = open('ImagePop.aspx?id=popup_' + NewImage[NewImage.length - 1], 'pop', 'width=460,height=330,toolbar=no,status=no,scrollbars=scrollbars,directories=no,location=no,resizable=no,menubar=no');
		
		newWin.focus();
}

function openPrivacy()
{
	window.open('http://www.coty.com/terms_sweep.html','privacy','scrollbars=yes,status=no,width=790,height=400')
}