
function addFilter(objName)
{
	var query = "";
	if (isObject(objName)){
		if (!objName.checked)
			query = "&"+objName.name+"=off";
	}
		return query;
}

function CleanString(ToCleanString)
{  
        var CleanedString = ToCleanString.replace(/^\s+|\s+$/g,"");        
        CleanedString = CleanedString.replace(/ and and /i, "and");
        return CleanedString;
}

function HasValue(NewValue)
{
	if (CleanString(NewValue) == '')
	{
		return false;
	}
	else
	{
		return true;
	}
	
}

function getCollection(objForm){
//alert();
	var collectionID = '';
	var sep = '';
	if (isObject(objForm.RMCollection)){
	
	for (i = 0; i < objForm.RMCollection.length; i++) {
		if (objForm.RMCollection[i].selected){
				collectionID += sep + objForm.RMCollection[i].value;
				sep = ','
		}	
	}
	for (i = 0; i < objForm.RFCollection.length; i++) {
		if (objForm.RFCollection[i].selected){
				collectionID += sep + objForm.RFCollection[i].value;
				sep = ','
		}	
	}
	}
	return collectionID;
}

function SwapLightBox(objVal) 
{
	var url;
	url = '../iframe_alterlightbox.asp?action=swap&slb='+objVal+'';
	setIFrame(url,'iframeUpdate');
}

function doSelect(objChecked, SelectName, assocObjName)
{
	if (SelectName != ''){
		var objSelect = eval('document.frm.'+SelectName+'');
		var len = objSelect.length;
		if (assocObjName != ''){
			var objAssoc =  eval('document.frm.'+assocObjName+'')
		}
	}
	if (objChecked){
		for (var i=0; i < len; i++) 
		{
			objSelect.options[i].selected = true;
			if (isObject(objAssoc))
			{
				objAssoc.checked= true;
			}
		}
	}else{
		for (var i=0; i < len; i++) 
		{
			objSelect.options[i].selected = false;
			if (isObject(objAssoc))
			{
				objAssoc.checked= false;
			}
		}
	}
}

function SetCheckBoxes(objSelect,strCheckBox) 
{
	var arrCheckBox = strCheckBox.split(",")
	var len = objSelect.length;
	var bUnSelected = false
	var bSelected = false
	
	for (var i=0;i<len;i++)
	{
		if (objSelect[i].selected)
		{
			bSelected = true
		}else{
			bUnSelected = true
		}
	}
	if (bUnSelected == true){
		for (var i=0;i<arrCheckBox.length;i++){
			eval('document.frm.'+arrCheckBox[i]+".checked= false")
		}	
	}
	if (bUnSelected == true && bUnSelected == true){
		eval('document.frm.'+arrCheckBox[0]+".checked= true")	
	}
	if (bSelected == true && bUnSelected == false){
		for (var i=0;i<arrCheckBox.length;i++){
			eval('document.frm.'+arrCheckBox[i]+".checked= true")
		}	
	}
}

function login(lib, img){
	document.frm.onsubmit="";
	document.frm.method ="post";
	document.frm.submit();
}

function show(val){
	var blnValue = false;
	if (val == 1) {
		blnValue = true;
	}
		document.frm.chkHorizontal.checked = blnValue;
		document.frm.chkVertical.checked=blnValue;
		document.frm.chkPanoramic.checked=blnValue;
		document.frm.chkSquare.checked=blnValue;
		document.frm.chkBW.checked=blnValue;
		document.frm.chkColor.checked=blnValue;
		document.frm.chkPhotograph.checked=blnValue;
		document.frm.chkIllustration.checked=blnValue;
}

function setImagesPerPage(){
	val = document.frm.ImagesPerPage[document.frm.ImagesPerPage.selectedIndex].value;
	url = window.location.href
	if (url.indexOf("ipps=") > 0){
		posAt = url.substr(url.indexOf("ipps="),url.length - url.indexOf("ipps="))
		if (url.indexOf("&") > 0){
			posAt = posAt.substr(0,posAt.length - posAt.indexOf("&")-1)
		}
		url = replaceSubstring(url,posAt,"ipps="+val)
		window.location.href = url;
	}else{
		if (url.indexOf("?") > 0){
			window.location.href = url + "&ipps="+val;
		}else{
			window.location.href = window.location.href + "?ipps="+val;
		}
	}
	return false;
}
