// /_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;
} 


function openStoriesFlash(host,state,curState,plate,dmnid){
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="970" height="510" id="crock_hp_flash" align="middle">');
document.write ('<param name="allowScriptAccess" value="sameDomain" />');
document.write ('<param name="movie" value="/flash/CC_storiesMap.swf?wsurl=' + host + '&dmnid=' + dmnid + '&curState=' + state + '&curStateName=' + curState + '&shareLink=' + plate + '" /><param name="quality" value="high" /><param name="bgcolor" value="#efe7d2" /><embed src="/flash/CC_storiesMap.swf?wsurl=' + host + '&dmnid=' + dmnid + '&curState=' + state + '&curStateName=' + curState + '&shareLink=' + plate + '" quality="high" bgcolor="#efe7d2" width="970" height="510" name="crock_hp_flash" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write ('</object>');    
}

function openRecipesFlash(host,dmnid){
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="970" height="510" id="crock_hp_flash" align="middle">');
document.write ('<param name="allowScriptAccess" value="sameDomain" />');
document.write ('<param name="movie" value="/flash/CC_shareMap.swf?wsurl=' + host + '&dmnid=' + dmnid + '" /><param name="quality" value="high" /><param name="bgcolor" value="#efe7d2" /><embed src="/flash/CC_shareMap.swf?wsurl=' + host + '&dmnid=' + dmnid + '" quality="high" bgcolor="#efe7d2" width="970" height="510" name="crock_hp_flash" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write ('</object>');    
}
    
function openPrintShare(recipeid)
{
	window.open('/RecipePrintShare.aspx?recipeid=' + recipeid,'print','scrollbars=yes,status=no,width=820,height=600')
}

function openPrintMRS(recipeid)
{
	window.open('/RecipePrintMRS.aspx?id=' + recipeid,'print','scrollbars=yes,status=no,width=820,height=600')
}

function openNascarFlash(){
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="780" height="574" id="CC_nascar" align="middle">');
document.write ('<param name="allowScriptAccess" value="sameDomain" />');
document.write ('<param name="movie" value="/flash/CC_nascar.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#eee4cb" /><embed src="/flash/CC_nascar.swf" quality="high" bgcolor="#eee4cb" width="780" height="574" name="CC_nascar" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write ('</object>');    
}

function openStateFairFlash(){
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="780" height="574" id="CC_nascar" align="middle">');
document.write ('<param name="allowScriptAccess" value="sameDomain" />');
document.write ('<param name="movie" value="/flash/CC_State_Fair.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#eee4cb" /><embed src="/flash/CC_State_Fair.swf" quality="high" bgcolor="#eee4cb" width="780" height="574" name="CC_State_Fair" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write ('</object>');    
}

function openDonatedFlash(host,color){
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="216" height="75" id="CC_donation_graph_sa" align="middle">');
document.write ('<param name="allowScriptAccess" value="sameDomain" />');
document.write ('<param name="movie" value="/flash/CC_donation_graph_sa.swf?wsurl=' + host + '" />');
document.write ('<param name="quality" value="high" />');
document.write ('<param name="bgcolor" value="' + color + '" />');
document.write ('<embed src="/flash/CC_donation_graph_sa.swf?wsurl=' + host + '" quality="high" bgcolor="' + color + '" width="216" height="75" name="CC_donation_graph_sa" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write ('</object>');
}

function openSNNVideos(dmnid){
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="722" height="396" id="CC_archive_videos" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="wmode" value="transparent"> <param name="movie" value="/flash/CC_archive_videos.swf?dmnid=' + dmnid + '" /><param name="quality" value="high" /><param name="bgcolor" value="#fbeabd" /><embed src="/flash/CC_archive_videos.swf?dmnid=' + dmnid + '" quality="high" wmode="transparent" bgcolor="#fbeabd" width="722" height="396" name="CC_archive_videos" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object>');    
}

function openRovingReporter(dmnid){
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="780" height="574" id="CC_roving_reporter" align="middle">');
document.write ('<param name="allowScriptAccess" value="sameDomain" />');
document.write ('<param name="movie" value="/flash/CC_roving_reporter.swf?dmnid=' + dmnid + '" /><param name="quality" value="high" /><param name="bgcolor" value="#FBF0D6" /><embed src="/flash/CC_roving_reporter.swf?dmnid=' + dmnid + '" quality="high" bgcolor="#FBF0D6" width="780" height="574" name="CC_roving_reporter" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write ('</object>');
}

function openJeanneVideos(dmnid){
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="722" height="396" id="CC_jeanne_benedict_archive" align="middle">');
document.write ('<param name="allowScriptAccess" value="sameDomain" />');
document.write ('<param name="movie" value="/flash/CC_jeanne_benedict_archive.swf?dmnid=' + dmnid + '" /><param name="wmode" value="transparent"><param name="quality" value="high" /><param name="bgcolor" value="#fbeabd" /><embed src="/flash/CC_jeanne_benedict_archive.swf?dmnid=' + dmnid + '" quality="high" wmode="transparent" bgcolor="#fbeabd" width="722" height="396" name="CC_jeanne_benedict_archive" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write ('</object>');
}

function openMenuVideo(video){
document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="230" height="190" id="CC_menu_jeanne" align="middle">');
document.write ('<param name="allowScriptAccess" value="sameDomain" />');
document.write ('<param name="movie" value="/flash/CC_menu_jeanne.swf?video=' + video + '" /><param name="wmode" value="transparent"><param name="quality" value="high" /><param name="bgcolor" value="#663333" /><embed src="/flash/CC_menu_jeanne.swf?video=' + video + '" quality="high" bgcolor="#663333" width="230" wmode="transparent" height="190" name="CC_menu_jeanne" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write ('</object>');
}