function CalcPicSize(PicID) 
{
    var ratio = document.images[PicID].height / document.images[PicID].width
    if (ratio==0.75) 
    {
		document.images[PicID].width = 405;
		document.images[PicID].height = 304;
    }
    else if (ratio < 0.75)
    {
		document.images[PicID].height = document.images[PicID].height * (405 / document.images[PicID].width);
		document.images[PicID].width = 405;
    }
    else
    {
		document.images[PicID].width = document.images[PicID].width * (304 / document.images[PicID].height);
		document.images[PicID].height = 304;
    }
    
};

function SelectDeselect()
// Selects or deselects checkboxs on search results form
{    
	if (document.all.SelectDeselectCheckBox.checked == true)
		SetChecks(true)
	else
		SetChecks(false);
}
/* The Check All and Uncheck All records on screen */			
function SetChecks(val){
var lngth = Checkboxes.IDList.length 
	if (lngth != null){
		for (var i = 0; i <lngth; i++) {
			if (val == true)
	 			Checkboxes.IDList[i].checked = true
			else
			{
				Checkboxes.IDList[i].checked = false;
				SetSelectNoSelect(Checkboxes.IDList[i].value);
			}
		}	
	}	
	
	if (lngth == null){
		if (val == true)
	 		Checkboxes.IDList.checked = true
		else
			Checkboxes.IDList.checked = false
	}
	SaveSelectedRecords()
}		

/* Save selected records */			
function SaveSelectedRecords(){
var lngth = Checkboxes.IDList.length 
/*	Checkboxes.RecordsIDList.value = 0 */
	if (lngth != null){
		for (var i = 0; i <lngth; i++) {
			if (Checkboxes.IDList[i].checked == true)
	 			Checkboxes.RecordsIDList.value=Checkboxes.RecordsIDList.value+','+Checkboxes.IDList[i].value
		}			
	}	
}


function SetSelectNoSelect(RecordID){   
var lngth = Checkboxes.IDList.length 
	if (lngth != null){
		for (var i = 0; i <lngth; i++) {
			if (Checkboxes.IDList[i].value == RecordID) 
			{
				if (Checkboxes.IDList[i].checked == true)
	 				Checkboxes.RecordsIDList.value=Checkboxes.RecordsIDList.value+','+Checkboxes.IDList[i].value
	 			else
	 			{
					Checkboxes.RecordsIDList.value = Checkboxes.RecordsIDList.value.replace(","+RecordID, "")	 			
	 			}
	 		}
		}			
	}	
}


/* Filter selected records */			
function FilterSelectedRecords(codeSource){
	/* Submit the form to refresh data
		alert(codeSource);*/
		var whereSQL = '';
		var selectedRecords = Checkboxes.RecordsIDList.value;
		Checkboxes.RecordsIDList.value="";
		if (selectedRecords != 0) {
			selectedRecords = selectedRecords.substring(1,selectedRecords.lenght);
			WhereSQL='TransID in(' + selectedRecords + ')';
			document.Checkboxes.action = codeSource + '?WhereSQL=' + WhereSQL;
			document.Checkboxes.target = '_self';
			Checkboxes.submit();
			document.Checkboxes.target = '_self';
		}

}		
/* Open a popup window with a picture send as a parameter, windows is openned with the picture size */
function PopupPic(sPicURL,widthx, heighty, topx,lefty,toolbarYN,resizableYN) 
{
	window.open("popuppicture.asp?"+sPicURL,"",'toolbar='+ toolbarYN + ',location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=' + resizableYN + ',copyhistory=no,width=' + widthx + ',height=' + heighty + ',screenX=100,screenY=100,top=' + topx + ',left=' + lefty + "'");
}
/* Open a popup window with a URL send as a parameter, windows is openned width=widthx, height=heighty, and from top=topx, left=lefty  */
function popupWindow(url,widthx, heighty, topx,lefty,toolbarYN,resizableYN) 
{
	windowHandle = window.open(url,"",'toolbar='+ toolbarYN + ',location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=' + resizableYN + ',copyhistory=no,width=' + widthx + ',height=' + heighty + ',screenX=100,screenY=100,top=' + topx + ',left=' + lefty + "'");
}

