function toggledisplay_worker(asElement,asDisplay)
{
	document.getElementById(asElement).style.display = asDisplay;
}
function toggledisplay(asElement,asDisplay)
{
	return function(e) { 
    toggledisplay_worker(asElement,asDisplay); 
	}
}

function checkSearch(f) {
	if (!f.value.match(/\S/)) {
		alert("Please enter a valid keyword");
		f.focus();
		return (false);
	}
	return (true);
}

function checkSearchPoints(f) {
	if (f.value.match(/\XX/)) {
		alert("Please choose a points category to search for.");
		f.focus();
		return (false);
	}
	return (true);
}

function checkSearchCategory(f) {
	if (f.value.match(/\XX/)) {
		alert("Please choose a product category to search for.");
		f.focus();
		return (false);
	}
	return (true);
}


function doclear(){
	if(document.searchForm.search.value=='Search'){
		document.searchForm.search.value = '';
	}
}
function showalternate(obj,image){
	if (obj.src != image){
	obj.src=image
	}
}

function displayrentoptions(vValue){
/*	if(vValue == "Rent Reminder - Email" || vValue == "Rent Reminder - Email and SMS"  || vValue == "Email"){
		document.getElementById("email_mandatory").innerText = '*';	
		document.getElementById("email_mandatory").style.display='inline';
	}else{
		document.getElementById("email_mandatory").style.display='none';		
	}
*/
	if(vValue == "Rent Reminder - SMS" || vValue == "Rent Reminder - Email and SMS" || vValue == "SMS"){
		document.getElementById("mobile_mandatory").innerText = '*';	
		document.getElementById("mobile_mandatory").style.display='inline';	
	}else{
		document.getElementById("mobile_mandatory").style.display='none';	
	}
}

function DisplayPaymentType(asValue)
{
	lsDisplay = (asValue == 'Bank Account')?'none':'inline';
	if(asValue == 'Bank Account')
	{
		document.getElementById('BA').style.display = 'inline';
	}
	else
	{
		document.getElementById('BA').style.display = 'none';
	}
	
	document.getElementById("creditcard_details").style.display = lsDisplay;
	
	
	document.getElementById("bank_account_change").style.display = (asValue=='Bank Account')?'inline':'none';
	if (asValue != 'Bank Account')
	{
		document.getElementById("AccountBSB").value = '';
		document.getElementById("AccountNumber").value = '';
		document.getElementById("AccountName").value = '';
	}
	else
	{
		document.getElementById("ExpiryDateexpmon").selectedIndex  = 0;
		document.getElementById("ExpiryDateexpyear").selectedIndex = 0;
		document.getElementById("NameOnCard").value = '';
		document.getElementById("ccn").value = '';
	}
}

function DisplayPaymentAgreementType(asValue)
{
	lsDisplay = (asValue == 'Bank Account')?'none':'inline';
	document.getElementById("creditcard_details").style.display = lsDisplay;
	if (asValue == 'Bank Account') {	
		document.getElementById("creditcard_info").style.display = lsDisplay;
	}
//	document.getElementById("agreement").style.display = lsDisplay;
//	document.getElementById("tenant_terms").style.display = lsDisplay;
	document.getElementById("bank_account_change").style.display = (asValue=='Bank Account')?'inline':'none';
	
	if (asValue == 'Bank Account')
	{
		document.getElementById("ExpiryDateexpmon").selectedIndex  = 0;
		document.getElementById("ExpiryDateexpyear").selectedIndex = 0;
		document.getElementById("NameOnCard").value = '';
		document.getElementById("ccn").value = '';
	
	}
}


function displayrentoptionschange(vValue){
	if(vValue == "Rent Reminder - SMS" || vValue == "Rent Reminder - Email and SMS"){
		document.getElementById("mobile_mandatory").innerText = '*';	
		document.getElementById("mobile_mandatory").style.display = 'inline';	
	}else{
		document.getElementById("mobile_mandatory").style.display='none';	
	}
}

function displayreferaloptions(vValue){
	if(vValue != "Agent Enquiry"){
		document.getElementById("WorkPhone_mandatory").style.display='none';	
		document.getElementById("FullName_mandatory").style.display='none';	
		
	}else{
		document.getElementById("WorkPhone_mandatory").style.display='inline';
		document.getElementById("FullName_mandatory").style.display='inline';	 
	}
}

function closePopupWindow(sParentURL)
{
	// checks to see if link is in a window or popup
	// yes, then window is closed and the opening page is redirected
	// no, then the page is redirected
	if (opener)
	{
		window.close();
		opener.location.href = sParentURL;
	}
	else
	{
		location.href = sParentURL;
	}
}

function fadeclose(id) {
	var object = document.getElementById(id)
    var speed = Math.round(500 / 50);
    var timer = 0;	
	var height = object.clientHeight;
	object.style.overflow = 'hidden';
    for(i = 100; i > -1; i--) {
        setTimeout("changeOpac(" + i + ",'" + id + "'," + height + ")",(timer * speed));
        timer++;
    }
}

function changeOpac(opacity, id,height) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
	object.height = (height * (opacity / 100)) + "px";
	object.display = (opacity == 0)?'none':'block';
}


