/* 
NotesOnCooking.com
Website by LaMa Media
Copyright (c) 2009 - All rights reserved
*/
// ****************************************************************
// For Pop Look button
// ****************************************************************
function load() {
var load = window.open('../content/look/1.html','','scrollbars=no,menubar=no,height=620,width=520,resizable=yes,toolbar=no,location=no,status=no');

}
// ****************************************************************
// GLOBALS
// ****************************************************************
/*global document, window, screen, navigator, clearTimeout, setTimeout, fBrowserDetect*/




var vPage,
	vPages = ['home', 'praise', 'events', 'bios', 'mediaroom', 'recommended', 'contact'],
	vPageNames = ['Home', 'Praise', 'Events', 'Bios', 'Media Room', 'Recommended', 'Contact'],
	vDepth = '',
	vDelim = '|';

if(!Array.indexOf) {
	Array.prototype.indexOf = function(obj) {
		for (var t = 0; t < this.length; t++) {
		if (this[t] == obj) {
                return t;
            }
        }
        return -1;
    };
}


// ****************************************************************
// UTILITIES
// ****************************************************************

function fOpacity(rID, rValue) { 
    var tStyle = document.getElementById(rID).style,
		tValue = (rValue / 100);
    tStyle.opacity = tValue; 
    tStyle.MozOpacity = tValue; 
    tStyle.KhtmlOpacity = tValue; 
    tStyle.filter = 'alpha(opacity=' + rValue + ')'; 
} 

function fEmailLink(rID, rName, rDomain, rDisplay) {
	var tAddress = rName + String.fromCharCode(64) + rDomain,
		tDisplay = (typeof(rDisplay) == 'undefined') ? tAddress : rDisplay,
		tLink = '<a href="mailto:' + tAddress + '">' + tDisplay + '</a>';
	
	document.getElementById(rID).innerHTML = tLink;
}


// ****************************************************************
// PAGES
// ****************************************************************

function fBrowserFixes() {
	if (fBrowserDetect.browser == 'Explorer') { 
		document.getElementById('nocbody').style.paddingBottom = '98px';
		document.getElementById('header').style.height = '99px';
	}
}


function fCommon() {

	var t, tPage, tName, tLink, 
		tCommon = '';

	tCommon += 
	'<div class="cheftop"><a href="../index.html"><img src="../media/procenium-new-gray.png" width="268" height="305" border="0"></a></div>' +
		'<table width="100%" border="0" cellpadding="0" cellspacing="0" id="fullwidth"><tr><td><div id="header">' +
		'<a id="addthis" href="http://www.addthis.com/bookmark.php?v=250" onmouseover="return addthis_open(this, \'\', \'[URL]\', \'[TITLE]\')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s7.addthis.com/static/btn/sm-share-en.gif" width="83" height="16" alt="Bookmark and Share" style="border:0"></a>' +
		'<a id="btn-rcr" class="navtop" href="http://rcrcreative.com"><span>RCR Creative Press</span></a>' +
		'<a id="btn-noc" class="navtop" href="http://www.notesoncooking.com/"><span>Notes on Cooking</span></a>' +
		'<a id="on-nod" class="navtop" href="../index.html"><span>Notes on Directing</span></a>' +
		'<a id="btn-nod1" class="navtop" href="http://notesonteaching.com"><span>Notes on Directing</span></a>' +
		'<div id="brickline"></div>';
	
	for (t = 0; t < vPages.length; t++) {
		tPage = vPages[t];
		tName = vPageNames[t];
		if (t == vPages.indexOf(vPage)) {
			tCommon += '<div id="on-' + tPage + '" class="navbar"><span>' + tName + '</span></div>';
		} else {
			if (tPage == 'home') { 
				tLink = vDepth + 'index'; 
			} else {
				tLink = tPage;
			}
			tCommon += '<a id="btn-' + tPage + '" class="navbar" href="' + tLink + '.html"><span>' + tName + '</span></a>';
		}
	}
	
	tCommon += 
		
		'</div></td></tr></table>' +
		'<div id="footer">' +
		'<table width="100%"  border="0" cellspacing="0" cellpadding="0">' +
		  '<tr valign="top">' +
		'<td><div class="foot-title-img"><img src="' + vDepth + 'media/title.gif" width="137" height="72" alt=""></div></td>' +
		'<td><table width="950" id="footable" cellpadding="0" cellspacing="0" border="0" align="center"><tr valign="middle" align="center">' +
		'<td width="16%">&nbsp;</td>'+
		
		//'<td><a id="btn-blog" class="navbot" href="http://notesoncooking.wordpress.com/" target="_blank"><span>Visit the Blog</span></a></td>' +
		'<td><a id="btn-article" class="navbot" href="javascript:fPopupArticle()"><span>Get Your Free Article</span></a></td>' +
		
		'<td><a id="btn-look" class="navbot" href="javascript:load()"><span>Take a Closer Look</span></a></td>' +
		'<td><a id="btn-book" class="navbot"  href="http://www.amazon.com/gp/product/0972425500/ref=as_li_ss_tl?ie=UTF8&tag=notesondirect-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=0972425500" target="_blank"></a><img src="http://www.assoc-amazon.com/e/ir?t=&l=as2&o=1&a=0972425500" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></td>' +
		'</tr></table>' +
		'</tr></table>' +
		'</div>' ;
			
	document.getElementById('common').innerHTML = tCommon;
}

function fPageStart(rPage, rDepth) {
	vPage = rPage;
	while (rDepth--) {
		vDepth+='../';
	}
}


function fPageEnd() {
	if (vPage != 'home') { fCommon(); }
	fBrowserFixes();
	document.getElementById('content').innerHTML += '<div id="content-bottom"></div>';
}


function fRightBlurb(rOver) {
	if (rOver) {
		document.getElementById('rightcover').style.display = 'none';
		document.getElementById('rightblurb').style.display = 'block';
	} else {
		document.getElementById('rightcover').style.display = 'block';
		document.getElementById('rightblurb').style.display = 'none';
	}
}


// ****************************************************************
// POPUP
// ****************************************************************

function fPopup(rFile, rPopW, rPopH, rTarget, rPopScroll, rPopRel, rPopLR, rPopTB, rLROff, rTBOff) {
	var tWinW, tWinH, tWinL, tWinT, tWinR, tWinB, tPopX, tPopY, tPopWin, tArgs,
		tFirefox = (fBrowserDetect.browser == 'Firefox' || fBrowserDetect.browser == 'Netscape') ? 1 : 0;
	
	if ((typeof(rTarget) == 'undefined') || (rTarget === 0)) { rTarget = 'popWin'; }
	if (typeof(rPopScroll) == 'undefined') { rPopScroll = '0'; }
	if (typeof(rPopRel) == 'undefined') { rPopRel = 'W'; }
	if (typeof(rPopLR) == 'undefined') { rPopLR = 'L'; }
	if (typeof(rPopTB) == 'undefined') { rPopTB = 'T'; }
	if (typeof(rLROff) == 'undefined') { rLROff = 0; }
	if (typeof(rTBOff) == 'undefined') { rTBOff = 0; }

	if (rPopRel == 'W' || rPopRel == 'w') {
		if (tFirefox) {
			tWinL = window.screenX;
			tWinT = window.screenY;
			tWinW = (window.outerWidth - 20);
			tWinH = (window.outerHeight - 55);
		} else {
			tWinL = window.screenLeft;
			if (rPopTB == "T" || rPopTB == "t") {
				tWinT = window.top.screenTop;
			} else {
				tWinT = window.screenTop;
			}
			tWinW = (document.body.clientWidth - 10);
			tWinH = (document.body.clientHeight - 30);
		}
	} else {
		tWinL = 0;
		tWinT = 0;
		if (tFirefox) {
			tWinW = (screen.width - 10);
			tWinH = (screen.height - 0);
		} else {
			tWinW = (screen.width - 10);
			tWinH = (screen.height - 50);
		}
	}
	tWinR = (tWinL + tWinW);
	tWinB = (tWinT + tWinH);
	
	if (rPopLR == 'L' || rPopLR == 'l') {
		tPopX = tWinL;
	} else if (rPopLR == 'R' || rPopLR == 'r') {
		tPopX = (tWinR - rPopW);
	} else { // (rPopLR == 'C') 
		tPopX = (tWinL + ((tWinW / 2) - (rPopW / 2)));
	}
	if (rPopTB == 'T' || rPopTB == 't') {
		tPopY = tWinT;
	} else if (rPopTB == 'B' || rPopTB == 'b') {
		tPopY = (tWinB - rPopH);
	} else { // (rPopTB == 'C') 
		tPopY = (tWinT + ((tWinH / 2) - (rPopH / 2)));
	}
	tPopX = (tPopX + rLROff);
	tPopY = (tPopY + rTBOff);
	if (tFirefox) {
		tArgs = 'width=' + rPopW + ',height=' + rPopH + ',screenX=' + tPopX + ',screenY=' + tPopY + ',resizable=0,scrollbars=' + rPopScroll + ',menubar=0';
	} else {
		tArgs = 'width=' + rPopW + ',height=' + rPopH + ',left=' + tPopX + ',top=' + tPopY + ',resizable=0,scrollbars=1,menubar=0';
	}
	tPopWin = window.open(rFile, rTarget, tArgs);
	tPopWin.focus();
}


function fPopupPage(rPage) {
	if (vDepth === '') { 
		rPage = 'content/' + rPage;
	}
	fPopup(rPage + '.html', 400, 612);
}

function fPopupArticle() { fPopupPage('pop_article');}
function fPopupLook() { fPopupPage('looking');}
function fPopupBook() { fPopupPage('pop_book');}
function fPopupRelease() { fPopupPage('release');}
function fPopupPublishers() { fPopupPage('publishers');}
function fPopupWsj() { fPopupPage('wsj');}
function fPopupNicola() { fPopupPage('nicola');}
function fPopupDramatics() { fPopupPage('dramatics');}
function fPopupDramabookshop() { fPopupPage('dramabookshop');}
function fPopupaact() { fPopupPage('aact');}
function fPopupOntario() { fPopupPage('ontario');}
function fPopuptt() { fPopupPage('tt');}
function fPopupChoice() { fPopupPage('Choice');}
function fPopupAmertheater() { fPopupPage('AmerTheatre');}
function fPopupUkweb() { fPopupPage('ukweb');}
function fPopupBackstage() { fPopupPage('backstage');}
function fPopupLibraryjournal() { fPopupPage('libraryjournal');}
function fPopupTheatremania() { fPopupPage('theatremania');}
function fPopupAmertheatreweb() { fPopupPage('Amertheaterweb');}
function fPopupDeadtrees() { fPopupPage('deadtrees');}
function fPopupdirvswriter() { fPopupPage('dirvswriter');}


// ****************************************************************
// BROWSER DETECT
// http://www.quirksmode.org/js/detect.html
// ****************************************************************

var fBrowserDetect={init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS";},searchString:function(data){for(var i=0;i<data.length;i++){var dataString=data[i].string;var dataProp=data[i].prop;this.versionSearchString=data[i].versionSearch||data[i].identity;if(dataString){if(dataString.indexOf(data[i].subString)!=-1){return data[i].identity;}}else if(dataProp){return data[i].identity;}}},searchVersion:function(dataString){var index=dataString.indexOf(this.versionSearchString);if(index==-1){return;}return parseFloat(dataString.substring(index+this.versionSearchString.length+1));},dataBrowser:[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.userAgent,subString:"iPhone",identity:"iPhone/iPod"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};

fBrowserDetect.init();
/*------------------from page two---------------------------------*/

//var vColumns = 4;
var vLooks = new Array("Front Cover","Contents 1","Contents 2","Contents 3","Contents 4","Contents 5","Contents 6","Contents 7","Preface 1","Preface 2","Preface 3","Preface 4","Preface 5","Intro 1","Intro 2","Intro 3","Intro 4","The Script 1","The Script 2","The Script 3","The Script 4","The Script 5","The Script 6");
var vMaxLooks = (vLooks.length - 1);
var vLookNum = 0;//"00";
var vLookName = vLooks[0];//"";
var vLookWin;
function fLook(rNum, rName) {
	vLookNum = rNum;
	vLookName = rName;
	vLookWin = window.open('looking.html', 'nodLook', 'resizable=1, menubar=0, scrollbars=1, width=600, height=500');
	//vLookWin.focus();
}
function fLookNum(rPrevNext) {
	var tNum, tName;
	var tNum = (parseInt(vLookNum) + rPrevNext);
	if (tNum < 0) {
		tNum = vMaxLooks;
	} else if (tNum > vMaxLooks) {
		tNum = 0;
	}
	tName = vLooks[tNum];
	fLook(tNum, tName);
}
function fLookClose() {
	if (typeof(vLookWin) == 'object') {
		vLookWin.close();
	}
}

/*-----contents from page twp ends------*/

