/**
 * This Quickview javascript references the following HTML which is placed on the page directly wherever this js is used. This is the 'shell' html of the quickview popup window
 * It must be on the page before quickview.js is included
 * Also note that extra code is needed to include the quickview icon on the page
 * 
 * <!-- begin feature: quickview -->
 * <iframe id="qv_iframe"  src="assets/images/blank.html"></iframe>
 * <div id="qv_window">
 * 	<a id="closebtn" href="javascript:void(0)" onclick="closeProd(this);">close [x]</a>
 * 	<br/>
 * 	<div id="qv_error" class="ErrorMsg"></div>
 * 	<div id="qv_action"></div>
 * </div>
  * <script type="text/javascript" language="javascript" src="assets/images/includes/quickview.js"></script>
 * <!-- end feature: quickview -->
 *
 * IMPORTANT NOTE:  BE SURE TO CREATE A BLANK HTML PAGE AND PLACE IT IN ASSETS/IMAGES (name it blank.html).  THIS FILE IS USED IN THE IFRAME TO AVOID ERRORS IN IE.
 * 
 * GRAPHICS NEEDED: You will need a quickview icon (qvicon.gif) and possibly a close button and a details button.
 *
 * INCLUDE THE FOLLOWING AFTER EACH PRODUCT THUMBNAIL TO GET ICON ON EACH PRODUCT TO LAUNCH QV POPUP ON CLICK 
 *<!-- Quick View icon -->
 *<script language="javascript" type="text/javascript">draw_search_qv(PF_ID_HERE);</script>
 *<!-- /Quick View icon -->
 * 
 * ADD TO THE PRODUCT THUMBNAILS IMAGE TO DISPLAY QV ICON ON HOVER, then call the draw_search_qv() function
 * onmouseover="popQVIcon('qvicon_PF_ID_HERE');"
 * onmouseout="hideQVIcon('qvicon_PF_ID_HERE');"
 * draw_search_qv(PF_ID_HERE); 
 * 
 * FUNCTIONS TO CUSTOMIZE:
 * - showProd (this is the function that lays out the look of the QV popup)
 * - getProdInfo (you'll need to add the site's stem name here)
 * - draw_sku_option_qv (this is the function that draws out the product options select - this should be customized to be what customer has on product page)
 * - shareproduct (this formats the share with a friend email - should be what the customer uses on product page. - this will overwrite what is on product page!)
 * 
 * ADDING QUICKVIEW TO THE DEPARTMENT PAGE (DEPT.ASP)   // JAT 5/8/08 - added this section also put in 'default' images and files into a new quickview folder on docs server
 * check box 10 (the last one on the list) on page 5 in the manager  and add the following code to the last "NOT USED" text box in the middle column.
 * <table cellpadding=0 cellspacing=0 style="padding-top:10px;"><tr><td align=center><a HREF=#url# #onclick# class="deptlinkP" target="_top"><img ALIGN="CENTER" BORDER="0" VSPACE="5" HSPACE="5" ALT="#name#" SRC="assets/product_images/#image_file#" onmouseover="popQVIcon('qvicon_#pf_id#');" onmouseout="hideQVIcon('qvicon_#pf_id#');" onError="this.src='assets/images/comingsoon.gif'"></a><div class="qv-wrapper"><img src="assets/images/qvicon.gif" class="qvicon2" style="visibility: hidden; cursor: pointer;" id=qvicon_#pf_id# onmouseover="popQVIcon('qvicon_#pf_id#');" onclick="getProdInfo('#pf_id#');" onmouseout="hideQVIcon('qvicon_#pf_id#');"></div></td></tr><tr><td align=left style="padding:5px 10px 0px 30px;"><a HREF=#url# #onclick# class="deptlinkP" target="_top">#name#</a><span class="shortDesc">#short_description#</span>
*/

/* JAT 8/3/07 - this is a new version of quickview.js  */
var prodReq, prodObj;								// prodReq holds the request object and prodObj holds the returned json object
var isIE = ((navigator.appName) == "Microsoft Internet Explorer")? true : false;	// need this for determining popup positioning
var isIE6 = (window.ActiveXObject)? true : false;	// need this for ajax stuff and whether to display an iframe behind popup
var qvWin = document.getElementById('qv_window');
if(isIE6){var qvIFrame = document.getElementById('qv_iframe');}	// to prevent select dropdowns from bleeding through the div
var qvErr = document.getElementById('qv_error');				// holds message to user if they haven't chosen a sku from dropdown to add to basket
var qvAction = document.getElementById('qv_action');			// holds the product form and action buttons (add to cart, wish, view cart)
//var qvLoader = document.getElementById('qv_loader');			// (moosejaw specific) animated gif for loading
var winHeight = 0;

/**
 * Displays the quick view icon when user rolls over the product image
 * @param{string} pf_id is used to find the id of the quickview icon image on the page.
 **/
function popQVIcon(qv_id){
	var qvicon = document.getElementById(qv_id);
	qvicon.style.visibility = "visible";
	qvicon.style.cursor = "pointer";
	qvicon.parentNode.display = "block";
	//qvicon.parentNode.visibility = "visible";
}

/**
 * Hides the quick view icon when user rolls off the product image
 * @param{string} pf_id is used to find the id of the quickview icon image on the page.
 **/
function hideQVIcon(qv_id){
	document.getElementById(qv_id).style.visibility = "hidden";
}

/**
 * Populates and displays the quickview window for selected product
 **/
function showProd(){
	
	// set "global vars" from product.js onto the json object instead
	prodObj.num_avail = false;	// make a num_avail in place of missing one

	// check if object has product info before going through all the display stuff
	if(!prodObj.pf_id){
		// in the rare case there is no product info returned - display a message to user & clear out quickview popup
		qvWin.style.height = "300px";
		if(isIE6){qvIFrame.style.height = "300px";}
		qvErr.innerHTML = "Sorry, the page has not finished loading.  Please try again...";
		return;
	}//else if(prodObj.Items.length <= 0){	// if product comes back with no items
	//	qvWin.style.height = "300px";
	//	if(isIE6){qvIFrame.style.height = "300px";}
	//	qvErr.innerHTML = "Sorry but this product is no longer available. Please contact orders@brecityonline.com with any questions. ";
	//	return;
	//}	
	
	
	//holds the product display to be written to action div
	var actionMarkup = "";
	
	// begin form that will add product to basket
	actionMarkup += "<FORM METHOD=POST NAME=\"form2\" ACTION=\"" + i_jscript_uu_rootURL + "shopper_lookup.asp\" onsubmit=\"return checkSku();\">";
	actionMarkup += "<input type=hidden name=target id=target value=\"xt_orderform_additem.asp\">";
	actionMarkup += "<INPUT TYPE=HIDDEN NAME=\"auto_reg\" VALUE=\"1\">";
	actionMarkup += "<INPUT TYPE=HIDDEN NAME=s_id VALUE=" + i_jscript_uu_sid + " >";	
	actionMarkup += "<input type=hidden name=qty value=1>";
	if (user_guid !=' '){
		actionMarkup += "<INPUT TYPE=HIDDEN NAME=mscssid VALUE=" + user_guid + " >";
	}

	actionMarkup += "<INPUT TYPE=HIDDEN NAME=wish_id VALUE=" + GetParamterValueQv("wish_id") + " >";
	actionMarkup += "<INPUT TYPE=HIDDEN NAME=order_sid VALUE=" + GetParamterValueQv("order_sid") + " >";
	actionMarkup += "<INPUT TYPE=HIDDEN NAME=so_number VALUE=" + GetParamterValueQv("so_number") + " >";
	actionMarkup += "<INPUT TYPE=HIDDEN NAME=pf_id VALUE=" + prodObj.pf_id + " >";
	actionMarkup += "<INPUT TYPE=HIDDEN Name=returnpath Value=\""+document.location.pathname+document.location.search+"&addfrom=qv\" >";
	
	actionMarkup += '<table width="380" border="0" cellspacing="0" cellpadding="0">';
		//product name
		actionMarkup += '<tr><td valign="top"><FONT class="ProductName">'+prodObj.name+'</FONT></td>';
		//display price
		// check onsale flag to see if sale price should be displayed.		
		actionMarkup += '<td valign="top" align="right">';
		
		actionMarkup += ( prodObj.on_sale == "true") ? "<font class='ListPricewoSale'>Regular Price&nbsp;"+prodObj.list_price_str+"</font><br><font class='SalePrice'>Sale&nbsp;"+prodObj.sale_price_str+"</font>" : "<font class='ListPricewoSale'>Price&nbsp;"+prodObj.list_price_str+"</font>";		
		actionMarkup += '</td></tr>';
		
		if ( prodObj.Items.length > 0 ){
                 actionMarkup += '<tr><td colspan="2" class="product_top_spacer">&nbsp;</td></tr>';
              } else {
                 actionMarkup += '<tr><td colspan="2" class="product_top_spacer"><font color="red"><br><br>This item is currently unavailable.<br>Please contact <strong>info@brewcityonline.com</strong> regarding future availability.</font></td></tr>';
              }		
		
		//display sku and qty dropdowns		 
		actionMarkup += '<tr><td>'+draw_sku_option_qv()+'</td><td align="right">';
	
		// add to cart button
		if (prodObj.enable_basket==1 && prodObj.num_avail){
			actionMarkup += '<INPUT TYPE=Image NAME="pbasket" SRC="assets/images/btnaddbskt1.gif" BORDER=0 ALT="Add to your shopping cart">';
		}
		actionMarkup += '</td></tr>';
		
		actionMarkup += '<tr><td colspan="2" align="center">';
		
		//display image with link to product
		// create main image
		actionMarkup += "<a href=\"product.asp?pf_id=" + prodObj.pf_id + "&\" onclick=\"return(visitargs('product.asp','pf_id=" + prodObj.pf_id + "&','URL'));\"><img id='prod_img' BORDER=0  VSPACE=0  HSPACE=0 ALT=\"" + prodObj.name + "\" title=\"" + prodObj.name + "\" src=\"assets/product_images/" + prodObj.image_2_file+"\" onError=\"this.src='assets/images/spacer.gif';\"></a><br/>";	
		
		// JAT 7/17/08 - add swatches to product popup - UNCOMMENT LINE BELOW TO ACTIVE SWATCH FEATURE !!
		//actionMarkup += drawSwatchQV();
		
		actionMarkup += '</td></tr>';
		
		/* Commenting out Description JMS
		actionMarkup += '<tr><td colspan="2" align="left">';
		// description
		actionMarkup += prodObj.description;
		actionMarkup += '</td></tr>';*/
		
		actionMarkup += '<tr><td colspan="2" align="center">';
		//product detail link
		actionMarkup += "<a href=\"product.asp?pf_id=" + prodObj.pf_id + "&\" onclick=\"return(visitargs('product.asp','pf_id=" + prodObj.pf_id + "&','URL'));\"><img src=\"assets/images/btndetails.gif\" alt=\"Product Details\" title=\"Product Details\" border=\"0\"></a>";
		//buttons
		if (prodObj.enable_wish==1 && prodObj.num_avail){		// add to wish basket button
			 actionMarkup += '<INPUT TYPE=Image  NAME="wbasket" SRC="assets/images/btnaddwish.gif" BORDER=0 ALT="Add to your wish cart">';
		}
		if (prodObj.enable_basket==1 && prodObj.num_avail){		// add to cart button
			actionMarkup += '<INPUT TYPE=Image  NAME="pbasket" SRC="assets/images/btnaddbskt1.gif" BORDER=0 ALT="Add to your shopping cart">';
		}
		//actionMarkup += "<a href=\"javascript:shareproduct('share_new.asp','none','SURL','"+prodObj.pf_id+"','"+prodObj.image_file+"','"+escape(prodObj.name)+"');\"><img src=\"assets/images/btnemlfriend.jpg\" alt=\"Email This to a Friend\" border=\"0\"></a>";
		actionMarkup += '</td></tr>';				
		
		actionMarkup += '</table>';
	
	actionMarkup += "</FORM><br class='clear'>";// end the form

	qvAction.innerHTML = actionMarkup;	// put form, add to cart, add to wish basket, view cart buttons inside div
	
	winHeight = 600;
	//make height 215 + height of image
	if(document.getElementById("prod_img"))
	{
		var img = document.getElementById("prod_img");
		winHeight = img.height + 215;
	}
	
	// re-set the popup's height
	//winHeight = (prodObj.name.length > 60)? 580 : 560;	// ***change height of main popup window if product title goes to a second line
	//winHeight += ((qvPrice.innerHTML).indexOf('-') > -1)? 15 : 0;	// ***add 10 px if price is too long for one line
	qvWin.style.height = winHeight + "px";
	qvWin.style.height = "auto";
	if(isIE6){	// make iframe visible if IE
		//qvIFrame.style.height = winHeight + "px";
		qvIFrame.style.height = (winHeight-50) +"px";
		//qvIFrame.style.left = ((document.body.clientWidth / 2) - 235) + "px";
		//qvIFrame.style.top = (document.documentElement.scrollTop + 50) + "px";
		qvIFrame.style.display = "block";
		qvIFrame.style.visibility = "visible";
		qvIFrame.style.zIndex = "9999979";
	}

	//qvLoader.style.display = "none";	// hide loader animation	
	qvWin.style.visibility = "visible";	// finally display the product quickview popup on the page
}


/**
 * Calls the ajax request for product data
 * @param{string} pf_id is sent in the POST to specify which product's data we're requesting
 **/
function getProdInfo(pf_id){
	if(qvWin.style.visibility == "visible"){closeProd(qvWin.firstChild);}
	// set the popup positioning
	if(isIE6){		// ie6
		qvIFrame.style.left = ((document.body.clientWidth / 2) - 235) + "px";
		qvIFrame.style.top = (document.documentElement.scrollTop + 50) + "px";
		qvWin.style.left = qvIFrame.style.left;
		qvWin.style.top = qvIFrame.style.top;
	}else if(isIE){	// ie7
		qvWin.style.left = ((document.body.clientWidth / 2) - 235) + "px";
		qvWin.style.top = (document.body.scrollTop + 50) + "px";
	}else{			// ff + others
		qvWin.style.left = ((document.body.scrollWidth / 2) - 235) + "px";
		qvWin.style.top = (window.pageYOffset + 50) + "px";
	}

	// display the popup window with a 'loading' message to user until the product info has been loaded
	//qvLoader.style.display = "block";
	qvWin.style.visibility = "visible";
	if(isIE6){qvIFrame.style.display = "block";}

	if (!isIE6) { // iIE7, Mozilla, Safari, ...
		prodReq = new XMLHttpRequest();
		isIE6 = false;
	} else{ // IE6, below
		prodReq = new ActiveXObject("Microsoft.XMLHTTP");
		isIE6 = true;
	}

	/* determine page protocol */  
	var myTemp = window.location.href;  
	var tempSplit = myTemp.split(":");  
	var pageProt = tempSplit[0];  
	  
	prodReq.open('GET', document.location.protocol+'//'+document.location.hostname+'/brewcity/product_json.asp?pf_id='+pf_id, true);
	// NOTE TO DEVELOPER - additional query items you can use:
	// verbose=1 (to use for debugging)
	// inventory=1 (will return availability and out of stock messages)
	  
	prodReq.setRequestHeader('Content-type', 'application/xml');
	prodReq.onreadystatechange = function(){productCallback();}	// specify our callback function
	prodReq.send(null);
}

/**
 * Callback function called in getProdInfo, catches errors or bad statuses that may be returned
 **/
function productCallback(){
	try{
		if(prodReq.readyState == 4){	// 4 = complete
			prodObj = eval('(' + prodReq.responseText + ')');	// parse returned json object for our javascript to read
			showProd();	// call functino to display product /quickview window
			if (prodReq.status !=200) {
				alert('status != 200');
				return;
			}
		}
		else {
			// So IE won't throw an error
			return;
		}
	}catch(e){
		// improperly formed json
	}

}

/**
 * Closes and clears out the product quickview window
 **/
function closeProd(win){
	// clear out divs
	qvErr.style.visibility = "hidden";	
	qvAction.innerHTML = "";	
	win.parentNode.style.visibility = "hidden";		// hide quickview popup
	if(qvIFrame){qvIFrame.style.display = "none";}	// hide iframe
}

/**
 * make sure a product sku has been selected from dropdown before adding to basket
 * @param{boolean} onchange is a flag that is set to true if being called from the sku dropdown onchange event
 */
function checkSku(onchangeFlag){
	var skuSelect;
	if(document.getElementById('sku')){skuSelect = document.getElementById('sku');}	// only grab the sku select dropdown if it exists on the page

	if(onchangeFlag){	// only do this stuff if being called from the select box onchange
		if(skuSelect.value != ""){
			qvErr.style.display = "none";
		}
		return;
	}else{
		if(skuSelect){
			if(skuSelect.value == ""){	// only do this stuff if being called from the form2 onsubmit
				qvErr.style.display = "block";
				//qvWin.style.height = (winHeight + 40) + "px";
				return false;
			}else{
				qvErr.style.display = "none";
				return true;
			}
		}else{
			// if there is no sku select
			qvErr.style.display = "none";
			return false;
		}
	}
}


/* draws the sku dropdown */
/**
 * Returns true if 'e' is contained in the array 'a'
 * @author Johan Känngård, http://dev.kanngard.net
 */
function contains(a, e) {
	if(a!=null)
		for(j=0;j<a.length;j++)if(a[j]==e)return true;
	return false;
}

function draw_sku_option_qv()
{	
	// set differences in vars		
	var product_var = prodObj.Items;
	
	var attr_label = new Array();
	attr_label[0] = prodObj.attr_label1;
	attr_label[1] = prodObj.attr_label2;	
	
	var skuMarkup = "";
	var num_avail = 0;
	var dropdownattr1 = "";
	var attrname = "";
	var dropdown_label="";	
	if (product_var.length >= 1 ){
		prodObj.num_avail = true;
		if(product_var.length==1){
			skuMarkup += "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>";
			skuMarkup += "<TR VALIGN=TOP ><TD class=ProductAttrlabel >" + attr_label[0] + "</TD><TD>";
			if (product_var[0].avail != "0") {
				num_avail=1;
				skuMarkup += "&nbsp;" + product_var[0].attr_value1;
			} else 
			{
				skuMarkup += "<BR>So sorry but this product is not available.";
			
			}
			skuMarkup += "<INPUT TYPE=HIDDEN  NAME=sku id=sku VALUE=\"" + product_var[0].sku + "\" >";
			skuMarkup += "</td></TR></TABLE>";
		}
		else
		{	
			skuMarkup += "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>";
	
			i=attr_label.length-1;
			labelstr="";
			while (attr_label[i]!= "" && i >=0 ) {
			labelstr=labelstr + attr_label[i] + " ";
			i=i-1;
			}
			//writeoption_qv("",labelstr ,sel_values[0]);
			for (atn=0;atn< product_var.length ;atn++){
				if (product_var[atn].avail != "0") {
				  if (num_avail == 0){
				    skuMarkup += "<TR VALIGN=TOP><TD class=ProductAttrlabel>Size</TD><TD>";
				    skuMarkup += "<div id=ddDiv><SELECT class=ProductAttr NAME='sku' id='sku' >";
				  }
				  if (prodObj.useVariantPrice=="True"){
				    if (prodObj.on_sale=="True"){
				      skuMarkup +=writeoption_qv(product_var[atn].sku,(product_var[atn].attr_value2 + " - " + product_var[atn].attr_value1 + " $"+ OKStrOfPenny(product_var[atn].price_sale)+"&nbsp;") ,'');
				    } else {
				      skuMarkup +=writeoption_qv(product_var[atn].sku,(product_var[atn].attr_value2 + " - " + product_var[atn].attr_value1 + " $"+ OKStrOfPenny(product_var[atn].price_list)+"&nbsp;") ,'');
				    }
				  } else {
				    skuMarkup +=writeoption_qv(product_var[atn].sku,(product_var[atn].attr_value2 + " - " + product_var[atn].attr_value1+"&nbsp;") ,'');
				  }
				  num_avail++;
				}
			}//end for
			if (num_avail > 0){
			  skuMarkup += "</SELECT></div></TD><td class=ProductAttrlabel>&nbsp;Qty</td><td><div id=ddDiv><SELECT class=ProductAttr NAME='qty' id='qty'>";
			for(na=1;na<=5;na++){skuMarkup += "<option value=\""+na+"\">"+na+"&nbsp;</option>";}
			  skuMarkup += "</select></div></td>";
			}else{
			  skuMarkup += "<TR VALIGN=TOP><TD class=ProductAttrlabel><BR>So sorry but this product is not available.</td>";
			}
			skuMarkup += "</TR></TABLE>";
		}
	}
	
	return skuMarkup;
	
} //end draw_sku_option

function writeoption_qv(option,display,select){
	var optMarkup = "";
	if (select==option){selected=" SELECTED";}else{selected="";}
	option=String(option);
	option=option.replace(/'/g,"&#39;");
	optMarkup += "<OPTION Value='"+option+"'"+ selected +">"+ display + "</option>";
	return optMarkup;
}

function GetParamterValueQv(ParameterName)
{
var EQUAL = "=";
var AMP = "&";
var QUE = "?";
var EMPTY = "";
var url = window.document.URL.toString();
if (url.indexOf(QUE) > 0 ) {
var Parameters = url.split(QUE)[1].split(AMP);

	for (i = 0; i < Parameters.length; i++ ){
		if (Parameters[i].indexOf(EQUAL) > 0 ){
		var ParameterValue = Parameters[i].split(EQUAL);

		if (ParameterValue[0]== ParameterName ) {
		return ParameterValue[1];
		}
		}
	}
}
return EMPTY;
}


/* draws quick view icon on search thumbnail
*/
function draw_search_qv(product_pfid)
{
	document.write("<div class=\"qv-wrapper\">");
	document.write("<img src=\"assets/images/qvicon.gif\" class=\"qvicon\" style=\"visibility:hidden;\" ");
	if(window.XMLHttpRequest){document.write("style=\"left:0px;\" ");}	// add in an ie7 hack
	document.write("id=\"qvicon_" + product_pfid  + "\" ");
	document.write("onmouseover=\"popQVIcon('qvicon_" + product_pfid  + "');\" ");
	document.write("onclick=\"getProdInfo('" +  product_pfid + "');\" ");
	document.write("onmouseout=\"hideQVIcon('qvicon_" + product_pfid  + "');\" /></div>");
}



/* function called to share product with a friend*/
function shareproduct(PageURL,args,SURL,apf_id,aimage,aproduct_name)
{
	if(typeof apf_id == "undefined") apf_id = pf_id;
	if(typeof aimage == "undefined" && product_image[0].image) aimage = product_image[0].image;
	if(typeof aproduct_name == "undefined") aproduct_name = product_name;
	
	var plink;
	var emailbody;
	var url;
	if (args.indexOf("=")<0 ||args.indexOf("&")<0 ){
		args="";
	}
	if (user_guid !=' ')
	{		
		PageURL =PageURL + '?mscssid='+ user_guid+ '&pf_id='+apf_id+ '&'+ args ;
	}else{
		PageURL =PageURL + '?pf_id='+apf_id+ '&'+ args ;
	}
	
	plink=i_jscript_uu_rootURL+"product.asp?pf_id="+ apf_id +"&" ;
	emailbody = "Dear #RecipientName#,<BR><br>#Text_field_3#<BR><BR>I found this. <BR><A HREF=#URL#>Click here</a> to check it out <BR>or cut-n-paste this link into your browser:<BR><BR><A HREF=#URL#>#URL#</a><BR><BR> #FromName#<BR> #FromEmail#";
	/*emailbody="Dear #RecipientName#,<BR> #Text_field_3# <BR><BR>";
	if (aimage!=""){
		emailbody = emailbody + "<A HREF=\"#URL#\"><img src=\""+i_jscript_uu_rootURL+"assets/product_images/"+aimage+"\" border=0 alt=\""+ aproduct_name+"\"></a>";
	}
	emailbody = emailbody + "<A HREF=\"#URL#\">"+ aproduct_name + "</a><BR>" ;
	emailbody = emailbody + "from #FromName# at <A href=\"mailto:#FromEmail#\">#FromEmail# <BR>" ;*/
	window.location=PageURL +"referer="+escape(plink)+"&email_body="+escape(emailbody)+"&target="+ escape(window.location.href)+"&";
	//Note: This return is required as well
	// false tells the browser to ignore the default action entirely
	//usage Click Here II
	return(false);
} //end shareproduct

/* JAT 7/1/08 - Instead of copying and pasting the hard code onto each page that uses quickview, you can call this function which will write the code for you */
function draw_qv_container(){
	var qvMarkup = "";
	qvMarkup += "<!-- begin feature: quickview -->";
	qvMarkup += "<iframe id=\"qv_iframe\" style=\"\" src=\"assets/images/blank.html\"></iframe>";
	qvMarkup += "<div id=\"qv_window\" style=\"\">";
	qvMarkup += "<a id=\"closebtn\" href=\"javascript:void(0)\" onclick=\"closeProd(this);\">close [x]</a>";
	qvMarkup += "<br/><div id=\"qv_error\" class=\"ErrorMsg\"></div>";
	qvMarkup += "<div id=\"qv_action\"></div>";
	qvMarkup += "</div>";
	qvMarkup += "<!-- end feature: quickview -->";
	document.write(qvMarkup);
}

/* JAT 7/18/08 - This is the Default swatch code and functions the same way as swapper_template.js */
function drawSwatchQV(){
	var swatchcode = "";

	var info_attributes = prodObj.info_attributes;	// setting info attributes var to JSON equivalent
	
	var array_largeimage;
	if (typeof info_attributes!="undefined" && info_attributes != "" && info_attributes != "default"){
		
		var thumbnails_array = info_attributes.split(",");
		var image_array;
		if (thumbnails_array.length >= 1){
			//the number below changes the number of columns for the swatches
			var columns=4;
			var atn = 0;
			var myImage;
			var counter = 1;
			swatchcode += "<table border=0 id='qv_swatch_tbl' cellpadding='0' cellspacing='0'><tr valign='top'>";
			
			for (atn=0; atn<thumbnails_array.length; atn++){
				if (thumbnails_array[atn]!=""){
					image_array = thumbnails_array[atn].split(":");
					swatchcode += "<td align=center><table border=0><tr><td align=center><A HREF=\"#\" onClick=\"return false\" onmouseover=\"imgOnQV('"+image_array[1]+"')\" ><img NAME=\""+image_array[1]+"\" id=\""+image_array[1]+"\" src=\"assets/images/swatches/" + prodObj.pf_id + "_" + image_array[1] + "_sm.jpg\" border=0></A>";
					swatchcode += "<br>"+image_array[0]+"</td></tr></table></td>";
					if (counter==columns){
						swatchcode += "</tr><tr>";
						counter=0;
					}
				}
			counter = counter+1;
			}
			swatchcode += "</tr></table>";
		}
	}
	
	return swatchcode;
}

/*  JAT 7/18/08 - Rollover function for swatch feature on quickview*/
function imgOnQV(imgName) {
        document.getElementById("prod_img").src="assets/images/swatches/" + prodObj.pf_id + "_" + imgName + "_lg.jpg";
}