<!--//
var SizeOK=true;
var ColorOK=true;
var errMsg;

function SubmitForm() {
	var OKToSubmit=true;
	if (!SizeOK) {
		errMsg = "Please select a size!";
		OKToSubmit=false;
	}
	if (!ColorOK) {
		if (SizeOK) {
			errMsg = "Please select a color!";
		} else {
			errMsg = "Please select a size and color!";
		}
		OKToSubmit=false;
	}
	if (OKToSubmit) {
		return(true);
	} else {
		alert(errMsg);
		return(false);
	}
}

function WriteItemLink(itemID) {
	var itemDesc;
	if (dept[itemID]==1) {
		itemDesc = "<I>" + name[itemID] + "</I> " + deptName[dept[itemID]];
	} else {
		itemDesc = "\"" + name[itemID] + "\" " + deptName[dept[itemID]];
	}
	document.write('<A HREF="itemdetail.html?' + itemID + '"><IMG SRC="store/' + ID[itemID] + '_150.jpg" BORDER="1"><BR>' + itemDesc + '<BR><STRONG>$' + price[itemID] + '</STRONG></A>');
}

function WriteHeader() {
	var hImgSrc;

	if (dept[dID]==1) {
		hImgSrc="music";
	}
	else {
		hImgSrc="clothing";
	}
	document.write('<IMG SRC="images/h-' + hImgSrc + '.gif">');
}

function WriteImage() {
	document.write('<A HREF="Javascript:Zoom(' + dID + ');"><IMG SRC="store/' + ID[dID] + '_300.jpg" ALT="CLICK FOR LARGER IMAGE" BORDER="1"><BR><B>ZOOM +</B></A>');
}

function NewWindow(pageName,winName,w,h) {
  var winLeft = (screen.availWidth-w)/2;
  var winTop = (screen.availHeight-h)/2;
  var settings  = 'height=' + h + ',';
      settings += 'width=' + w + ',';
      settings += 'top=' + winTop + ',';
      settings += 'left=' + winLeft + ',';
      settings += 'scrollbars=auto,';
      settings += 'resizable=no,titlebar=no';
  win=window.open(pageName,winName,settings);  

  // Bring window into focus
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

function Zoom(zoomID) {
	var pageName = "zoom.html?" + ID[zoomID];
	var winName = "winXLFXitem" + zoomID;
	var w = 500; var h = 500;
	if (dept[zoomID]==1) { w = 500; h = 500; }
	if (dept[zoomID]==2) { w = 450; h = 490; }
	if (dept[zoomID]==3) { w = 358; h = 490; }
	if (dept[zoomID]==4) { w = 490; h = 515; }
	if (dept[zoomID]==5) { w = 470; h = 434; }
	if (dept[zoomID]==6) { w = 450; h = 490; }
	if (dept[zoomID]==7) { w = 450; h = 450; }
	w = w + 16; h = h + 18;
	
	NewWindow(pageName,winName,w,h);
}

function WriteDesc() {
	if (dept[dID]==1) {
		var numTracks = (tracks[dID].length - 1);
		document.write('<BR><SPAN CLASS="merchTitle"><I>' + name[dID] + '</I> ' + deptName[dept[dID]] + '</SPAN><BR>(');
		if (recordLabelURL[dID]) {
			document.write('<A HREF="'+ recordLabelURL[dID] + '" TARGET="_blank">' + recordLabel[dID] + '</A>');
		} else {
			document.write(recordLabel[dID]);
		}
		document.write(', released ' + releaseDate[dID] + ')<BR><BR>');
		WriteTracks(numTracks);
	} else {
		document.write('<BR><SPAN CLASS="merchTitle">"' + name[dID] + '" ' + deptName[dept[dID]] + '</SPAN><BR>');
	}
	document.write('<BR>' + desc[dID] + '<BR><BR><SPAN CLASS="merchPrice">$' + price[dID] + '</SPAN><BR><BR>');
	WriteCartForm();

}

function WriteCartForm() {
	var returnURL = "http://www.xlookingforwardx.com/new/index2.html?merchreturn";
	var itemName = name[dID] + " " + deptName[dept[dID]];

	document.write('<FORM TARGET="paypal" ACTION="https://www.paypal.com/cgi-bin/webscr" METHOD="post" NAME="frm' + number[dID] + '" ID="frm' + number[dID] + '" onSubmit="return(SubmitForm())">');
	document.write('	<INPUT TYPE="hidden" NAME="ID" VALUE="' + ID[dID] + '">');
	document.write('	<INPUT TYPE="hidden" NAME="cmd" VALUE="_cart">');
	document.write('	<INPUT TYPE="hidden" NAME="business" VALUE="orders@xlookingforwardx.com">');
	document.write('	<INPUT TYPE="hidden" NAME="item_name" VALUE="' + itemName + '">');
	document.write('	<INPUT TYPE="hidden" NAME="item_number" VALUE="' + number[dID] + '">');
	document.write('	<INPUT TYPE="hidden" NAME="amount" VALUE="' + price[dID] + '">');
	document.write('	<INPUT TYPE="hidden" NAME="no_note" VALUE="1">');
	document.write('	<INPUT TYPE="hidden" NAME="cs" VALUE="1">');
	document.write('	<INPUT TYPE="hidden" NAME="page_style" VALUE="primary">');
	document.write('	<INPUT NAME="return" TYPE="hidden" VALUE="' + returnURL + '">');

	// Begin color select
	if (colors[dID]) {	// write only if clothing
		ColorOK=false; var errMsg = "Please select a size and color!";
		document.write('	<INPUT NAME="on1" TYPE="hidden" VALUE="Color">');
		document.write('	<SPAN CLASS="merchSize">Available Colors:</SPAN>&nbsp;<SELECT NAME="os1" CLASS="merchInput" onChange="if(os1.selectedIndex==0) {ColorOK=false;} else {ColorOK=true;}">');
		document.write('	<OPTION VALUE="NONE SPECIFIED" SELECTED>(Please Select)</OPTION>');
		var colorID;
		for (idx = 0 ; idx < colors[dID].length ; idx++) {
			document.write('<OPTION VALUE="' + colors[dID][idx] + '">' + colors[dID][idx] + '</OPTION>');
		}
		document.write('	</SELECT><BR><BR>');
	}
	// End color select

	// Begin size select
	if (dept[dID] > 1) {	// write only if clothing
		SizeOK=false; var errMsg = "Please select a size!";
		document.write('	<INPUT NAME="on0" TYPE="hidden" VALUE="Size">');
		document.write('	<SPAN CLASS="merchSize">Available Sizes:</SPAN>&nbsp;<SELECT NAME="os0" CLASS="merchInput" onChange="if(os0.selectedIndex==0) {SizeOK=false;} else {SizeOK=true;}">');
		document.write('	<OPTION VALUE="NONE SPECIFIED" SELECTED>(Please Select)</OPTION>');
		var sizeID;
		for (idx = 0 ; idx < sizes[dID].length ; idx++) {
			sizeID = sizes[dID][idx];
			document.write('<OPTION VALUE="' + sizeShort[sizeID] + '">' + sizeLong[sizeID] + '</OPTION>');
		}
		document.write('	</SELECT><BR><BR>');
	}
	// End size select

	document.write('	<INPUT NAME="submit" TYPE="image" ID="submit" SRC="images/addtocart.gif" ALT="ADD TO CART" WIDTH="100" HEIGHT="24" BORDER="0">');
	document.write('	<INPUT TYPE="hidden" NAME="add" VALUE="1">');
	document.write('</FORM>');
	if (navigator.appName == "Netscape") {
			document.write('<BR>');
	}
}

function WriteTracks(numTracks) {
	document.write('<TABLE WIDTH="330" BORDER="0" CELLSPACING="0" CELLPADDING="4">');
	document.write('  <TR ALIGN="CENTER">');
	document.write('    <TD COLSPAN="2"><STRONG><U>TRACK LISTING</U>:</STRONG></TD>');
	document.write('  </TR>');
	document.write('  <TR ALIGN="CENTER" VALIGN="TOP">');
	document.write('    <TD WIDTH="50%">');
	document.write('1.&nbsp;&nbsp;' + tracks[dID][1]);
	for (idx = 2 ; idx <= numTracks/2 ; idx++) {
		document.write('<BR>' + idx + '.&nbsp;&nbsp;' + tracks[dID][idx]);
	}
	var resumeIdx = idx;
	document.write('    </TD><TD WIDTH="50%">');
	document.write(resumeIdx + '.&nbsp;&nbsp;' + tracks[dID][resumeIdx]);
	for (idx = resumeIdx+1 ; idx <= numTracks ; idx++) {
		document.write('<BR>' + idx + '.&nbsp;&nbsp;' + tracks[dID][idx]);
	}	
	document.write('    </TD>');
	document.write('  </TR>');
	document.write('  <TR ALIGN="CENTER">');
	document.write('     <TD COLSPAN="2"><A HREF="http://www.purevolume.com/xlookingforwardx" TARGET="_blank" CLASS="fineprint">Preview tracks from this album on PureVolume</A></TD></TR></TABLE>');	
}

//-->

