function ConfirmSubmit(label)
{
	var agree=confirm(label);
	if (agree)
		return true ;
	else
		return false ;
}
function entsub(event,ourform) 
{
  if (event && event.which == 13)
    ourform.submit();
  else
    return true;
}
function formatCurrency(num) 
{
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
		num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
		cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+' '+num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num + ',' + cents);
}
function HideShowDiv(whichDivId,attribute)
{
	//alert('HideShowDiv');
	if (document.all) 
	{ //IS IE 4 or 5 (or 6 beta)
		eval( "document.all." + whichDivId + ".style.visibility = attribute;");
	}
	if (document.layers) 
	{ //IS NETSCAPE 4 or below
		document.layers[whichDivId].visibility = attribute;
	}
	if (document.getElementById && !document.all) 
	{
		theDiv = document.getElementById(whichDivId);
		theDiv.style.visibility = attribute;
	}
}
//
// THIS FUNCTION WILL CHANGE IN PRODUCT DETAIL PAGE
// SUB SECTION CONTENT
//
function ChangeProductSection(pdid,ctsid,lid)
{
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	//alert('123');
	
	var fnWhenDone = function (oXML) {
		//alert(ctsid);
		//document.getElementById('debug').value = oXML.responseText; 
		document.getElementById('ProductDetailSubContent_ZoneId').innerHTML = oXML.responseText;
		//document.getElementById('L_PRODUCT_DETAIL_SUB_MENU_DESCRIPTION').style.color = '#3b2910';
		document.getElementById('L_PRODUCT_DETAIL_SUB_MENU_INDICATION').style.color = '#3b2910';
		document.getElementById('L_PRODUCT_DETAIL_SUB_MENU_DOSAGE').style.color = '#3b2910';
		document.getElementById('L_PRODUCT_DETAIL_SUB_MENU_WARNING').style.color = '#3b2910';
		document.getElementById('L_PRODUCT_DETAIL_SUB_MENU_NOTES').style.color = '#3b2910';				
		document.getElementById(ctsid).style.color = '#3c6a00';
		
	};
	myConn.connect("includer_ajax.php", "GET", "sid=catalogue&pid=product&pdid="+pdid+"&ctsid="+ctsid+"&lid="+lid, fnWhenDone);	
}
//
// THIS FUNCTION WILL CHANGE IN PRODUCT CATEGORY LISTING
// FULL OR SHORT, DESCRIPTION
//
function ChangeCategoryListingDescription(pcid,lid,isFull,maxChar)
{
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	//alert('123');
	
	var fnWhenDone = function (oXML) {
		//alert(ctsid);
		//document.getElementById('debug').value = oXML.responseText; 
		document.getElementById('ProductCategoryDescription_'+pcid+'_div').innerHTML = oXML.responseText;
	};
	myConn.connect("includer_ajax.php", "GET", "sid=catalogue&pid=categories&pcid="+pcid+"&isFull="+isFull+"&maxChar="+maxChar+"&lid="+lid, fnWhenDone);	
}
function ChangeFAQDescription(faqid,lid,isFull)
{
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	//alert('123'+faqid);
	
	var fnWhenDone = function (oXML) {
		//alert(ctsid);
		//document.getElementById('debug').value = oXML.responseText; 
		document.getElementById('FAQ_'+faqid+'_div').innerHTML = oXML.responseText;
	};
	
	myConn.connect("includer_ajax.php", "GET", "sid=faq&pid=content&faqid="+faqid+"&isFull="+isFull+"&lid="+lid, fnWhenDone);	
}
function ChangeReferenceDescription(refid,maxChar,isFull)
{
	/*
	alert(refTxt);
	document.getElementById('ReferencesBook'+refid).innerHTML = refTxt;
	*/
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	
	var fnWhenDone = function (oXML) {
		//alert( oXML.responseText);
		//document.getElementById('debug').value = oXML.responseText; 
		document.getElementById('ReferencesBook'+refid).innerHTML = oXML.responseText;
	};
	
	myConn.connect("includer_ajax.php", "GET", "sid=references&pid=content&refid="+refid+"&isfull="+isFull+"&maxchar="+maxChar, fnWhenDone);	
}

function AddInputType(fieldCounterId,fieldsDivId,fieldName,inputType,attribute)
{
	var fieldCursor = 1;
	if(document.getElementById(fieldCounterId))
		fieldCursor = Number(document.getElementById(fieldCounterId).value)+1;
		
	document.getElementById(fieldCounterId).value = fieldCursor;
	var retTxt = "";//document.getElementById(fieldsDivId).innerHTML;
	for(var i=1;i<=fieldCursor;i++)
	{	
		retTxt = retTxt + "<input type='" + inputType + "' name='" + fieldName +"["+(fieldCursor*-1)+"]'" + attribute  + "><br>";
	}
	document.getElementById('debug').value = retTxt;
	document.getElementById(fieldsDivId).innerHTML = retTxt;
}
function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}
function CheckUnCheckAllFields(theForm,field,isChecked) 
{
	var fieldNameLength = field.length;
	var tmpCompareString = "";
	for(var i=0; i < theForm.elements.length; i++)
	{
		tmpCompareString = theForm.elements[i].name.substring(0,fieldNameLength);
		if(theForm.elements[i].disabled == false && theForm.elements[i].type=="checkbox" && tmpCompareString == field)
		{
			theForm.elements[i].checked=isChecked;
		}
	}	
}

/*
function formData2QueryString(docForm) {

        var strSubmit       = '';
        var formElem;
        var strLastElemName = '';
        
        for (i = 0; i < docForm.elements.length; i++) {
                formElem = docForm.elements[i];
                switch (formElem.type) {
                        // Text, select, hidden, password, textarea elements
                        case 'text':
                        case 'select-one':
                        case 'hidden':
                        case 'password':
                        case 'textarea':
                                strSubmit += formElem.name + 
                                '=' + escape(formElem.value) + '&'
                        break;
                        default:
                        
                        break;
            	}
        }
}
*/