function launch(newURL, newName, newFeatures)
{
	var remote = open(newURL, newName, newFeatures);
	return remote;
}


function popuplaunch(theURL,theNAME,theWIDTH,theHEIGHT,theTYPE) {
if (theTYPE=='flexi')
	{
	Remote = launch(theURL, theNAME, "height="+theHEIGHT+",width="+theWIDTH+",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0,title=0");
	}
else
	{
	Remote = launch(theURL, theNAME, "height="+theHEIGHT+",width="+theWIDTH+",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0,title=0");
	}
}

//note: used only for popups that use the photo frame as it auto-adds the extra needed for the frame
//      max height of photos/interior should be 558px (for IE8 on a 768 tall screen)
function popuplaunchpic(theURL,theNAME,theWIDTH,theHEIGHT,theTYPE)
{
	theWIDTH=theWIDTH+50;
	theHEIGHT=theHEIGHT+58;

	if (theTYPE=='flexi')
	{
		Remote = launch(theURL, theNAME, "height="+theHEIGHT+",width="+theWIDTH+",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=yes,scrollbars=yes,status=0,toolbar=0,title=0");
	}
	else
	{
		Remote = launch(theURL, theNAME, "height="+theHEIGHT+",width="+theWIDTH+",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0,title=0");
	}
}

//note folioid has a limit here, need to increase if more stamps created for page
function loadfolio()
{
	if (location.search)
	{
		var ary=window.location.search.substr(1).split("&");

		for (i=0;i<ary.length;i++)
		{
			ary[i]=ary[i].split("=");
		}
		var qStr=new Array();
		for (i=0;i<ary.length;i++)
		{
			ary[i][0]=ary[i][0].replace(/\+/g," ");
			ary[i][0]=unescape(ary[i][0]);
			ary[i][1]=ary[i][1].replace(/\+/g," ");
			ary[i][1]=unescape(ary[i][1]);
			qStr[ary[i][0]]=ary[i][1];
		}
		var folioid = qStr["folioid"];
		if(folioid>=27)
		{
		 folioid=0;
		}
		folioswap('stamp'+folioid);
	}
}

function folioswap(theid)
{
	document.getElementById('stamp0').className='item off';
	document.getElementById('stamp1').className='item off';
	document.getElementById('stamp2').className='item off';
	document.getElementById('stamp3').className='item off';
	document.getElementById('stamp4').className='item off';
	document.getElementById('stamp5').className='item off';
	document.getElementById('stamp6').className='item off';
	document.getElementById('stamp7').className='item off';
	document.getElementById('stamp8').className='item off';
	document.getElementById('stamp9').className='item off';
	document.getElementById('stamp10').className='item off';
	document.getElementById('stamp11').className='item off';
	document.getElementById('stamp12').className='item off';
	document.getElementById('stamp13').className='item off';
	document.getElementById('stamp14').className='item off';
	document.getElementById('stamp15').className='item off';

// if higher than 13, swap to stamp set 2
// else go to stamp set 1


	document.getElementById(theid).className='item on';
}


function preload()
{
	if (top!=self)
		{top.location=self.location; }
	document.getElementById('preload').innerHTML = document.getElementById('preload').innerHTML+' <img src="images/upsize_back-open.jpg" width="1" height="1" border="0" alt="" /> <img src="images/upsize_back-shut.jpg" width="1" height="1" border="0" alt="" /> <img src="images/upsize_back-portfolio.jpg" width="1" height="1" border="0" alt="" /> <img src="images/portfolio/stamps.jpg" width="1" height="1" border="0" alt="" /> <img src="images/upsize_back-staff.jpg" width="1" height="1" border="0" alt="" /> <img src="images/upsize_back-info-top.jpg" width="1" height="1" border="0" alt="" /> <img src="images/upsize_back-info-bot.jpg" width="1" height="1" border="0" alt="" /> <img src="images/upsize_back-services.jpg" width="1" height="1" border="0" alt="" /> <img src="images/services/envelope-stack-0-home.jpg" width="1" height="1" border="0" alt="" /> <img src="images/services/envelope-stack-1-websites.jpg" width="1" height="1" border="0" alt="" /> <img src="images/services/envelope-stack-2-unmail.jpg" width="1" height="1" border="0" alt="" /> <img src="images/services/envelope-stack-3-logos.jpg" width="1" height="1" border="0" alt="" /> <img src="images/services/envelope-stack-4-print.jpg" width="1" height="1" border="0" alt="" /> <img src="images/services/envelope-stack-5-seo.jpg" width="1" height="1" border="0" alt="" /> <img src="images/services/envelope-stack-6-ecommerce.jpg" width="1" height="1" border="0" alt="" />';
}

function popuploader()
{
	var whatpic = location.search ? unescape(location.search.substring(1)) : 'someimagehere';
	document.getElementById('thepic').innerHTML='<a href="#" onclick="self.window.close();"><img src="'+whatpic+'" border="0" alt="close window"></a>';
}

function staffpic(whatstaff,whatyear)
{
	if (whatstaff=='jstilts')
	{
		if (whatyear==2004)
		{
			var whatpic='images/blank.gif';
			var nextyear=2009;
		}
		if (whatyear==2009)
		{
			var whatpic='images/staff/jonathan-2009.jpg';
			var nextyear=2004;
		}
		document.getElementById('jspic').innerHTML='<div id="jspic"><img src="'+whatpic+'" width="176" height="162" border="0" alt="Jonathan Stilts" id="jspic" usemap="#jstilts" /><map name="jstilts"><area shape="poly" coords="132,0,175,105,175,108,46,161,42,161,0,54,0,52,131,0" href="#" onclick="staffpic(\'jstilts\','+nextyear+');return false;" alt=""><area shape="poly" coords="159,0,160,4,175,4,175,0" href="services.html" alt="Service"></map></div>';
	}
	if (whatstaff=='edavo')
	{
		if (whatyear==2004)
		{
			var whatpic='images/blank.gif';
			var nextyear=2009;
		}
		if (whatyear==2009)
		{
			var whatpic='images/staff/emma-2009.jpg';
			var nextyear=2004;
		}
		document.getElementById('edpic').innerHTML='<div id="edpic"><img src="'+whatpic+'" width="147" height="121" border="0" alt="Emma Davidson" id="edpic" usemap="#edavo" /><map name="edavo"><area shape="poly" coords="0,6,140,0,146,113,145,115,21,120,5,120,0,13" href="#" onclick="staffpic(\'edavo\','+nextyear+');return false;" alt=""></map></div>';
	}
}

function divswap(whatdiv,whatstate)
{
	document.getElementById(whatdiv).style.display=whatstate;
}


function classswap(whatdiv,whatclass)
{
	document.getElementById(whatdiv).className=whatclass;
}

function picswap(whaturl,whatid)
{
	document.getElementById(whatid).innerHTML='<img src="'+whaturl+'" border="0" alt="" />';
}

//note used to determine if a page has been accessed internally or not (parameter passed via JS on links)
function internalcheck1()
{
	var thesource='';

	if (location.search)
	{
		thesource = location.search ? unescape(location.search.substring(1)) : 'someValueHere';
	}

	return(thesource);
}

//note used to determine if a page is within an iframe or not
function internalcheck2()
{
	var thesource='internal';

	if (top == window)
	{
		thesource='external';
	}

	return(thesource);
}

//note used for personal portfolio pages only
function setpagepport()
{
	var thesource = internalcheck1();
	if (thesource != '')
	{
		divswap('workfull','none');divswap('portfull','block');document.getElementById('scroll1').scrollTop=0;
		document.getElementById('portfolioiframe').src=thesource;
		divswap('portfolioiframe','block');
	}
}

//note used for personal portfolio ITEM pages only
function setpagepport2()
{
	var thesource = internalcheck2();
	if (thesource == 'external')
	{
		var whatpage=self.location;
		self.location='index.html?'+whatpage;
	}
}

function copywriteyear()
{
	var theDate=new Date()
	var todaysyear=theDate.getFullYear();
	document.getElementById('copywriteyear').innerHTML = todaysyear;
}
