function istCheckChain(id) {

	var curSelect = document.getElementById(id);
	var NewId = id.replace('-b', '');
	
	if(!curSelect.checked) {
		document.getElementById(NewId).checked=false;
		document.getElementById(NewId+'-b').checked=false;
	} else {
		document.getElementById(NewId).checked=true;
		document.getElementById(NewId+'-b').checked=true;
	}
}

function istRemoveFromCompare(prefix) {
	/*
		Use jQuery Library to determine the browser
		in order to remove a column properly.
			options: safari, opera, msie, mozilla
	*/
	var istCheckedArray = new Array();
	var objChecks = document.getElementsByTagName('input');
	
	var jj = 0; // counter
	for(var i = 0; i < objChecks.length; i++){
		if(objChecks[i].type=='checkbox' && objChecks[i].id.indexOf('chkbxrm-')!=-1 && objChecks[i].id.indexOf('-b')==-1){
			if(objChecks[i].checked) {
				istCheckedArray[jj] = objChecks[i].id.replace('chkbxrm-', '');
				jj++;
			}
		}
	}
	
	// Get existing cookie
	var istCurrCookieStr = getCookie('istCompareIDs');
	
	var istCompareArray = istCurrCookieStr.split('|');		// if cookie exists, populate array with values
	
	for(var i = 0; i < istCheckedArray.length; i++) {
		var id = istCheckedArray[i];

		if($.browser.msie) {
			document.getElementById("col"+id).style.display="none";
		} else if($.browser.mozilla) {
			document.getElementById('col'+id).style.visibility='collapse';
		} else if($.browser.safari) {
			document.getElementById('col'+id).style.visibility='collapse';
			alert('Safari Browser: Need to verify function!!!');
		} else if($.browser.opera) {
			document.getElementById('col'+id).style.visibility='collapse';
			alert('Opera Browser: Need to verify function!!!');
		}
		
		// Delete ID form existing cookie values
		// Loop thru cookie value to determine if passed id's are in cookie
		for(var j = 0; j < istCompareArray.length; j++) {
			if(istCompareArray[j] == id) {
				istCompareArray.splice(j, 1);	// Delete array value and key if found
			}
		} // Close loop
	}
	// Create string of ID's to store in cookie
	istIdString = istCompareArray.join('|');
	
	// Set cookie with the selected ids
	setCookie('istCompareIDs', istIdString, '', '/', '', '');
}

function istCompareClearAll() {
	
	// Delete comparison cookie
	deleteCookie('istCompareIDs','/','');
	
	// close modal window
	// TODO
	
}

function istCompareShow(fileUrl) {
	/*
		Collect all Comparison checkboxes that are currently selected
	*/
	var jj = 0;
	var istIdString = '';
	var istAlreadyInArray = false;
	var istCompareArray = new Array();
	var istNewCompareArray = new Array();
	var istCheckedObjects = document.getElementsByName('istCompareChk'); // Grab all checkboxes

	// Get existing cookie
	var istCurrCookieStr = getCookie('istCompareIDs');
	
	// Create array of existing cookie values
	if(istCurrCookieStr) {
		var istCurrCompareArray = istCurrCookieStr.split('|');	// Temporary - used to verify cookie exists
		var istCompareArray = istCurrCookieStr.split('|');			// if cookie exists, populate array with values
		var tt = istCompareArray.length;
	}

	for(var i = 0; i < istCheckedObjects.length; i++) {
		
		// Box Checked ?
		if (istCheckedObjects[i].checked == true) {

			if(istCurrCompareArray) {
				
				// Cookie exists with current values
				for(var t = 0; t < istCurrCompareArray.length; t++) {
					if(istCurrCompareArray[t] == istCheckedObjects[i].value) {
						// Checked value exists in array, Don't add to array
						istAlreadyInArray = true;
						break;
					}
				}
				if(istAlreadyInArray == false) {
					// Add new value to Existing cookie array
					istCompareArray[tt] = istCheckedObjects[i].value;
					tt++;
				}
				
			} else {
				
				// No cookie exists, add values to new array
				istAlreadyInArray = false;
				istCompareArray[jj] = istCheckedObjects[i].value;
				
			}
			istAlreadyInArray = false;
			jj++;
		}
	}
	
	if (jj < 1) {
		// No boxes checked, throw error.
		alert('Please check one or more items you would like to compare. Click the compare link once your ready to compare.');
	} else if (jj == 1) {
		alert('Please select at least one other item to include in comparison.');
	}
	
	// Create string of ID's to store in cookie
	istIdString = istCompareArray.join('|');
	
	// Set cookie with the selected ids
	setCookie('istCompareIDs', istIdString, '', '/', '', '');
	
	//window.location = fileUrl+'/compare_data.php?height=-90&width=-90';
}

function displayCookieVals() {
	// Get cookie values
	var istCurrCookieStr = getCookie('istCompareIDs');
	
	// Create array of cookie values
	if(istCurrCookieStr) {
		var istCurrCompareArray = istCurrCookieStr.split('|');
		alert('Current Values: '+istCurrCompareArray);
	} else { alert('None Found!'); }
}

function showToolTip(obj, content) {
	obj.T_STICKY=true;
	obj.T_TEMP=3500;
	obj.T_SHADOWCOLOR='#ccaacc';
	obj.T_SHADOWWIDTH=4;
	return content;
}

function showToolTipImage(obj, filename) {
	obj.T_STICKY=true;
	obj.T_TEMP=3500;
	obj.T_SHADOWCOLOR='#ccaacc';
	obj.T_SHADOWWIDTH=4;
	content = '<img src=\'{$incUPLOADURL}/prod-full/'+filename+'\' border=\'0\'>';
	return content;
}


$(document).ready(function(){
	$("img.dropshadow").wrap("<div class='wrap1'><div class='wrap2'>" +
	"<div class='wrap3'></div></div></div>");
});


function doPrint() {
	$('controlsContainer').hide(); // [prototype] hides the page controls container
	$('controlsContainer2').hide(); // [prototype] hides the page controls container
	$('logoContainer').show(); // [prototype] show company logo
	self.focus();
	self.print();
}