
function openpopup (sURL)
{
//	window.open ('/' + sURL, 'PopupWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
	window.open ( sURL, 'PopupWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
};

function openpopupCustomName (sURL, sName)
{
//	window.open ('/' + sURL, 'PopupWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
	window.open ( sURL, sName, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
};


function openpopupSize (sURL, iWidth, iHeight)
{
	window.open (sURL, 'PopupWin', 'toolbar=no,location=no,directories=no,status=no, menubar=no, scrollbars=yes, resizable=no,height='+iHeight+',width='+iWidth);
};

function openCustomPopup (sURL, sParams)
{

	window.open (sURL, 'PopupWin', sParams);
};

function OpenWindow (sURL, sName, sParams, iWidth, iHeight)
{
	window.open (sURL, sName, sParams+',height='+iHeight+',width='+iWidth);
};


function openHelppopup (sURL)
{
	iWidth='340';
	iHeight='425';
	openpopupSize (sURL, iWidth, iHeight);

};

/*
if(!document.getElementById){
  if(document.all)
  document.getElementById=function(){
    if(typeof document.all[arguments[0]]!="undefined")
    return document.all[arguments[0]]
    else
    return null
  }
  else if(document.layers)
  document.getElementById=function(){
    if(typeof document[arguments[0]]!="undefined")
    return document[arguments[0]]
    else
    return null
  }
}
*/
//Multi-browser compatible function that returns a reference to any object in the page
function GetObject(strWindow, strObjectName,strParent)
{	
	var objItem;
	
	if (document.all)
		objItem = strWindow.document.all[strObjectName];
	else
	{
		objItem = strWindow.document.getElementById(strObjectName);
		if (objItem==null)
			objItem=strWindow.document.getElementsByName(strObjectName)[0];
		if (strWindow.document.getElementsByName(strObjectName).length>1)
			objItem=strWindow.document.getElementsByName(strObjectName);	
	}

	return (objItem);
};


function cOn(td,color)
{
	if(document.getElementById||(document.all && !(document.getElementById)))
		td.style.backgroundColor=color;
}

function cOut(td,color)
	{
	if(document.getElementById||(document.all && !(document.getElementById)))
		td.style.backgroundColor=color;
}

//Function that hides/shows the righr input box depending on selected country
function ShowStateList(CountryID)
{
	if(CountryID ==41) {	//canada
		GetObject(window,'canprovdiv','').style.display = "inline";
		GetObject(window,'usprovdiv','').style.display = "none";
		GetObject(window,'otherprovdiv','').style.display = "none";
	}
	else if(CountryID ==250) {	//USA
		GetObject(window,'canprovdiv','').style.display = "none";
		GetObject(window,'usprovdiv','').style.display = "inline";
		GetObject(window,'otherprovdiv','').style.display = "none";
	}
	else {
		GetObject(window,'canprovdiv','').style.display = "none";
		GetObject(window,'usprovdiv','').style.display = "none";
		GetObject(window,'otherprovdiv','').style.display = "inline";
	}
};

//More compatible ShowDiv and HideDiv functions
//Use these instead of the ones above
//										--Arbi
function HideDiv(strWindow, strDivID, strParent)
{
	objDIV = GetObject(strWindow, strDivID, strParent);
	if (typeof(objDIV) == 'object')
	{
		objDIV.style.display = "none";
		objDIV.style.visibility = "hidden";	
		
	}

};

function ShowDiv(strWindow, strDivID, strParent)
{
	objDIV = GetObject(strWindow, strDivID, strParent);
	//alert ('showdiv');
	if (typeof(objDIV) == 'object')
	{
		objDIV.style.display = "";
		objDIV.style.visibility = "visible";
	
	}
};

function ShowHideDiv(strWindow, strDivID, strParent)
{
	objDIV = GetObject(strWindow, strDivID, strParent);
	//alert(typeof(objDIV));
	if (typeof(objDIV) == 'object')
		if (objDIV.style.visibility=='visible')
			HideDiv (strWindow,strDivID,strParent) ;
		else
			ShowDiv (strWindow,strDivID,strParent) ;
};

function ChangeClass(id, newClass) 
{
	//alert (id);
	identity=document.getElementById(id);
	identity.className=newClass;

}

function ToggleRowSelect(ClickedClass, UnClickedClass, id)
{
	//alert (id.className);
	id=document.getElementById(id);
	//alert ("ClassName: "+id.className);
	if (id.className=ClickedClass)
	{
		//alert ("Clicked: "+id.className);
		ChangeClass(id, UnClickedClass);
	}
	else
	{
		//alert ("UnClicked");
		ChangeClass(id, ClickedClass);
	}
}


function uncheckall(FormID,Rows, UnClickedClass)
{
	for (i=0;i < Rows;i++)
	{
		if	(document["form_"+FormID]["repeat[]"][i].type=="checkbox")
		{
			document["form_"+FormID]["repeat[]"][i].checked=false;
			ChangeClass('ROW_'+FormID+i, UnClickedClass);
		}
	}
}

function checkone(FormID,item,ClickedClass, UnClickedClass)
{
	if	(document["form_"+FormID]["repeat[]"][item])
		identity = document["form_"+FormID]["repeat[]"][item];
	else
		identity = document["form_"+FormID]["repeat[]"];
	
		
	if	(identity.type=="checkbox")
	{ 
		if (identity.checked)
		{
			if	(document["form_"+FormID]["repeat[]"][item])
				document["form_"+FormID]["repeat[]"][item].checked=false;
			else
				document["form_"+FormID]["repeat[]"].checked=false;

			ChangeClass('ROW_'+FormID+item, UnClickedClass);
		}
		else
		{
			if	(document["form_"+FormID]["repeat[]"][item])
				document["form_"+FormID]["repeat[]"][item].checked=true;
			else
				document["form_"+FormID]["repeat[]"].checked=true;

			ChangeClass('ROW_'+FormID+item, ClickedClass);
		}
	 }
}

function SuperCheckOne(FormName, FormID,ItemName, ItemID, RowName, ClickedClass, UnClickedClass, ItemQty)
{
//	alert(FormName+FormID);
	//alert (RowName+FormID+ItemID);
	
	
	//if (identity.length == 0)
	if (document[FormName+FormID][ItemName][ItemID])
		identity = document[FormName+FormID][ItemName][ItemID];
	else
		identity = document[FormName+FormID][ItemName];
	
	if	(identity.type=="checkbox")
	{ 
		
		if (identity.checked)
		{
			if (document[FormName+FormID][ItemName][ItemID])
				document[FormName+FormID][ItemName][ItemID].checked=false;
			else
				document[FormName+FormID][ItemName].checked=false;
			ChangeClass(RowName+FormID+ItemID, UnClickedClass);
			document[FormName+FormID][ItemQty][ItemID].value=0;            
		}
		else
		{
			if (document[FormName+FormID][ItemName][ItemID])
				document[FormName+FormID][ItemName][ItemID].checked=true;
			else
				document[FormName+FormID][ItemName].checked=true;
			ChangeClass(RowName+FormID+ItemID, ClickedClass);
			if (document[FormName+FormID][ItemQty][ItemID].value==0)
				document[FormName+FormID][ItemQty][ItemID].value=1;            
	  
		}
	 }
}

function check(FormID,Rows, ClickedClass, UnClickedClass)
{
	for (i=0;i < Rows;i++)
	{

		if	(document["form_"+FormID]["repeat[]"][i].type=="checkbox")
		{ 
			if (document["form_"+FormID]["repeat[]"][i].checked)
			{
				document["form_"+FormID]["repeat[]"][i].checked=false;
				ChangeClass('ROW_'+FormID+i, UnClickedClass);
			}
			else
			{
				document["form_"+FormID]["repeat[]"][i].checked=true;
				ChangeClass('ROW_'+FormID+i, ClickedClass);
			}
		 }
	}

}

function checkall(FormID, Rows,ClickedClass)
{
	for (i=0;i < Rows;i++)
	{
		//HighlightRow(i, "ROW_"+i, ResetClass);
		//if	(document["form_"+FormID]["repeat[]"][i].type=="checkbox")
		if (document["form_"+FormID]["repeat[]"][i].type=="checkbox");
		{
			//document["form_"+FormID]["repeat[]"][i].checked=true;
			document["form_"+FormID]["repeat[]"][i].checked=true;
			ChangeClass('ROW_'+FormID+i, ClickedClass);
		}
	}
}	

