/*
	created by		: Rob Lilley, http://Rob-COmmunications.com
	created on		: Jan 2, 2004
	purpose			: Main JavaScript file for Century Graphic
*/


/* ***********************************************************************

for Adding Product

**********************************************************************  */ 

// for adding an image product
function AddImageChanged(){
	document.zcNewAdminINCAdd.ImageNameMirror.value = document.zcNewAdminINCAdd.attached.value;
}

// for changing to an existing image product
function addExistingImageChange(){
	document.zcNewAdminINCAdd.ImageNameMirror.value = document.zcNewAdminINCAdd.addimagepath.value;
}	

// Make sure all 3 Prices change if atcost changes 
function AddCostChange(){

	if(document.zcNewAdminINCAdd.addatcost.value == ''){
		alert('You must provide the Cost price');
		return false;
		}
	
	if(isNaN(document.zcNewAdminINCAdd.addatcost.value)){
		alert('You must provide a numeric Cost price');
		return false;
		}
	
	// Round the initial values first
	document.zcNewAdminINCAdd.addatcost.value = roundValue(document.zcNewAdminINCAdd.addatcost.value);
	
	// Make the calculations based on rounded values
	document.zcNewAdminINCAdd.addprice.value = roundValue(document.zcNewAdminINCAdd.addatcost.value * document.zcNewAdminINCAdd.addpercent0.value);
	document.zcNewAdminINCAdd.addtprice1.value = roundValue(document.zcNewAdminINCAdd.addatcost.value * document.zcNewAdminINCAdd.addtpercent1.value);
	document.zcNewAdminINCAdd.addtprice2.value = roundValue(document.zcNewAdminINCAdd.addatcost.value * document.zcNewAdminINCAdd.addtpercent2.value);
}

// Make sure Price changes if percent changes
function AddPercent0Change()
{

	if(isNaN(document.zcNewAdminINCAdd.addpercent0.value))
	{
		alert('You must provide a numeric Tier 1 MarkUp %');
		return false;
	}
	// Round the initial value first
	document.zcNewAdminINCAdd.addpercent0.value = roundValue(document.zcNewAdminINCAdd.addpercent0.value);
	// Make the calculations based on rounded values
	document.zcNewAdminINCAdd.addprice.value = roundValue(document.zcNewAdminINCAdd.addatcost.value * document.zcNewAdminINCAdd.addpercent0.value);
}

// Make sure tPrice1 changes if tpercent1 changes 
function AddTpercent1Change()
{
	if(isNaN(document.zcNewAdminINCAdd.addtpercent1.value))
	{
		alert('You must provide a numeric Tier 2 MarkUp %');
		return false;
	}
	// Round the initial value first
	document.zcNewAdminINCAdd.addtpercent1.value = roundValue(document.zcNewAdminINCAdd.addtpercent1.value);
	// Make the calculations based on rounded values
	document.zcNewAdminINCAdd.addtprice1.value = roundValue(document.zcNewAdminINCAdd.addatcost.value * document.zcNewAdminINCAdd.addtpercent1.value);
}

// Make sure tPrice2 changes if tpercent2 changes 
function AddTpercent2Change()
{
	if(isNaN(document.zcNewAdminINCAdd.addtpercent2.value))
	{
		alert('You must provide a numeric Tier 3 MarkUp %');
		return false;
	}
	// Round the initial value first
	document.zcNewAdminINCAdd.addtpercent2.value = roundValue(document.zcNewAdminINCAdd.addtpercent2.value);
	// Make the calculations based on rounded values
	document.zcNewAdminINCAdd.addtprice2.value = roundValue(document.zcNewAdminINCAdd.addatcost.value * document.zcNewAdminINCAdd.addtpercent2.value);
}


// Make sure a numeric tQTY is given 
function addQtyChange()
{	
	if(isNaN(document.zcNewAdminINCAdd.addqty.value))
	{
		alert('You must provide a numeric Quantity');
		document.zcNewAdminINCAdd.addqty.value = 0;
		return false;
	}
}

// Make sure a numeric tQTY1 is given 
function AddTQty1Change()
{	
	if(isNaN(document.zcNewAdminINCAdd.addtqty1.value))
	{
		alert('You must provide a numeric Quantity 2');
		document.zcNewAdminINCAdd.addtqty1.value = 0;
		return false;
	}
}

// Make sure a numeric tQTY2 is given 
function AddTQty2Change()
{
	if(isNaN(document.zcNewAdminINCAdd.addtqty2.value))
	{
		alert('You must provide a numeric Quantity 3');
		document.zcNewAdminINCAdd.addtqty2.value = 0;
		return false;
	}
}

function AddCompetitorPrice1Change()
{
	if(isNaN(document.zcNewAdminINCAdd.addCompetitorPrice1.value))
	{
		alert('You must provide a numeric Competitor Price1');
		return false;
	}
	document.zcNewAdminINCAdd.addCompetitorPrice1.value = roundValue(document.zcNewAdminINCAdd.addCompetitorPrice1.value);
}

function AddCompetitorPrice2Change()
{
	if(isNaN(document.zcNewAdminINCAdd.addCompetitorPrice2.value))
	{
		alert('You must provide a numeric Competitor Price2');
		return false;
	}
	document.zcNewAdminINCAdd.addCompetitorPrice2.value = roundValue(document.zcNewAdminINCAdd.addCompetitorPrice2.value);
}

function AddCheckFields(){
	
	if(document.zcNewAdminINCAdd.addpid.value == '')
	{
		alert('You must provide a ProductID');
		return false;
		}
		
	if(document.zcNewAdminINCAdd.addcid.value == '')
	{
		alert('You must provide a CenturyID');
		return false;
		}
		
	if(document.zcNewAdminINCAdd.addname.value == '')
	{
		alert('You must provide a Product Name');
		return false;
		}
	if(document.zcNewAdminINCAdd.addspecs.value == '')
	{
		alert('You must provide Product Specs');
		return false;
		}
		
	if(document.zcNewAdminINCAdd.addatcost.value == '')
	{
		alert('You must provide a cost');
		return false;
	}
	
	if(isNaN(document.zcNewAdminINCAdd.addatcost.value))
	{
		alert('You must provide a numeric Cost');
		return false;
	}
		
	if(document.zcNewAdminINCAdd.addpercent0.value == '')
	{
		alert('You must provide the Tier 1 MarkUp %');
		return false;
	}
		
	if(isNaN(document.zcNewAdminINCAdd.addCompetitorPrice1.value))
	{
		alert('You must provide a numeric Competitor Price 1');
		return false;
	}
		
	if(isNaN(document.zcNewAdminINCAdd.addCompetitorPrice2.value))
	{
		alert('You must provide a numeric Competitor Price 2');
		return false;
	}
						
	if(document.zcNewAdminINCAdd.addkeywords.value == '')
	{
		alert('You must provide Keywords');
		return false;
		}
	
	// Tiered?	
	if(document.zcNewAdminINCAdd.addteired.value == 'yes'){

			if(isNaN(document.zcNewAdminINCAdd.addtpercent2.value))
			{
				alert('You must provide a numeric Tier 3 MarkUp %');
				return false;
			}
		
			if(document.zcNewAdminINCAdd.addtpercent1.value == '')
			{
				alert('You must provide the Tier 2 MarkUp %');
				return false;
			}
			
			if(isNaN(document.zcNewAdminINCAdd.addtpercent1.value))
			{
				alert('You must provide a numeric Tier 2 MarkUp %');
				return false;
			} 
		
			if(document.zcNewAdminINCAdd.addtqty1.value == '')
			{
				alert('You must provide the Tier 2 QTY');
				return false;
			}
		
			if(isNaN(document.zcNewAdminINCAdd.addtqty1.value))
			{
				alert('You must provide a numeric Tier 2 QTY');
				return false;
			}
		
			if(document.zcNewAdminINCAdd.addtpercent2.value == '')
			{
				alert('You must provide the Tier 3 MarkUp %');
				return false;
			}
			
			
			if(document.zcNewAdminINCAdd.addtqty2.value == ''){
				alert('You must provide the Tier 3 QTY');
				return false;
			}
			
			if(isNaN(document.zcNewAdminINCAdd.addtqty2.value))
			{
				alert('You must provide a numeric Tier 3 QTY');
				return false;
			}
			
			if(document.zcNewAdminINCAdd.adddescription.value == ''){
				return confirm('Are you sure you do not wish to supply a description?');
			}
	}
}
/* ***********************************************************************

for Adding Product ENDS

**********************************************************************  */ 
					
/* ***********************************************************************

for SAVE-DELETE product 

**********************************************************************  */ 

// Change Prices if atcost changes
function AtCostChange(obj)
{
	if(obj.atcost.value == '')
	{
		alert('You must provide the Cost price');
		return false;
	}

	if(isNaN(obj.atcost.value))
	{
		alert('You must provide a numeric Cost price');
		return false;
	}
	obj.atcost.value = roundValue(obj.atcost.value);
	obj.price.value = roundValue(obj.atcost.value * obj.percent0.value);
	obj.tprice1.value = roundValue(obj.atcost.value * obj.tpercent1.value);
	obj.tprice2.value = roundValue(obj.atcost.value * obj.tpercent2.value);				
}

// Make sure Price changes if percent changes 
function Percent0Change(obj)
{

	if(isNaN(obj.percent0.value))
	{
		alert('You must provide a numeric Tier 1 MarkUp %');
		return false;
	}
	
	if(obj.percent0.value == '')
	{
		alert('You must provide the Tier 1 MarkUp %');
		return false;
	}
	obj.percent0.value = roundValue(obj.percent0.value);
	obj.price.value = roundValue(obj.atcost.value * obj.percent0.value);
}
// Make sure QTY is number or not left blank 
function QtyChange(obj)
{
	if(obj.teired.value == 'no')
	{
		if(obj.qty.value == '')
		{
			obj.qty.value =0;
			return false;
		}
	
		if(isNaN(obj.qty.value))
		{
			alert('You must provide a numeric Tier 1 Quantity');
			return false;
		}		
	}

	if(obj.teired.value == 'yes')
	{
		if(obj.qty.value == '')
		{
			alert('You must provide a Tier 1 Quantity');
			return false;
		}
		
		if(isNaN(obj.qty.value))
		{
			alert('You must provide a numeric Tier 1 Quantity');
			return false;
		}	
	}				
}

// Make sure tPrice1 changes if tpercent1 changes 
function Tpercent1Change(obj)
{
	if(obj.teired.value == 'no')
	{
		if(obj.tpercent1.value == '')
		{
			obj.tpercent1.value = 0;
			return false;
		}
	
		if(isNaN(obj.tpercent1.value))
		{
			alert('You must provide a numeric Tier 2 MarkUp %');
			return false;
		}
	}

	if(obj.teired.value == 'yes')
	{
		if(obj.tpercent1.value == '')
		{
			alert('You must provide a Tier 2 MarkUp %');
			return false;
		}
	
		if(isNaN(obj.tpercent1.value))
		{
			alert('You must provide a numeric Tier 2 MarkUp %');
			return false;
		}	
	}
	obj.tpercent1.value = roundValue(obj.tpercent1.value);																					
	obj.tprice1.value = roundValue(obj.atcost.value * obj.tpercent1.value);
}	

// Make sure tQTY1 is number or not left blank 
function TQty1Change(obj)
{
	if(obj.teired.value == 'no')
	{
		if(obj.tqty1.value == '')
		{
			obj.tqty1.value =0;
			return false;
		}
	
		if(isNaN(obj.tqty1.value))
		{
			alert('You must provide a numeric Tier 2 Quantity');
			return false;
		}		
	}

	if(obj.teired.value == 'yes')
	{
		if(obj.tqty1.value == '')
		{
			alert('You must provide a Tier 2 Quantity');
			return false;
		}
		
		if(isNaN(obj.tqty1.value))
		{
			alert('You must provide a numeric Tier 2 Quantity');
			return false;
		}	
	}				
}

// Make sure tPrice1 changes if tpercent1 changes 
function Tpercent2Change(obj)
{
	if(obj.teired.value == 'no')
	{
		if(obj.tpercent2.value == '')
		{
			obj.tpercent2.value = 0;
			return false;
		}
	
		if(isNaN(obj.tpercent2.value))
		{
			alert('You must provide a numeric Tier 3 MarkUp %');
			return false;
		}
	}

	if(obj.teired.value == 'yes')
	{
		if(obj.tpercent2.value == '')
		{
			alert('You must provide a Tier 3 MarkUp %');
			return false;
		}
	
		if(isNaN(obj.tpercent2.value))
		{
			alert('You must provide a numeric Tier 3 MarkUp %');
			return false;
		}	
	}
	obj.tpercent2.value =roundValue(obj.tpercent2.value);																						
	obj.tprice2.value = roundValue(obj.atcost.value * obj.tpercent2.value);
}

// Make sure tQTY2 is number or not left blank 
function TQty2Change(obj)
{
	if(obj.teired.value == 'no')
	{
		if(obj.tqty2.value == '')
		{
			obj.tqty2.value =0;
			return false;
		}
	
		if(isNaN(obj.tqty2.value))
		{
			alert('You must provide a numeric Tier 3 Quantity');
			return false;
		}
	}

	if(obj.teired.value == 'yes')
	{
		if(obj.tqty2.value == '')
		{
			alert('You must provide a Tier 3 Quantity');
			return false;
		}
	
		if(isNaN(obj.tqty2.value))
		{
			alert('You must provide a numeric Tier 3 Quantity');
			return false;
		}	
	}
} 	

// Numeric CompetitorPrice1
function CompetitorPrice1Change(obj)
{
	if(isNaN(obj.CompetitorPrice1.value))
	{
		alert('You must provide a numeric Competitor Price 1');
		return false;
	}
	obj.CompetitorPrice1.value = roundValue(obj.CompetitorPrice1.value);
}

// Numeric CompetitorPrice2
function CompetitorPrice2Change(obj)
{
	if(isNaN(obj.CompetitorPrice2.value))
	{
		alert('You must provide a numeric Competitor Price 2');
		return false;
	}
	obj.CompetitorPrice2.value = roundValue(obj.CompetitorPrice2.value);
}
/* ***********************************************************************

for SAVE-DELETE product ENDS

**********************************************************************  */ 

/* ***********************************************************************

Misc functions

**********************************************************************  */ 

// Round all passed values
function roundValue(myValue)
{
	return Math.round((myValue) * 100)/100;
}

// Open window to see Product details 		
function openWindow(linkObj,windowName,properties){
	window.open(linkObj, windowName, properties);
}
	
// Open window to see Product details 		
function openPWin(linkObj){
	window.open(linkObj, "pWin","location=no,toolbar=no,status=yes,scrollbars=yes,resizable=yes,width=705,height=550");
}

// Validate the Resume page
function validateResumeForm(f)
{
	if (f.firstName.value == "")
	{
		alert("Please enter a First Name.");
		f.firstName.focus();
		return false;
	}
	
	if (f.lastName.value == "")
	{
		alert("Please enter a Last Name.");
		f.lastName.focus();
		return false;
	}
	
	//alert(f.keepExistingResume[0].checked);
	//alert(f.keepExistingResume[1].checked);
	//alert(f.keepExistingResume[2].checked);
	
	
	if (f.keepExistingResume[0].checked)
	{
		// No resume
		if (f.webSiteURL.value == "")
		{
			alert("As no resume is provided, please enter the name of the individuals' website.");
			f.webSiteURL.focus();
			return false;
		}
	}
	
	if (f.keepExistingResume[2].checked)
	{
		// No resume
		if (f.documentName.value == "")
		{
			alert("Please enter the location and name of a resume, or browse to find one.");
			f.documentName.focus();
			return false;
		}
	}
	
	// Gather category items
	for(i=0; i<f.category_selected.options.length; i++)
	{
		// store in temporary array, then delete them
		if (i==0)
		{
			f.category_values.value = f.category_values.value + f.category_selected.options[i].value;
		}
		else
		{
			f.category_values.value = f.category_values.value + "," + f.category_selected.options[i].value;
		}
	}
}

// Change the contents of two select/option tags by adding and/or removing items from one to another
function alterCategories(action, f, allSelections, userSelections)
{
	// action = 'add' or 'remove'
	// f = name of the form
	// allSelections = the select tag with all entries
	// selectUsers = the select tag with the users selections
	
	var s,val,tmp;
	tmp = new Array();
	allSelections = eval("document." + f + "." + allSelections);
	userSelections = eval("document." + f + "." + userSelections);
	
	
	if(action == 'add')
	{
		s = allSelections.selectedIndex;
		if(s == -1)
		{
			alert("Please select an item to add!");
			allSelections.focus();
			return false;
		}
		
		// remeber value
		val = allSelections.options[s].value;
		txt = allSelections.options[s].text;
		// remove it 
		allSelections.options[s] = null;
		userSelections.options[userSelections.options.length] = new Option(txt, val);
		
		// store in temporary array, then delete them
		for(i=0; i<userSelections.options.length; i++)
		{
			val = userSelections.options[i].value;
			txt = userSelections.options[i].text;
			tmp[i] = txt + "|" + val;	
		}
		// now sort tmp and re-populate the options
		tmp.sort();
		for(i=0; i<userSelections.length; i++)
		{
			optionInfo = tmp[i].split("|");
			userSelections.options[i] = new Option(optionInfo[0],optionInfo[1]);
		}
		for(i=0; i<tmp.length; i++) tmp[i] = null;

	}
	else if(action == 'remove') 
	{
		s = userSelections.selectedIndex;
		if(s == -1)
		{
			alert("Please select an item to remove!");
			userSelections.focus();
			return false;
		}
		// remeber value
		val = userSelections.options[s].value;
		txt = userSelections.options[s].text;
		// remove it 
		userSelections.options[s] = null;
		allSelections.options[allSelections.options.length] = new Option(txt, val);
		
		// store in temporary array, then delete them
		for(i=0; i<allSelections.options.length; i++)
		{
			val = allSelections.options[i].value;
			txt = allSelections.options[i].text;
			tmp[i] = txt + "|" + val;	
		}
		
		// now sort tmp and re-populate the options
		tmp.sort();
		for(i=0; i<allSelections.length; i++)
		{
			optionInfo = tmp[i].split("|");
			allSelections.options[i] = new Option(optionInfo[0],optionInfo[1]);
		}
		for(i=0; i<tmp.length; i++) tmp[i] = null;
		
	}
}

// preload images for faster rollovers
var preloadFlag = true;
function preloadImages() {
	if (document.images) {
		contact_over = newImage("images/contact-over.gif");
		aboutus_over = newImage("images/aboutus-over.gif");
		faq_over = newImage("images/faq-over.gif");
		library_over = newImage("images/library-over.gif");
		techsupp_over = newImage("images/techsupp-over.gif");
		hardwareOn = newImage("images/hardwareOn.gif");
		softwareOn = newImage("images/softwareOn.gif");
		artsuppOn = newImage("images/artSuppOn.gif");
		homeOn = newImage("images/homeOn.gif");
		moreInfoOn = newImage("images/moreInfoOn.gif");
		viewCartON = newImage("images/viewCartOn.gif");
		preloadFlag = true;
	}
}

function newImage(arg) 
{
	if (document.images) 
	{
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

// switch images when mouseover or mouseon
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];
		}
	}
}

/*
function openPWin(linkObj)
{
	window.open(linkObj, "pWin","toolbar=no,status=yes,scrollbars=yes,width=700,height=400");
}
*/

function openHelp(urlObj)
{
	window.open(urlObj, "","toolbar=no,status=yes,scrollbars=yes,width=380,height=200");
}

<!-- Preload images -->
<!--

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}


// Round a number to two decimal places
function roundNum(obj)
{
	obj.value = Math.round(obj.value*100)/100;
}

// -->
<!-- End Preload Script -->

/* Script to open the login.cfm page */
function openLogin(linkObj)
{
	window.open(linkObj, "taxWindow","toolbar=no,status=yes,scrollbars=no,width=350,height=260");
}


// open pop-up window
function openNewWindow(win,w,h)
{
	x = (screen.width - w)/2;
	y = (screen.height - h)/2;
	open(win,'new_win','screenX='+x+',left='+x+',screenY='+y+',top='+y+',width='+w+',height='+h+',scrollbars');
}
// Generic Error Message
function _CF_onError(form_object, input_object, object_value, error_message)
{
	alert(error_message);
  	return false;	
}

// Determine if an object has a value or not
function _CF_hasValue(obj, obj_type)
{

	if (obj_type == "TEXT" || obj_type == "PASSWORD")
	{
    	if (obj.value.length == 0) 
      		return false;
    	else 
      		return true;
   	}
    else if (obj_type == "SELECT")
	{
        for (i=0; i < obj.length; i++)
	    {
			if (obj.options[i].selected && obj.value != "NA")
				return true;
		}
       	return false;	
	}
    else if (obj_type == "SINGLE_VALUE_RADIO" || obj_type == "SINGLE_VALUE_CHECKBOX")
	{
		if (obj.checked)
			return true;
		else
       		return false;	
	}
    else if (obj_type == "RADIO" || obj_type == "CHECKBOX")
	{
        for (i=0; i < obj.length; i++)
	    	{
		if (obj[i].checked)
			return true;
		}
       	return false;	
	}
}

function _CF_checkinteger(object_value)
{
    //Returns true if value is a number or is NULL
    //otherwise returns false	
    if (object_value.length == 0)
        return true;
    //Returns true if value is an integer defined as
    //   having an optional leading + or -.
    //   otherwise containing only the characters 0-9.
	var decimal_format = ".";
	var check_char;
    //The first character can be + -  blank or a digit.
	check_char = object_value.indexOf(decimal_format)
    //Was it a decimal?
    if (check_char < 1)
		return _CF_checknumber(object_value);
    else
	return false;
}

function _CF_numberrange(object_value, min_value, max_value)
{
    // check minimum
    if (min_value != null)
	{
        if (object_value < min_value)
		return false;
	}
    // check maximum
    if (max_value != null)
	{
		if (object_value > max_value)
		return false;
	}

    //All tests passed, so...
    return true;
}

function _CF_checknumber(object_value)
{
    //Returns true if value is a number or is NULL
    //otherwise returns false	
    if (object_value.length == 0)
        return true;
		
    //Returns true if value is a number defined as
    //   having an optional leading + or -.
    //   having at most 1 decimal point.
    //   otherwise containing only the characters 0-9.
	var start_format = " .+-0123456789";
	var number_format = " .0123456789";
	var check_char;
	var decimal = false;
	var trailing_blank = false;
	var digits = false;

    //The first character can be + - .  blank or a digit.
	check_char = start_format.indexOf(object_value.charAt(0))

    //Was it a decimal?
	if (check_char == 1)
	    decimal = true;
	else if (check_char < 1)
		return false;

        

	//Remaining characters can be only . or a digit, but only one decimal.
	for (var i = 1; i < object_value.length; i++)
	{
		check_char = number_format.indexOf(object_value.charAt(i))
		if (check_char < 0)
			return false;
		else if (check_char == 1)
		{
			if (decimal)		// Second decimal.
				return false;
			else
				decimal = true;
		}
		else if (check_char == 0)
		{
			if (decimal || digits)	
				trailing_blank = true;
        // ignore leading blanks
		}
	    else if (trailing_blank)
			return false;
		else
			digits = true;
	}	

    //All tests passed, so...
    return true
}

function _CF_checkrange(object_value, min_value, max_value)
 {
    //if value is in range then return true else return false
    if (object_value.length == 0)
        return true;
		
    if (!_CF_checknumber(object_value))
	{
		return false;
	}
    else
	{
		return (_CF_numberrange((eval(object_value)), min_value, max_value));
	}

    //All tests passed, so...
    return true;
}

function _CF_checkphone(object_value)
{
    if (object_value.length == 0)
        return true;

    if (object_value.length != 12)
        return false;

	// check if first 3 characters represent a valid area code
    if (!_CF_checknumber(object_value.substring(0,3)))
		return false;
    else

	if (!_CF_numberrange((eval(object_value.substring(0,3))), 100, 1000))
		return false;

	// check if area code/exchange separator is either a'-' or ' '
	if (object_value.charAt(3) != "-" && object_value.charAt(3) != " ")
        return false

	// check if  characters 5 - 7 represent a valid exchange
    if (!_CF_checknumber(object_value.substring(4,7)))
		return false;
    else

	if (!_CF_numberrange((eval(object_value.substring(4,7))), 100, 1000))
		return false;

	// check if exchange/number separator is either a'-' or ' '
	if (object_value.charAt(7) != "-" && object_value.charAt(7) != " ")
        return false;

	// make sure last for digits are a valid integer
	if (object_value.charAt(8) == "-" || object_value.charAt(8) == "+")
        return false;
	else
	{
		return (_CF_checkinteger(object_value.substring(8,12)));
	}
}

// Checks all the fields in the checkout1.cfm file
function  billingInfoValidation(_CF_this)
{
	// Billing Options
	
    if  (!_CF_hasValue(_CF_this.login, "TEXT" )) 
    {
		if  (!_CF_onError(_CF_this, _CF_this.login, _CF_this.login.value, "Please enter a login name."))
        {
			_CF_this.login.focus();
			return false; 
        }
	}
    if  (!_CF_hasValue(_CF_this.pwd, "TEXT" )) 
    {
        if  (!_CF_onError(_CF_this, _CF_this.pwd, _CF_this.pwd.value, "Please enter a password."))
	    {
			_CF_this.pwd.focus();
			return false; 
        }
    }
    if  (!_CF_hasValue(_CF_this.fname, "TEXT" )) 
    {
        if  (!_CF_onError(_CF_this, _CF_this.fname, _CF_this.fname.value, "Please enter your first name."))
        {
			_CF_this.fname.focus();
            return false; 
        }
    }
    if  (!_CF_hasValue(_CF_this.lname, "TEXT" )) 
	{
        if  (!_CF_onError(_CF_this, _CF_this.lname, _CF_this.lname.value, "Please enter your last name."))
        {
			_CF_this.lname.focus();
          	return false; 
        }
    }
	
    if  (!_CF_hasValue(_CF_this.add1, "TEXT" )) 
    {
        if  (!_CF_onError(_CF_this, _CF_this.add1, _CF_this.add1.value, "Please enter the street name."))
        {
			_CF_this.add1.focus();
	        return false; 
         }
    }
	if  (!_CF_hasValue(_CF_this.city, "TEXT" )) 
	{
        if  (!_CF_onError(_CF_this, _CF_this.city, _CF_this.city.value, "Please provide the city."))
	    {
			_CF_this.city.focus();
	        return false; 
        }
    }
    if  (!_CF_hasValue(_CF_this.prov, "SELECT" )) 
    {
	      if  (!_CF_onError(_CF_this, _CF_this.prov, _CF_this.prov.value, "Please select your province."))
          {
		  	_CF_this.prov.focus();
			return false; 
           }
    }
	if  (!_CF_hasValue(_CF_this.pc, "TEXT" )) 
   {
	    if  (!_CF_onError(_CF_this, _CF_this.pc, _CF_this.pc.value, "Please provide your postal code."))
        {
			_CF_this.pc.focus();
	    	return false; 
        }
   }

	if  (!_CF_hasValue(_CF_this.country, "SELECT" )) 
	{
		if  (!_CF_onError(_CF_this, _CF_this.country, _CF_this.country.value, "Please select your country."))
		{
			_CF_this.country.focus();
			return false; 
        }
    }

	if  (!_CF_hasValue(_CF_this.phone2, "TEXT" )) 
    {
		if  (!_CF_onError(_CF_this, _CF_this.phone2, _CF_this.phone2.value, "Please provide your phone number."))
       {
	   		_CF_this.phone2.focus();
            return false; 
       }
    }
	
    if  (!_CF_checkphone(_CF_this.phone2.value))
   {
        if  (!_CF_onError(_CF_this, _CF_this.phone2, _CF_this.phone2.value, "Please provide your phone number in the correct format."))
        {
			_CF_this.phone2.focus();
	        return false; 
        }
   }

   	if  (!_CF_hasValue(_CF_this.email, "TEXT" )) 
	{
        if  (!_CF_onError(_CF_this, _CF_this.email, _CF_this.email.value, "Please enter your email address."))
        {
			_CF_this.email.focus();
            return false; 
        }
    }
	
    return true;
}

// Shipping Options
function  shippingInfoValidation(_CF_this)
{
	// Shipping Options
	 if  (!_CF_hasValue(_CF_this.shipOption, "SELECT" )) 
     {
	     if  (!_CF_onError(_CF_this, _CF_this.shipOption, _CF_this.shipOption.value, "Please select a delivery method."))
            {
				_CF_this.shipOption.focus();
	            return false; 
            }
     }
    return true;
}

function orderReviewValidation(f)
{
	if (f.TXExmpt.checked){
		if (f.TXExmptNum.value == ""){
			alert("Please enter your Tax Exemption number.");
			return false; 
		}
	}
	return true; 
}


// START - Login Functions //
function openReg(linkObj)
	{
		window.open(linkObj, "taxWindow","toolbar=no,status=yes,scrollbars=yes");
		self.resizeTo(770, 580);
	}
	
	function openEmailPassword(linkObj)
	{
		window.open(linkObj, "taxWindow","toolbar=no,status=yes,scrollbars=yes,width=770,height=520");
	}
// END - Login Functions //

// START - LoginINC Functions //
function openProfile(linkObj)
	{
		window.open(linkObj, "taxWindow","toolbar=no,status=yes,scrollbars=yes,width=770,height=520");
	}
// END - LoginINC Functions //

// START - Registration functions //
function validateRegistrationFields()
{			
	if(document.loginform.uid.value == ''){
		alert('You must supply a Username');
		loginform.uid.focus();
		return false;
		}
	if(document.loginform.pwd.value == ''){
		alert('You must supply a Password');
		document.loginform.pwd.focus();
		return false;
		}
	if(document.loginform.pwdConfirm.value == ''){
		alert('You must supply a confirmation Password');
		document.loginform.pwdConfirm.focus();
		return false;
		}
	if(document.loginform.pwd.value != document.loginform.pwdConfirm.value){
		alert('Please make sure your password and confirmation password match');
		document.loginform.pwd.focus();
		return false;
		}
	if(document.loginform.fname.value == ''){
		alert('You must supply a First Name');
		document.loginform.fname.focus();
		return false;
		}
	if(document.loginform.lname.value == ''){
		alert('You must supply a Last Name');
		document.loginform.lname.focus();
		return false;
		}
	if(document.loginform.add1.value == ''){
		alert('You must supply a Street Name');
		document.loginform.add1.focus();
		return false;
		}
	if(document.loginform.city.value == ''){
		alert('You must supply a City');
		document.loginform.city.focus();
		return false;
		}
	if(document.loginform.prov.value == ''){
		alert('You must supply a Province');
		document.loginform.prov.focus();
		return false;
		}
	if(document.loginform.pc.value == ''){
		alert('You must supply a Postal Code');
		document.loginform.pc.focus();
		return false;
		}
	if(document.loginform.country.value == ''){
		alert('You must supply a Country');
		document.loginform.country.focus();
		return false;
		}
	if(document.loginform.phone2.value == ''){
		alert('You must supply a Phone Number');
		document.loginform.phone2.focus();
		return false;
		}
	if(document.loginform.email.value == ''){
		alert('You must supply an Email address');
		document.loginform.email.focus();
		return false;
		}
}
// END - Registration functions //

// START - pDetail //
function sCart(linkObj) 
{
	opener.parent.location.href=linkObj;
	self.close();
}

// END - pDetail //

// START - showCart //
function openUpdate(linkObj)
{
	window.open(linkObj, "udWindow","toolbar=no,status=yes,scrollbars=yes,width=580,height=410");
}
// END - showCart //

// START - editProfile //
function checkFieldsEditProfile()
{
	
	if(document.loginform.pwd.value != '' || document.loginform.pwdConfirm.value != ''){
		if(document.loginform.pwd.value != document.loginform.pwdConfirm.value){
			alert('Your New Password and Password Confirmation must be the same');
			document.loginform.pwd.focus();
			return false;
			}
	}
	if(document.loginform.fname.value == ''){
		alert('You must supply a First Name');
		document.loginform.fname.focus();
		return false;
		}
	if(document.loginform.lname.value == ''){
		alert('You must supply a Last Name');
		document.loginform.lname.focus();
		return false;
		}
	if(document.loginform.add1.value == ''){
		alert('You must supply a Street Name');
		document.loginform.add1.focus();
		return false;
		}
	if(document.loginform.city.value == ''){
		alert('You must supply a City');
		document.loginform.city.focus();
		return false;
		}
	if(document.loginform.prov.value == ''){
		alert('You must supply a Province');
		document.loginform.prov.focus();
		return false;
		}
	if(document.loginform.pc.value == ''){
		alert('You must supply a Postal Code');
		document.loginform.pc.focus();
		return false;
		}
	if(document.loginform.country.value == ''){
		alert('You must supply a Country');
		document.loginform.country.focus();
		return false;
		}
	if(document.loginform.phone2.value == ''){
		alert('You must supply a Phone Number');
		document.loginform.phone2.focus();
		return false;
		}
	if(document.loginform.email.value == ''){
		alert('You must supply an Email address');
		document.loginform.email.focus();
		return false;
		}
}
// END - editProfile //

function checkABC(f) 
	{
		// make sure the user only adds a numeric qty
		if(isNaN(f.addQty.value))
		{
			alert('Please provide a numeric Quantity');
			f.addQty.focus();
			return false;
		}
		
		// Make sure user enters only an int
		inputStr = f.addQty.value
		for (var i = 0; i < inputStr.length; i++)
		{
			var oneChar = inputStr.charAt(i)
			if (oneChar < "0" || oneChar > "9")
			 {
				alert('Please enter a proper Quantity');
				f.addQty.focus();
				return false;
			}
		}	
		
		var myqty = parseInt(f.addQty.value); // the quantity entered by the shopper
		var qty = parseInt(f.Qty.value); // the single unit quantity
		
		if (f.teired.value != 0)
		{
		
			var qty1 = parseInt(f.Qty1.value); // the first teir quantity
			var qty2 = parseInt(f.Qty2.value); //the second teir quantity
			
			if(f.teired.value == "1" && (myqty > 0 && myqty < qty1))
			{    // Quantity of 1
				f.addPrice.value = f.Price.value;
				//alert(document.form1.fprice.value);
			}
				
			else if(f.teired.value == "1" && (myqty >= qty1 && myqty < qty2))
			{   // Quantity of 1st teired
				f.addPrice.value = f.Price1.value;
				//alert(document.form1.fprice.value);
			}
				
			else if(f.teired.value == "1" && myqty >= qty2)
			{   // Quantity of 2nd teired
				f.addPrice.value = f.Price2.value;
				//alert(document.form1.fprice.value);
			}
		}
	}
	
	function checkABCMultiple(formName, numRows) 
	{
		// iterate through each subForm
		for (var x = 1; x < numRows+1; x++)
		{
			f = formName + x; // set the name of each subForm
			// make sure the user only adds a numeric qty
			if(isNaN(document.forms[f].addQty.value))
			{
				alert('Please provide a numeric Quantity');
				document.forms[f].addQty.focus();
				document.forms[f].addQty.select();
				return false;
			}
			
			// Make sure user enters only an int
			inputStr = document.forms[f].addQty.value
			for (var i = 0; i < inputStr.length; i++)
			{
				var oneChar = inputStr.charAt(i)
				if (oneChar < "0" || oneChar > "9")
				 {
					alert('Please enter a proper Quantity');
					document.forms[f].addQty.focus();
					document.forms[f].addQty.select();
					return false;
				}
			}	
			
			var myqty = parseInt(document.forms[f].addQty.value); // the quantity entered by the shopper
			var qty = parseInt(document.forms[f].Qty.value); // the single unit quantity
			
			if (document.forms[f].teired.value != 0)
			{
			
				var qty1 = parseInt(document.forms[f].Qty1.value); // the first teir quantity
				var qty2 = parseInt(document.forms[f].Qty2.value); //the second teir quantity
				
				if(document.forms[f].teired.value == "1" && (myqty > 0 && myqty < qty1))
				{    // Quantity of 1
					document.forms[f].addPrice.value = document.forms[f].Price.value;
					//alert(document.form1.fprice.value);
				}
					
				else if(document.forms[f].teired.value == "1" && (myqty >= qty1 && myqty < qty2))
				{   // Quantity of 1st teired
					document.forms[f].addPrice.value = document.forms[f].Price1.value;
					//alert(document.form1.fprice.value);
				}
					
				else if(document.forms[f].teired.value == "1" && myqty >= qty2)
				{   // Quantity of 2nd teired
					document.forms[f].addPrice.value = document.forms[f].Price2.value;
					//alert(document.form1.fprice.value);
				}
			}
		}
		return true;
	}
	
	
	// Init section
	   zakroma = "";
	   obj_float_div = false;
	   active_img_mark = null;
	   show_delay = null;
	   preloads = new Object;
	   gags = new Array;
	 
	   window.onerror = function() { return true; }
	   window.onload = function(e) { if (document.getElementById && document.createElement) tooltip.define(); }
	
	function run_after_body() {
	   document.write('<textarea id="gate_to_clipboard" style="display:none;"></textarea>');
	   document.onmousemove = document_onmousemove;
	   if (window.onscroll) window.onscroll = hide_div();
	   document.write('<div class="float" id="div_200" style="left: -3000px; background: #ffffff;"><img id="img_200" class="border_b" width="200" height="150"></div>');
	   setInterval("changer();",333);
	   for (var i = 4; i <= 4+7; i += 1)  {
		  var rnd_200 = i; rnd_200 = (rnd_200 < 10) ? '0' + rnd_200 : rnd_200;
		  preloads['loader_'+i] = new Image;
		  preloads['loader_'+i].src = zakroma + "/main/200x150/" + rnd_200 + ".gif";
		  preloads['loader_'+i].width = 200;
		  preloads['loader_'+i].height = 150;
	   }
	}
	
	function get_obj(id_name) {
	   if (document.getElementById) {
		  return document.getElementById(id_name);
	   } else if (document.all) {
		  return document.all[id_name];
	   } else {
		  return null;
	   }
	}
	
	function document_onmousemove(e) {
	
	   if ( !obj_float_div ) return;
	
	   var pos_X = 0, pos_Y = 0;
	   if ( !e ) e = window.event;
	   if ( e ) {
		  if ( typeof(e.pageX) == 'number' ) {
			 pos_X = e.pageX; pos_Y = e.pageY;
		  } else if ( typeof(e.clientX) == 'number' ) {
			 pos_X = e.clientX; pos_Y = e.clientY;
			 if ( document.body && ( document.body.scrollTop || document.body.scrollLeft ) && !( window.opera || window.debug || navigator.vendor == 'KDE' ) ) {
				pos_X += document.body.scrollLeft; pos_Y += document.body.scrollTop;
			 } else if ( document.documentElement && ( document.documentElement.scrollTop || document.documentElement.scrollLeft ) && !( window.opera || window.debug || navigator.vendor == 'KDE' ) ) {
				pos_X += document.documentElement.scrollLeft; pos_Y += document.documentElement.scrollTop;
			 }
		  }
	   }
	 
	   var scroll_X = 0, scroll_Y = 0;
	   if ( document.body && ( document.body.scrollTop || document.body.scrollLeft ) && !( window.debug || navigator.vendor == 'KDE' ) ) {
		  scroll_X = document.body.scrollLeft; scroll_Y = document.body.scrollTop;
	   } else if ( document.documentElement && ( document.documentElement.scrollTop || document.documentElement.scrollLeft ) && !( window.debug || navigator.vendor == 'KDE' ) ) {
		  scroll_X = document.documentElement.scrollLeft; scroll_Y = document.documentElement.scrollTop;
	   }
	 
	   var win_size_X = 0, win_size_Y = 0;
	   if (window.innerWidth && window.innerHeight) {
		  win_size_X = window.innerWidth; win_size_Y = window.innerHeight;
	   } else if (document.documentElement && document.documentElement.clientWidth && document.documentElement.clientHeight) {
		  win_size_X = document.documentElement.clientWidth; win_size_Y = document.documentElement.clientHeight;
	   } else if (document.body && document.body.clientWidth && document.body.clientHeight) {
		  win_size_X = document.body.clientWidth; win_size_Y = document.body.clientHeight;
	   }
	 
	   pos_X += 15; pos_Y += 15;
	 
	   if (obj_float_div.offsetWidth && obj_float_div.offsetHeight) {
		  if (pos_X - scroll_X + obj_float_div.offsetWidth + 5 > win_size_X) pos_X -= (obj_float_div.offsetWidth + 25);
		  if (pos_Y - scroll_Y + obj_float_div.offsetHeight + 5 > win_size_Y) pos_Y -= (obj_float_div.offsetHeight + 20);
	   }
	
	   obj_float_div.style.left = pos_X + "px"; obj_float_div.style.top = pos_Y + "px";
	 
	}
	
	function show_200(img_src,wp_id,img_w,img_h) {
	
	   if (show_delay) {
		  clearTimeout(show_delay); show_delay = null;
	   } else {
		  obj_float_div = get_obj('div_200');
		  show_delay = setTimeout('show_200("' + img_src + '","' + wp_id + '",' + img_w + ',' + img_h+ ');', 400);
		  return;
	   }
	   var img_mark = 'img_wp_id_' + wp_id;
	   active_img_mark = img_mark;
	   if (preloads[img_mark] && preloads[img_mark].complete) {
		  swap_img(img_mark);
	   } else {
		  var rnd_200 = Math.round(Math.random()*4) + 7;
		  swap_img('loader_' + rnd_200);
	   }
	   if ( ! preloads[img_mark] ) {
		  preloads[img_mark] = new Image;
		  preloads[img_mark].src = zakroma + img_src;
		  preloads[img_mark].width = img_w;
		  preloads[img_mark].height = img_h;
		  preloads[img_mark].onerror = function() { gag(preloads[img_mark],200); }
	   }
	   show_div('div_200');
	}
	
	function changer() {
	   if ( !obj_float_div || !preloads[active_img_mark] || !get_obj('img_200')) return;
	   if ( get_obj('img_200').src != preloads[active_img_mark].src && preloads[active_img_mark].complete ) swap_img(active_img_mark);
	}
	
	function swap_img(img_mark) {
	   var obj_base_img = get_obj('img_200');
	   if (!obj_base_img) return;
	   obj_base_img.src    = preloads[img_mark].src;
	   obj_base_img.width  = preloads[img_mark].width;
	   obj_base_img.height = preloads[img_mark].height;
	}
	
	function show_div(div_mark) {
	   if (show_delay) {
		  clearTimeout(show_delay); show_delay = null;
	   } else {
		  obj_float_div = get_obj(div_mark);
		  show_delay = setTimeout('show_div("' + div_mark + '");', 400);
		  return;
	   }
	   if ( ! obj_float_div ) return;
	   if (obj_float_div.offsetWidth) {
		  obj_float_div.style.width = "auto";
		  obj_float_div.style.height = "auto";
		  if (obj_float_div.offsetWidth > 300) obj_float_div.style.width = "300px";
	   }
	   document_onmousemove;
	   obj_float_div.style.visibility = 'visible';
	}
	
	function hide_div() {
	   //var rnd_200 = Math.round(Math.random()*4) + 7; swap_img('loader_' + rnd_200);
	   clearTimeout(show_delay); show_delay = null;
	   if ( ! obj_float_div ) return;
	   obj_float_div.style.visibility = 'hidden';
	   obj_float_div.style.left = "-3000px";
	   obj_float_div = false;
	}
	
	function append_to_div(div_mark,doc) {
	   var obj_box = get_obj(div_mark);
	   if ( obj_box && typeof(obj_box.innerHTML) == 'string' ) obj_box.innerHTML += doc;
	}
	
	function gag(object,type) {
	   if (gags[object.src]) return;
	   if (type == 100) {
		  object.src = zakroma + "/main/200x150/gag_100.gif";
		  object.height = 75; // для Opera
		  object.style.height = "75px"; // для Gecko, IE
	   } else {
		  object.src = zakroma + "/main/200x150/gag_200.gif";
		  object.height = 150;
		  object.style.height = "150px";
	   }
	   object.style.display = "block"; // для Gecko
	   gags[object.src] = true;
	}
	
	
	
// favView.cfm 	
function chkSelectUnselectAll(formName, objName, numItems)
{
	for(i=1; i<=numItems; i++)
	{
		tempFormName = formName + i;
		if (document.forms[tempFormName].elements[objName].checked == false)
			{document.forms[tempFormName].elements[objName].checked = true;}
		else
			{document.forms[tempFormName].elements[objName].checked = false;}
	}
	
}
	
function setSelectedItemsList(elementType, mainFormName, subformName, listContainerName, elementBoxName, numItems)
{
	// Determines which items have quantities and makes a list of those items in listContatiner object
	
	// elementType = is this a text or chkbox?
	// mainFormName = container for remove and add all to cart buttons
	// subformName = name of the inner looped form of each item
	// listContainerName = name of container where list is generated 
	// chkBoxName = name of checkboxes to determine which items are selected
	// numItems = number of items to process
	
	// Determine which items have to add 

	if (checkABCMultiple(subformName, numItems))
	{
		itemChecked = false;
		if (elementType == "text") tempValueQTYs = document.forms[mainFormName].elements["checkedItemsListQTYs"]; // the container for the list of QTYs
		tempValueIDs = document.forms[mainFormName].elements[listContainerName]; // the container for the list of item IDs
		
		for(i=1; i<=numItems; i++)
		{
			tempFormName = subformName + i; // name of each subForm
			continueCheck = false;
			
			// check for text or check box
			if (elementType == "chkbox") 
			{
				if (document.forms[tempFormName].elements[elementBoxName].checked == true)
				continueCheck = true; 
			}
			else if (elementType == "text")
				continueCheck = true; 
				
			// is there is a QTY or checked item to add
			if (continueCheck)
			{	
				itemChecked = true; // and item is checked
				if (tempValueIDs.value.length == 0)
					{
					// don't add comma on first iteration
					tempValueIDs.value = tempValueIDs.value + document.forms[tempFormName].elements["ID"].value;
					if (elementType == "text") tempValueQTYs.value = tempValueQTYs.value + document.forms[tempFormName].elements["addQty"].value;
					}
				else
					{
					// add comma for all succesive iternations
					tempValueIDs.value = tempValueIDs.value + ", " + document.forms[tempFormName].elements["ID"].value;
					if (elementType == "text") tempValueQTYs.value = tempValueQTYs.value + ", " + document.forms[tempFormName].elements["addQty"].value;
					}
			}
		}
		// If there are no items checked, then stop the submission and let the user know
		if (itemChecked == false)
		{
			alert('Please choose item(s) to add first');
			return false;
		}
		else
			return true;
	}
	return false;
}

// adding or updating items in cart
function setFAction(formName, action)
{
	// Changes the content of fAction to determine the action of the submitted form
	document.forms[formName].elements["fAction"].value = action;
	return true;
	
}