
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var s;
var searchstr = location.search;
if (searchstr.indexOf("s=") != -1) {
	s = searchstr.slice(searchstr.lastIndexOf("s=") + 2);
	s = Number(s.substr(0, s.indexOf("&")));
} else {
	s = 1;
}
f = s + 9;

footer = '<table width="600" border="0" cellspacing="0" cellpadding="0" align="center">' +
	'  <tr valign="top">' +
	'    <td align="center"><font color="#0000ff" size="-2" face="Arial, Helvetica, sans-serif"><font size="2">More new Scenes coming soon.<br><a href="mailto:requests@irishpicturecompany.com">CLICK HERE to join our No Obligations Request List.</a><br>Email us so you can be notified when new Scenes are available.</font><br><br></font><font color="#902C00" face="Arial, Helvetica, sans-serif" size="1"><b>©</b> Our gallery list of titles is added to and changes on a regular basis to provide a more comprehensive collection.<br>Please feel free to visit regularly to discover beautiful new works, depicting majestic landscapes from all around Ireland.</font></td>' +
	'  </tr>' +
	'</table>' +
	'<p>&nbsp;</p>';

function ShowBasketFixed() {
	index = document.cookie.indexOf("IPDBasket");
	countbegin = (document.cookie.indexOf("=", index) + 1);
	countend = document.cookie.indexOf(";", index);
	if (countend == -1) {countend = document.cookie.length;}
	fulllist = document.cookie.substring(countbegin, countend);
	totprice = 0;
	basket_header = '<table width="634" border="0" cellspacing="0" cellpadding="0">' +
		'<tr bordercolor="#FFFFFF" valign="top">' +
		'	<td>' +
		'        	<table border="1" cellspacing="0" cellpadding="2" bordercolor="#FE0009" width="90">' +
		'			<tr>' +
		'				<td bgcolor="#FFFF00" align="center"><font color="#FF0100" face="Arial, Helvetica, sans-serif" size="-1"><a href="javascript:history.back()">RETURN TO<br><b>CART</b></a></font><font color="#FF0100"></font></td>' +
		'			</tr>' +
		'		</table>' +
		'	</td>' +
		'	<td>&nbsp;&nbsp;&nbsp;</td>' +
		'	<td>' +
		'		<table width="550" border="1" cellspacing="0" cellpadding="4" bordercolor="#FFFFFF">' +
		'			<tr valign="top">' +
		'				<td background="images/tbl_top.gif">&nbsp;</td>' +
		'				<td background="images/tbl_top.gif"><p><font face="Arial, Helvetica, sans-serif" size="-2">&nbsp;</font><font face="Arial, Helvetica, sans-serif" size="-1"><br><b>Product Description<br></b></font></p></td>' +
		'				<td background="images/tbl_top.gif" align="center"><p><font face="Arial, Helvetica, sans-serif" size="-2">&nbsp;</font><font face="Arial, Helvetica, sans-serif" size="-1"><br><b>Quantity</b></font></p></td>' +
		'				<td background="images/tbl_top.gif" align="center"><p><font face="Arial, Helvetica, sans-serif" size="-2">US Dollar</font><font face="Arial, Helvetica, sans-serif" size="-1"><br><b>Cost</b></font></p></td>' +
		'			</tr>';
		document.writeln(basket_header);

	itemlist = 0;
	quanttotal = 0;
	for (var i = 0; i <= fulllist.length; i++) {
		if (fulllist.substring(i,i+1) == '[') {
			itemstart = i+1;
		} else if (fulllist.substring(i,i+1) == ']') {
			itemend = i;
			thequantity = fulllist.substring(itemstart, itemend);
			quanttotal = quanttotal + parseInt(thequantity);
			itemtotal = 0;
			itemtotal = (eval(theprice*thequantity));
			temptotal = itemtotal * 100;
			totprice = totprice + itemtotal;
			itemlist=itemlist+1;

			basket_contents = '<tr valign="top">' +
				'	<td background="images/tbl_bottom.gif" align="center" valign="middle"><p>&nbsp;</p></td>' +
				'	<td background="images/tbl_bottom.gif" valign="middle"><p><input type="hidden" name="Item '+itemlist+'" value="'+theitem+'"><font face="Arial, Helvetica, sans-serif" size="-1" color="#000000">'+theitem+'</font></p></td>' +
				'	<td background="images/tbl_bottom.gif" align="center" valign="middle"><p><input type=hidden name="quant'+itemlist+'" value="'+thequantity+'"><font face="Arial, Helvetica, sans-serif" size="-1" color="#000000">'+thequantity+'</font></p></td>' +
				'	<td background="images/tbl_bottom.gif" align="center" valign="middle"><p><font face="Arial, Helvetica, sans-serif" size="-1" color="#000000">'+top.bottom.FormatPrice(top.bottom.alterError(itemtotal))+'</font></p></td>' +
				'</tr>';

			document.write(basket_contents);
		} else if (fulllist.substring(i,i+1) == ',') {
			theitem = fulllist.substring(itemstart, i);
			itemstart = i+1;
		} else if (fulllist.substring(i,i+1) == '#') {
			theprice = fulllist.substring(itemstart, i);
			itemstart = i+1;
		}
	}

	if (!totprice) document.write('<tr valign="top"><td background="images/tbl_bottom.gif" colspan="5"><font face="Arial, Helvetica, sans-serif" size="-1" color="#000000">Your basket is empty.</font></td></tr>');

	MultipleOf3 = (quanttotal-(quanttotal%3))/3;
	if (MultipleOf3 > 0) {
		Discount = MultipleOf3 * top.bottom.PicPrice;
		totprice = totprice - Discount;
		Discount = (Discount/100) / (top.bottom.PicPrice/100);
		document.writeln('<tr><td colspan=4 align=right><font color="#C70000"><b>Special Offer: You\'ve got ' + Discount + ' FREE!</b></font></td></tr>');
	}

	basket_footer = '			<tr valign="top">' +
		'				<td background="images/tbl_bottom.gif">&nbsp;</td>' +
		'				<td background="images/tbl_bottom.gif">&nbsp;</td>' +
		'				<td background="images/tbl_bottom.gif" align="center" valign="middle"><font face="Arial, Helvetica, sans-serif" size="-1" color="#FF0100"><b>TOTAL</b><br><font size="-2">US Dollars</font></font></td>' +
		'				<td background="images/tbl_bottom.gif" align="center" valign="middle"><font face="Arial, Helvetica, sans-serif" size="-1" color="#FF0100"><b><input type="hidden" name="Total" value="'+(totprice/100)+'">'+top.bottom.FormatPrice(top.bottom.alterError(totprice))+'</b></font></td>' +
		'			</tr>' +
		'		</table>' +
		'	</td>' +
		'</tr>' +
		'</table>';

	document.write(basket_footer);
}

function currencyExchange(a,s,t) {
	window.open("http://quote.yahoo.com/m5?a=" + a + "&s=" + s + "&t=" + t,'CurrencyConvert','fullscreen=no');
}

function openWindowPic(url) {
	window.open(url,"","width=446,height=338,scrollbars")
}

function checkFrameset() {
	// check if we are on www.irishphotographydirect.com
	if (window.location.hostname.indexOf("irishphotographydirect.com") == -1) {
	//	top.location.href= "http://www.irishphotographydirect.com";
	}

	// check to see if we are in frameset
	if (!top.frames.length) {
		// if not, go to welcome page, and pass this page as a param
		strLocation = "welcome.php?" + location.pathname;
		strSearch = new String(location.search);
		if (strSearch != "") strLocation += strSearch;
		location.href = strLocation;
	}
}

