/*
+----------------------------------------------------------------------+
| Preorder / Backorder Mod                                             |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2009 BCSE LLC. dba BCS Engineering                |
+----------------------------------------------------------------------+
|                                                                      |
| Advanced Filter Mod is subject for version 2.0 of the BCSE           |
| proprietary license. That license file can be found bundled with     |
| this package in the file BCSE_LICENSE. A copy of this license can    |
| also be found at                                                     |
| http://www.bcsengineering.com/license/BCSE_LICENSE_2.0.txt           |
|                                                                      |
+----------------------------------------------------------------------+
*/

var base_preorder_text = "<b>"+pb_product_not_available+"</b>&nbsp;<span onclick=\"javascript: window.open('preorder_backorder.php?productid="+pb_productid+"&variantid=@@variantid@@','pbwin','width=750,height=500');\" onmouseover=\"javascript: this.className = 'preorder_hover';\" onmouseout=\"javascript: this.className = 'preorder';\" class=\"preorder\">"+pb_preorder+"</span> "+pb_yours_today+".<br />"+
"<span style=\"color:red;\">"+pb_due_in_stock+": @@due_in_stock@@</span><br />";

var base_backorder_text = "<b>"+pb_product_out_of_stock+"</b>&nbsp;<span onclick=\"javascript: window.open('preorder_backorder.php?productid="+pb_productid+"&variantid=@@variantid@@','pbwin','width=750,height=500');\" onmouseover=\"javascript: this.className = 'preorder_hover';\" onmouseout=\"javascript: this.className = 'preorder';\" class=\"preorder\">"+pb_backorder+"</span> "+pb_yours_today+".<br />"+
"<span style=\"color:red;\">"+pb_due_in_stock+": @@due_in_stock@@</span><br />"

function set_pb_text(variantid){

	if(!document.getElementById('pre_text'))
		return;

	var text_element = document.getElementById('pre_text');

	if(variant_preorder.length < 1){
		text_element.innerHTML = '';
		return;
	}

	var variant_found = false;
	for(var z in variant_preorder){
		if(z == variantid){
			variant_found = true;
			break;
		}
	}

	if(!variant_found){
		text_element.innerHTML = '';
		return;
	}

	if(variant_preorder[variantid]['pb'] == 'B' && document.getElementById('product_avail') && document.getElementById('product_avail').tagName.toLowerCase() == "select"){
		var avail_select = document.getElementById('product_avail');

		while(avail_select.options.length > 0)
			avail_select.options[0] = null;

		var cnt = 0;
		for(var i = 1; i <= 50; i++)
			avail_select.options[cnt++] = new Option(i, i);
	}

	if(variant_preorder[variantid]['pb'] == 'P')
		var html_text = base_preorder_text.replace("@@variantid@@",variantid);
	else
		var html_text = base_backorder_text.replace("@@variantid@@",variantid);

	html_text = html_text.replace('@@due_in_stock@@',variant_preorder[variantid]['date_avail']);

	text_element.innerHTML = html_text;

	return;
}

