var imgPost = new Image();
var baseURL = "http://www.qcomet.com/";
var baseImages = "http://www.qcomet.com/pics/";	
var urlsHelp = "http://www.qcomet.com/help/slidehelp.html";
var urlsNews = "http://www.qcomet.com/help/qnew.html";
var nobar = "<meta http-equiv='imagetoolbar' content='no' /> ";


var home1 = "<P ALIGN=Center><A HREF='" + baseURL + "'>";
var home2 = "<IMG SRC='" + baseImages + "homebutt.gif' ALT='Home' BORDER='0' WIDTH='120' HEIGHT='80'></A>";
var cDark = "#000066";
var cLight = "#99ccff"
var cTableBG = " bgcolor=FloralWhite";
var cCaptionBG = " bgcolor=PowderBlue";
var cRowBG = " bgcolor=#DDDDDD";
var fCaption = " class='buttonText14'";
var fButton = " class='buttonText'";
var fRegText = " class='regBlueText'";
var fdText = " class='dText'";
var fSmallText = " class='copyText'";
var style = "<LINK REL=stylesheet TYPE='text/css' HREF='" + baseURL + "scripts/photos.css'>"
var shops = '<SCRIPT LANGUAGE=JAVASCRIPT src="http://www.qcomet.com/scripts/shops.js"></SCRIPT>'
var data = '<SCRIPT LANGUAGE=JAVASCRIPT src="qlist.js"></SCRIPT>'

var createdby = "<P ALIGN=Center><IMG SRC='" + baseImages + "createdby.gif' ALT='Created by BillP Studios' BORDER='0' WIDTH='75' HEIGHT='64'><BR>"
var copyFont = "<P ALIGN=Center "+fSmallText+">";
var copyWrite = "Copyright © 1999-2005 BillP Studios.<BR>All Rights Reserved.<BR>"

var m1 = "<P align=center><TABLE align='center' cellpadding='0' cellspacing='0'>";
var m2 = "<TR><TD colspan='7'><HR color='#000066'><TD></TR>";
var m3 = "<TR class='copyText'>";
var m4 = "<TD width='180' align='center'><A href='javascript:showNews()'>[QComet News]</A></TD>";
var m5 = "<TD width='180' align='center'><A href='http://www.winpatrol.com'>[WinPatrol.com]</A></TD>";
var m6 = "<TD width='180' align='center'><A href='http://www.qcomet.com/qstore.html'><b>[QComet Store]</b></A></TD>";
var m7 = "</TR></TABLE>";

var tabtop = "<TABLE align=center border=3  rules=none cellpadding=0 cellspacing=0 bordercolor=DeepSkyBlue ";
var table1 = "<TABLE align=center border=4  rules=none cellpadding=4 cellspacing=0 bordercolor=DeepSkyBlue ";
var table2 = "bordercolordark="+cDark+" bordercolorlight="+cLight+"  >";
var tab1 = "<TABLE align=center border=4  rules=cols cellpadding=0 cellspacing=0 bordercolor=DeepSkyBlue ";
var tab2 = "bordercolordark="+cDark+" bordercolorlight="+cLight+" >";

var row1 = "<TR "+cCaptionBG+"><TD align=center colspan=2>";
var row1s = "<TR><TD align=center colspan=2>";
var rowb1 = "<TR "+cRowBG+"><TD  align=center colspan=2><BR>";
var rowc1 = "<TR "+fCaption+"><TD  align=center  colspan=2 "+cCaptionBG+">";
var row2 = "<TD "+cTableBG+" align=center  colspan=1>";
var endRow = "</TD></TR>"
var endbRow = "<BR></TD></TR>"


function isAOL(){ return  navigator.userAgent.indexOf("AOL") != -1; }


function slideShow()
{
var i= getCurrentPicture();
var slide=i+1;

//count = 0;


//document.title = "QComet Slide: " + caption[i];

document.open();
document.write("<HTML><HEAD><TITLE>"+title+"</TITLE>"+nobar+style+shops+data+"</HEAD>");
//document.write("<BODY  leftmargin=60 marginheight=10  BACKGROUND='" + baseImages + "qcpback.gif'>");
document.write("<BODY  bgColor='white' marginwidth=20 topmargin=0 >");		


renderMenu(1);
renderControls( i );


document.write(table1+table2);
if( caption[i].length > 0)
{
	document.write(rowc1);
	document.write("<TABLE align=center border=0><TR class='buttonText14'><TD>" +  FormattedText( caption[i], 32 )+"</TD></TR></TABLE>");
	document.write(endRow);
}

document.write(row1s);
document.write("<TABLE align=center border='0' rules=none cellpadding='0' cellspacing=0>");

// if Netscape we could do it the old way
// and use this stuff otherwise use the new slides method.
if(navigator.appName == "Microsoft Internet Explorer" )
{
	document.write("<TR><TD colspan=3>");
	document.write("<img border=0 src='http://www.qcomet.com/pics/frametop.jpg' >");
	document.write("</TD></TR>");
	document.write("<TR><TD colspan=1>");
	document.write("<img border=0 src='http://www.qcomet.com/pics/frameleft.jpg' >");
	document.write("</TD>");
	document.write("<TD colspan=1>");
	document.write("<a href='javascript:updateSlideShow(1)'>");
	document.write("<img name='idPicture' border=0 src='" + picture[i] + "' " + 'alt="' + caption[i] + '"' +  " onLoad='javascript:CheckSize()'></A>");
	document.write("</TD>");
	document.write("<TD colspan=1>");
	document.write("<img name='idRight' border=0 src='http://www.qcomet.com/pics/frameright.jpg'  >");
	document.write("</TD></TR>");
	document.write("<TR><TD colspan=1>");
	document.write("<img name='idLeft' border=0 src='http://www.qcomet.com/pics/frameleft.jpg' >");
	document.write("</TD>");
	document.write("<TD colspan=1>");
	document.write("<img name='idBottom' border=0 src='http://www.qcomet.com/pics/framebottom.jpg' >");
	document.write("</TD>");
	document.write("<TD colspan=1>");
	document.write("<img border=0 src='http://www.qcomet.com/pics/framecorner.jpg' >");
	document.write("</TD></TR>");
}
else
{
	document.write("<a href='javascript:updateSlideShow(1)'>");
	document.write("<img name='idPicture' border=0 src='" + picture[i] + "' " + 'alt="' + caption[i] + '"' +  " onLoad='javascript:CheckSize()'></A>");
}


if(typeof(dtext[i]) != "undefined")
{
	if( dtext[i].length > 0)
	{
		document.write("<TR class='regBlueText'><TD colspan=1></TD>");
		document.write("<TD align=left colspan=1 >");
		document.write("<TABLE align=center border=0><TR><TD class='regBlueText'>" + FormattedText( dtext[i], 48 )+"</TD></TR></TABLE>");
		document.write("</TD>" );
		
		document.write("<TD></TD></TR>");
	}
}

if( typeof(jslink) != "undefined")
{
	if(typeof(jslinktext) != "undefined")
	{
		if( jslink.length > 0)
		{
			document.write("<TR class='buttonText'><TD colspan=1></TD>");
			document.write("<TD align=center colspan=1 >");
			document.write("<TABLE align=center border=0><TR><TD class='buttonText'>");
			document.write("<A target='null' href='" + jslink + "'><u>" + jslinktext + "</u></A>");
			document.write("</TD></TR></TABLE>");
			document.write("</TD>" );
			document.write("<TD></TD></TR>");
		}
	}
}

document.write("</TABLE>");
document.write(endRow);
document.write("</TABLE>");


// TEST
if(!isAOL() && (navigator.appName != "Netscape" ))
{
	document.write("<TABLE align=center><TR class='buttonText'><TD>");
	document.write("<A HREF='mailto:?subject=A QComet Photo from your friend.");
	document.write("&Body=I thought you would like this photo from QComet.com  " );
	document.write("%0D%0DSlide Show Title: " + title + "  " );
	document.write("%0DSlide caption: " + caption[i] + "  ");
	document.write("%0DClick on or Go to " +  window.parent.location.href + "'>");
	document.write("<u>Click here to Email this page to a friend</u></A>");
	document.write("</TD></TR></TABLE>");
}

// Amazon
//	document.write("<TABLE width=320 align=center><TD><br>");	
//	document.write( RandomOffer() );	
//	document.write("</TD></TR></TABLE>");

	document.write('<center>');
	document.write('<form action="http://www.google.com/cse" id="cse-search-box" target="_blank">');
	document.write("<font color='#000066'><br><B><I>Enter Text to Search for More Photos</I></B></font><div>");
	document.write('<input type="hidden" name="cx" value="partner-pub-5216032068438142:rh1oly-3e3q" ID="Hidden1" />');
	document.write('<input type="hidden" name="ie" value="ISO-8859-1" ID="Hidden2" /> <input type="text" name="q" size="42" ID="Text1" />');
	document.write('<br><input type="submit" name="sa" value=" Search " ID="Submit1" /></div></form>');
	document.write('<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=en"></script>');
	document.write('</center>');





if( typeof(copyright)!= "undefined")
{
	if(copyright != "")	// use copyright from user
		copyWrite = copyright;
}



document.write(m1+m2+m3+m4+m5+m6+m7);



document.write("</BODY></HTML>");
document.close();
}

function updateSlideShow(direction)
{
var h = parent.location.href;
var nr = h.split("?");
var page = getCurrentPicture();
var size=picture.length;
var p;

	if(direction == 0)
		page = page - 1
	else
		page = page + 1;
	
	if(page < 0) page = 0;
	//if(page == size) page = size-1;
	if(page == size) page = 0;

	p = "?"+page;
	window.parent.location.href = nr[0]+p;
}


function getCurrentPicture()
{
var h = parent.location.href;
var nr = h.split("?");
var page;

	if(( typeof(nr[1])== "undefined") )
		page = 0;
	else
		page=nr[1]-0;
	return page;
}

function showHelp()
{
	window.open( urlsHelp, 'PopHelp', 'resizable=1,height=360,width=480,scrollbars=1,toolbar=no,status=0');
}

function showNews()
{
	window.open( urlsNews, 'QCometNews', 'resizable=1,height=360,width=480,scrollbars=1,toolbar=no,status=0');
}


function FormattedText(sText, linesize)
{
var myOutput = "";
var myLine = "";
var myWord = "";
var newInput = "";
var	temp1 = "";

//	if(navigator.appName.indexOf("WebTV") != -1) // WebTV
//	{
			temp1 = sText;
//	}
//	else
//	{
//		temp0 = sText.replace(/<br>/gi,"<BR>");
//		temp1 = temp0.replace(/&#013&#010/gi,"<BR>");
//	}
		
    newInput = temp1.split( "<BR>");
	for(i=0; i < newInput.length; i++)
	{
		newParagraph = newInput[i];	

		//	-------------  Each line
		newLine = newParagraph.split("<");
		newSegment = newLine[0];
		
		for(j=1; j < newLine.length+1; j++)
		{
				//	----------------------------------  each word
				myWord = newSegment.split(" ");
				for(k=0; k < myWord.length; k++)	// number of elements in word array
				{
					temp = myLine + myWord[k];
					if( temp.length > linesize )
					{
						myOutput = myOutput + myLine + "<BR>";
						myLine = myWord[k] + " ";
					}
					else
					{
						myLine = myLine + myWord[k] + " ";
					}
				}  //--------------------------------------- end of each word	
			if(j < newLine.length)
			{
				temp = newLine[j].split(">");
				newSegment = temp[1];
				html = "<" + temp[0] + ">";
				myLine = myLine + html;
			}
		}	// ------------------------  end of each line

		myOutput = myOutput + myLine + "<BR>";
		myLine = "";
		
	} //-------- End of check for <BR>'s
	
	myOutput = myOutput + myLine;
	
	return myOutput;
}


function addComment( slide)
{
	var im = picture[slide];
	var f = im.split(".");
	url = "http://www.qcomet.com/addcomment.html?" + album + "=" + f[0];
	p = window.open( url, '', 'resizable=1,height=360,width=480,scrollbars=0,toolbar=no,status=0');
}

function readComments( slide)
{
	var im = picture[slide];
	var f = im.split(".");
	url = "http://www.qcomet.com/showcomment.html?" + album + "=" + f[0];
	p = window.open( url, '', 'resizable=1,height=360,width=480,scrollbars=0,toolbar=no,status=0');
}


function DoLink(slide)
{
	x = screen.availWidth;
	x = x - x/6;
	y = screen.availHeight;
	y = y - y/4;
	

	if(typeof(link[slide]) != "undefined")
	{
		if(link[slide] == "undefined")
			return;
		url = link[slide];

		if(url.length > 0)
		{
			//location.href = url;
			window.open( url, '', 'resizable=1,height=' + y + ',width=' + x + ',scrollbars=1,toolbar=yes,status=0');
		}
	}
	return;
}


function CheckSize()
{	// If new images are added to this code we must change the number found here.

	//if(navigator.appName == "Netscape" ) return;
	if(navigator.appName == "Microsoft Internet Explorer" )
	{
		h = document.images['idPicture'].height;
		w = document.images['idPicture'].width;
		x = screen.availWidth;
		x = x - x/4;
	
		if(w > x)
		{
			w1 = x;
			h1 = (h * w1/w);
			document.images['idPicture'].width = w1;
			document.images['idPicture'].height = h1;
		}

		h = document.images['idPicture'].height;
		w = document.images['idPicture'].width;
		document.images['idRight'].height = h;
		document.images['idRight'].width = 10;
		document.images['idLeft'].width = 10;
		document.images['idLeft'].height = 10;
		document.images['idBottom'].width = w;
		document.images['idBottom'].height = 10;
	}
}


function renderControls( i )
{
var href0 = "<A class='copyText' HREF=javascript:updateSlideShow(0)";
var href1 = "<A class='copyText' HREF=javascript:updateSlideShow(1)";
var himgLast = "<img id='idLast' src='" + baseImages + "last.jpg' border='0'";
var himgNext = "<img id='idNext' src='" + baseImages + "next.jpg' border='0'";
var blankHREF = "<A name='nolast' class='copyText'><img src='" + baseImages + "blank.jpg' alt='No selection available' border='0'>";
var lastHREF;
var nextHREF;
var pic = i+1

document.write(tabtop+tab2);
//document.write("<TR "+cTableBG+">");
if(pic > 1)
{
	lastOver = " ONMOUSEOVER=\"idLast.src='http://www.qcomet.com/pics/last0.jpg'; return true;\" ";
	lastOut =  " ONMOUSEOUT=\"idLast.src='http://www.qcomet.com/pics/last.jpg'; return true;\"> ";
	lastHREF = href0 + lastOver + lastOut + himgLast + 'alt="' + caption[i-1] + '"><BR>LAST</A>';
	document.write("<TR>"+row2+lastHREF+"</TD>");
}
else
	document.write("<TR>"+row2+blankHREF+"<BR>&#149</A></TD>");


document.write("<TD align=center colspan=3 class='buttonText14'"+cTableBG+"> "+ FormattedText( title, 32 ) );
document.write("<br><span align=center class='copyText'>Picture " + pic + " of "+ picture.length+"</span></TD>");


if(pic < picture.length)
{
	nextOver = " ONMOUSEOVER=\"idNext.src='http://www.qcomet.com/pics/next0.jpg'; return true;\" ";
	nextOut =  " ONMOUSEOUT=\"idNext.src='http://www.qcomet.com/pics/next.jpg'; return true;\"> ";
	nextHREF = href1 + nextOver + nextOut + himgNext + 'alt="' + caption[i+1] + '"><BR>NEXT</A>';
	document.write(row2+nextHREF+"</TD>");
}
else
	document.write(row2+blankHREF+"<BR>&#149</A></TD>");
	
document.write("</TR>");
document.write("</TABLE>");

}