var vacation = ""; // "This Site is on Vacation till Nov 1";

function OnVacation()
{
	var s = "";
	s = '<div id="OnVacation" style="position:absolute; top: 140px; left: 0px;"><p class=text>' + vacation + '</p></div>';
	return s;
}

function OpenStone ( cat )
{
	if ( top.win ) {
		top.win.close();
	}

	top.win = null;

	top.win=window.open('Stone.asp?cat=' + cat + '&h=N' ,'myonestone',
  		'width=740,height=420'
   		+ ',menubar=0'
   		+ ',toolbar=0'
   		+ ',status=1'
   		+ ',scrollbars=0'
   		+ ',resizable=1');

 	top.win.focus();
}

function MakePayPalAddToCart ( pal )
{
if ( vacation != "" ) return vacation;
var s = ''
+ '<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">'
+ '<input type="hidden" name="cmd" value="_s-xclick">'
+ '<input type="hidden" name="hosted_button_id" value="' + pal + '">'
+ '<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">'
+ '<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">'
+ '</form>' ;
return s ;
}

function MakePayPalViewCart ()
{
if ( vacation != "" ) return vacation;
var s = ''
+ '<form name="_xclick" target="paypal" action="https://www.paypal.com/us/cgi-bin/webscr" method="post">'
+ '<input type="hidden" name="cmd" value="_cart">'
+ '<input type="hidden" name="business" value="' + MakeDestination () + '">'
+ '<input type="image" src="https://www.paypal.com/en_US/i/btn/view_cart_new.gif" border="0" name="submit" alt="Make payments with PayPal - it is fast, free and secure!">'
+ '<input type="hidden" name="display" value="1">'
+ '</form>' ;
return s ;
}

function MakeDestination()
{
	var s = "";
	var dot = ".";
	var et = "@";
	s += 'irenebatzvi';
	s += et;
	s += 'gmail';
	s += dot;
	s += 'com';
	return s;
}

function div ( left , top , contents , extraStyle ) {
	extraStyle = good ( extraStyle ) ;
	return '<div style="position:absolute; top:' + top + 'px; left:' + left + 'px; ' + extraStyle + '">' + contents + '</div>' ;
}

function MakeShoppingPanelText ()
{
	var s = ''
	+ 'Purchasing Stone Charms is easy. You can use any of major credit cards or PayPal.'
  + '<br><br>Just click on a stone image in a specific gallery and it will open a window'
  + ' containing a larger stone image with information about the stone.'
  + '<br><br>The window also contains an Add To Cart button that lets you add the stone to your shopping cart.'
  + '<br><br>You can come back to your shopping cart at any time and view its contents by clicking the View Cart button below.'
	;
	return s;
}

function MakeShippingLink ()
{
	var s = ''
	+ '<p class="text">'
	+ '<a class=navtextlink href="javascript:'
	+ 'var winshipping=window.open('
	+ "'Shipping.asp','myshipping','width=800,height=400,menubar=0,toolbar=0,status=0,scrollbars=0,resizable=1');winshipping.focus();"
	+ '">Shipping and Return Policy</a></p>' 
	;
	return s;
}

function addElement( divId , parentDivId , innerText ) {
	var maybe = document.getElementById(divId);
	if (maybe != null) return;
  var papa = document.getElementById(parentDivId);
  var newdiv = document.createElement('div');
  newdiv.setAttribute('id',divId);
  newdiv.innerHTML = '<div class="shoppingCartPanel">'
  + '<table width=300 cellpadding=5><tr><td align=right class=text><a class=navtext href=\'#\' onclick=\'removeElement("'+divId+'","'+parentDivId+'")\'>X</a></td></tr>'
  + '<tr><td><p class=text>' + innerText + '</p>'
  + '</td></tr><tr><td align=center>'
  + MakePayPalViewCart ()
  + MakeShippingLink ()
  + '</td></tr></table></div>'
  ;
  papa.appendChild(newdiv);
}

function removeElement(divId , parentDivId ) {
  var papa = document.getElementById(parentDivId);
  var olddiv = document.getElementById(divId);
  papa.removeChild(olddiv);
}

function OpenShoppingPanel ()
{
	addElement ( 'Stam' , 'Shopping' , MakeShoppingPanelText () ) ;
}

function OpenBottomShoppingPanel ()
{
	addElement ( 'BottomStam' , 'BottomShopping' , MakeShoppingPanelText () ) ;
}


function OpenUp(name, pal, cat, ahref, price, wid, hei, motif, story, sold)
{
	if ( top.win ) {
		top.win.close();
	}

	top.win = null;

	var oname = name.replace( /{APOS}/g , "'" );
	var omotif = motif.replace( /{APOS}/g , "'" );
	var ostory = story.replace( /{APOS}/g , "'" );

	top.win=window.open('','myonestone',
  		'width=740,height=420'
   		+ ',menubar=0'
   		+ ',toolbar=0'
   		+ ',status=1'
   		+ ',scrollbars=0'
   		+ ',resizable=1');

	var docRef = top.win.document.open("text/html","replace");

 	var s =	'<html><head><title>' + oname + '</title><LINK href="irene.css" rel="stylesheet" type="text/css">'
 			+ '<STYLE TYPE="text/css">body {margin: 0; padding: 0; background-color: #000000; }</STYLE>'
   		+ '</head><body bgcolor="#000000" >'
   		+ '<table width="740" height="420" border="1" cellspacing="10" cellpadding="0" bordercolor="white" bgcolor="#000000" '
   		+ '  align="center" valign="top" ><tr> '
   		+ '<td width="400" align="center"><img src="stones/' + ahref + '" width="400" height="400" ></td>'
   		+ '<td width="310" align="center"><p class="stonename">' + oname + '</p>'
   		+ '<p class="stoneinfo">Catalog Number: ' + cat 
   		+ '<br>Size in inches: ' + wid + ' x ' + hei ;
   		
  if ( price != "" && sold != "sold" ) { 		
  	s += '<br>Price: $' + price	+ '<span class="stonecomment">(includes shipping within USA)</span>' ;
  }
  
  s += '</p>'
   		+ '<p class="stoneinfo">Inspirational Motifs: ' + omotif + '</p>'
   		+ '<p class="stonestory">' +  ostory  + '</p>' ;
 	 	
 	top.win.document.writeln( s );
 	
 	var shop = FindElsewhere ( cat ) ;
 	
 	if ( shop != null ) {
 			top.win.document.writeln( '<p class="stoneinfo"><span style="font-size: 8pt;">Can be purchased at: ' + '</span><br>' ) ;
 			top.win.document.writeln( '<span style="color: red;">' + shop.shop + '</span><br>' ) ;
 			top.win.document.writeln( shop.phone + '<br>' ) ;
 			if ( shop.url != "" ) {
 				top.win.document.writeln('<a class=navtextlink href="javascript:var away=window.open(\'http://' + shop.url + '\');">' + shop.url + '</a>' ) ;
			}
 			top.win.document.writeln( '</p>' ) ;
 	
 	} else if ( sold == "sold" ) {
 			top.win.document.writeln( '<p class="sold">SOLD</p>' ) ;
 	} else if ( price == "" ) {
 			top.win.document.writeln( '<p class="sold">Not For Sale On This Site</p>' ) ;
 	} else if ( pal != "" && pal != 0 ) {
 			top.win.document.writeln('<p class="menubar">' + MakePayPalAddToCart ( pal ) + '</p>'	);
 	} else {
 			top.win.document.writeln(
   			'<p class="menubar">'
   			+ '<a class="nav" href="javascript:'
   			+ 'var winorder=window.open(\'ContactUs.asp?stonename='
   			+ name + "&stonecat=" + cat + "&stoneprice=" + price + "','order" + cat + "','width=800,height=560"
   			+ ",menubar=0,toolbar=0,status=0,scrollbars=0,resizable=1');winorder.focus();" 
   			+ '">Order By Email</a></p>'
 			);
 	}

  if ( shop == null && price != "" && sold != "sold" ) { 		
 		top.win.document.writeln( MakeShippingLink () );
  }
	
 	top.win.document.writeln('</td></tr></table>');
 	top.win.document.writeln('<div class="copyrightWhite" >Copyright &copy; 2008-2010 Irene Bat-Zvi. All rights reserved.</div>');
 	top.win.document.writeln('</body></html>');

 	top.win.document.close();
 	
 	top.win.focus();
}



function FirstRow()
{
	PrepareCatalog();
	document.write('<table width="100%" border="0" cellspacing="2" cellpadding="0" ');
	document.write('  align="center" valign="top" bgcolor="#000000"><tr> ');
}
function EndRows()
{
	document.write('</tr></table>');
}
function Row()
{
	document.write('</tr><tr>');
}

function GetCat ( ahref )
{
	var cat = "";
	if (String(ahref) != "undefined") {
		if (ahref.length > 4) {
			if (ahref.substr(3,1) == ' ' || ahref.substr(3,1) == '.') {
				cat = ahref.substr(0,3);
			} else if (ahref.substr(4,1) == ' ' || ahref.substr(4,1) == '.') {
				cat = ahref.substr(0,4);
			}
		}
	}
	return cat ;
}

function Stone(name, pal, ahref, price, wid, hei, motif, story)
{
	var cat = GetCat ( ahref ) ;
	var sold = "";
	if ( IsSold ( cat ) ) {
		sold = "sold";
	}
	var myRegExp = new RegExp("'","g"); 
	var iname = name.replace ( myRegExp , "{APOS}" ) ;
	var imotif = motif.replace ( myRegExp , "{APOS}" ) ;
	var istory = story.replace ( myRegExp , "{APOS}" ) ;

	document.write('<td height="225" valign="top"><p class="menubar"><a class="nav" width="200" href="javascript:OpenUp(');
	document.write("'" + iname + "', '" + pal + "', '" + cat + "', '" + ahref + "', '" + price + "', '" 
		+ wid + "', '" + hei + "', '" + imotif + "', '" + istory );
	document.write("', '" + sold );
	document.write("');" + '">');
	document.write('<img valign="top" src="stones/' + ahref + '" width="200" height="200" ><br>');
	document.write( name );
	if ( sold == "sold" ) {
		document.write( '<span class="sold">SOLD</span>' ) ;
	}
	document.write('</a></p></td>');
}

function NoStone ()
{
	document.write('<td><p>&nbsp;</p></td>');
}

function SideTable ( concatenatedStones )
{
	var s = '<br><br><table border="0" cellspacing="0" cellpadding="20" align="center" valign="center">' ;
	s += concatenatedStones ;
	s += '</table>' ;
	document.write( s ) ;
}

function SideStone ( ahref )
{
	var cat = GetCat ( ahref ) ;
	var s = '<tr><td><a class="nav" href="javascript:OpenStone(' + cat + ');">' ;
	s += '<img src="stones/' + ahref + '" width="200" height="200">' ;
	s += '</a></td></tr>' ;
	return s ;
}


