// JavaScript Document

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}


function submitCompare(fundID,selName) {
	//document.getElementById('frmCompare').Fund1.value=fundID;
	//document.getElementById('frmCompare').submit();
	var obj = document.getElementById('frmCompare');
	//alert(fundID);
	if (fundID) {
		switch(trim(selName)){
			case 'fundCompare1':
			  obj.Fund1.value = fundID;
			  ajaxFunctionCompare('div-compare','Fund1='+obj.Fund1.value+'&Fund2='+obj.Fund2.value+'&Fund3='+obj.Fund3.value+'&Fund4='+obj.Fund4.value);
			  break    
			case 'fundCompare2':
			  ajaxFunctionCompare('div-compare','Fund1='+obj.Fund1.value+'&Fund2='+obj.Fund2.value+'&Fund3='+obj.Fund3.value+'&Fund4='+obj.Fund4.value);
			  break    
			case 'fundCompare3':
			  ajaxFunctionCompare('div-compare','Fund1='+obj.Fund1.value+'&Fund2='+obj.Fund2.value+'&Fund3='+obj.Fund3.value+'&Fund4='+obj.Fund4.value);
			  break    
			case 'fundCompare4':
			  ajaxFunctionCompare('div-compare','Fund1='+obj.Fund1.value+'&Fund2='+obj.Fund2.value+'&Fund3='+obj.Fund3.value+'&Fund4='+obj.Fund4.value);
			  break    
			default:
			  //code to be executed if n is
			  //different from case 1 and 2
		}
	}
	else {
		return false;
	}
}

function switchCross(id,table) {
	temp = document.getElementById(id);
	if(temp.src.match("contract")) {
		temp.src='/images/icons/expand.png';
		toggleDiv(table, false);
	}
	else {
		temp.src= '/images/icons/contract.png';
		toggleDiv(table, false);
	}
}


function toggleDiv(id, boolAll) {
	temp = document.getElementById(id).style;
	if (boolAll) {
		temp.visibility = 'visible';
		temp.display = 'block';
		temp.height = 'auto';
	} else {
		if (temp.visibility == 'visible') {
			temp.visibility = 'hidden';
			temp.display = 'none';
			temp.height= 'auto';
		}
		else {
			temp.visibility = 'visible';
			temp.display = 'block';
			temp.height = 'auto';
		}	
	}
}