function fn_showlinks(obj)
{
	objweb = 'web'+ obj
	objpalm = 'palm'+ obj
	if(document.all[objweb])
	{
		if(document.all[objweb].style.display == '')
		{
			document.all[objweb].style.display='none'
			document.all[objpalm].style.display='none'		
		}
		else
		{
			document.all[objweb].style.display=''
			document.all[objpalm].style.display=''			
		}
	}	
}

function fn_winopen(url)
{
	X=window.open(url,'','status=yes,toolbar=no,menu=no,resizable=yes,address=no,scrollbars=yes,top=15,left=5,width='+(screen.width-20)+',height='+(screen.height-100),true)
	X.focus();
}

function fn_href(url)
{
	window.location.href = url;	
}
function fn_alert()
{
	window.location.href = "asppages/undercon.asp"
}

function fn_faq()
{
	self.location.href = "asppages/faq.asp"
}

function fn_changebkg(id)
{
	id = event.srcElement.parentElement.id;
	
	if (id == "")
		return;
	if (event.type == "mouseout")
	{
		if(window.document.all[id])
		{
			window.document.all[id].style.backgroundColor = "";
		}	
		return;
	}	
	if (event.type == "mouseover")
	{
		if(window.document.all[id])
		{
			window.document.all[id].style.backgroundColor = "#C6C6C6";
		}	
	}	
	return;
		
}//end fn_changebkg
	
	
function fn_productfeature()
{
	window.location.href = "asppages/prodfeatures.asp"
}
	
if (window.document.all['cellprod'])	
{
	window.document.all['cellprod'].attachEvent('onmouseover',fn_changebkg)	
	window.document.all['cellprod'].attachEvent('onmouseout',fn_changebkg)	
}	
if (window.document.all['cellservices'])	
{
	window.document.all['cellservices'].attachEvent('onmouseover',fn_changebkg)	
	window.document.all['cellservices'].attachEvent('onmouseout',fn_changebkg)	
}	
if (window.document.all['cellquicktour'])	
{
	window.document.all['cellquicktour'].attachEvent('onmouseover',fn_changebkg)	
	window.document.all['cellquicktour'].attachEvent('onmouseout',fn_changebkg)	
}	
	
if (window.document.all['cellprodfeature'])	
{
	window.document.all['cellprodfeature'].attachEvent('onmouseover',fn_changebkg)	
	window.document.all['cellprodfeature'].attachEvent('onmouseout',fn_changebkg)	
}	

if (window.document.all['cellonlinedemo'])	
{
	window.document.all['cellonlinedemo'].attachEvent('onmouseover',fn_changebkg)	
	window.document.all['cellonlinedemo'].attachEvent('onmouseout',fn_changebkg)	
}	

if (window.document.all['celluserguide'])	
{
	window.document.all['celluserguide'].attachEvent('onmouseover',fn_changebkg)	
	window.document.all['celluserguide'].attachEvent('onmouseout',fn_changebkg)	
	//window.document.all['celluserguide'].attachEvent('onclick',fn_alert)	
}

if (window.document.all['celltour'])	
{
	window.document.all['celltour'].attachEvent('onmouseover',fn_changebkg)	
	window.document.all['celltour'].attachEvent('onmouseout',fn_changebkg)	
}

if (window.document.all['cellfaq'])	
{
	window.document.all['cellfaq'].attachEvent('onmouseover',fn_changebkg)	
	window.document.all['cellfaq'].attachEvent('onmouseout',fn_changebkg)	
}

if (window.document.all['cellcontact'])	
{
	window.document.all['cellcontact'].attachEvent('onmouseover',fn_changebkg)	
	window.document.all['cellcontact'].attachEvent('onmouseout',fn_changebkg)	
	//window.document.all['cellcontact'].attachEvent('onclick',fn_contactus)	
}

if (window.document.all['cellabout'])	
{
	window.document.all['cellabout'].attachEvent('onmouseover',fn_changebkg)	
	window.document.all['cellabout'].attachEvent('onmouseout',fn_changebkg)
	//window.document.all['cellabout'].attachEvent('onclick',fn_aboutus)		
}

//Donot delete this line
	self.name = 'visuallease'


function fn_signout()
{
	
	if (!(fn_popupsavewindow('signout')))
	{
		if (!(window.parent.location.href.search("asppages/" + "signout.asp") > 0))
			window.parent.location.href = "asppages/" + "signout.asp"
	}		
	return;
}



function fn_home()
{
	
	if (!(fn_popupsavewindow('home')))
		window.parent.location.href = "" + "default.asp"
		
	return; 	
}


function fn_popupsavewindow(str)
{
	name="visualleasesave"
	form_name = window.document.forms(0);
	
	if (window.parent.location.href.search("main.asp") > 0 ) 
	{	
		rightframeformname = window.parent.frames[2].document.forms(0).name
		
		if(rightframeformname == "frmfinancials" || rightframeformname == "frmgeneralmenu")
		{
			if (form_name.hdynchanged_grid.value == "true" || form_name.hdyncommentschanged.value == "true" || form_name.hdyngenmenuchanged.value == "true")
			{
				//val_leaseid = form_name.hdleaseid.value;
				if(window.parent.frames[2].document.forms[0].hdleaseinst)
					val_leaseinst = window.parent.frames[2].document.forms[0].hdleaseinst.value;
				//val_buildingname = window.parent.frames.main.document.forms(0).txtbuildingname.value
				url = "save.asp?hdleaseinst="+val_leaseinst;
				url = url + "&showpage=" + str;
				var_width=430;
				var_height=215;
				var_left=180;
				var_top=180;
				fn_showlookup(6,url,var_left,var_top,var_height,var_width,name)
				return true;
			}	
			else
				return false;
		}
	}
	return false;	
}

function fn_generalinformation(id)
{
	form_name = window.document.forms(0);
	window.parent.frames[1].fn_openmenu('m1lease');  //to expand the left frame menu
	window.parent.frames[1].fn_openmenu('m2currentlease'); //to expand the left frame menu
	switch (id)
		{
			case "hrfgeneralinfo":
				window.parent.frames.main.location.href = "mainright_generalinfo.asp?leaseinst="+''
				window.parent.frames[1].fn_openmenu('m3general'); //to expand the left frame menu
				break;
			case "hrflandlord":
				window.parent.frames.main.location.href = "mainright_generallandlord.asp?leaseinst="+''
				window.parent.frames[1].fn_openmenu('m3general');
			    break;
			case "hrffinancial":    
				curr_txtcurrent = 
				form_name.hdcurryearandposition.value  = window.parent.frames.main.location.href="mainright_financials.asp?leaseinst="+''+"&leaseid="+''+"&txtcurrent="+curr_txtcurrent;
				window.parent.frames[1].fn_openmenu('m3financials'); //to expand the left frame menu
				break;
		}
}



function validateonsubmit()
{	
	form_name=document.forms[0]
	var i;
	for(i=0 ; i<= form_name.elements.length -1; i++)
	{
		if(form_name.elements[i].className=="Country")
		{
				if(form_name.elements[i].value == "Please Select")
				{
					alert('Please select your Country.' );
					form_name.elements[i].focus();
					return false;
				}
		}				
		
		if(form_name.elements[i].className=="Phone")
		{
				if( !isnum(form_name.elements[i]))
				{
					alert(form_name.elements[i].objname + ' should be integer only');
					form_name.elements[i].value=""
					form_name.elements[i].focus();										
					return false;
				}
		}



		if(form_name.elements[i].className=="Phone")
		{
				if(form_name.elements[i].value.length == 0)
				{
					alert(form_name.elements[i].objname +' is required');
					form_name.elements[i].focus();
					return false;
				}
		}		

		if(form_name.elements[i].className=="notnull")
		{
				if(form_name.elements[i].value.length == 0)
				{
					alert(form_name.elements[i].objname +' is required');
					form_name.elements[i].focus();
					return false;
				}
		}		
		
		if(form_name.elements[i].className=="alphanumeric")
		{
				reg = /^(\w)$/gi;				
				if(form_name.elements[i].value.length == 0)
				{
					alert(form_name.elements[i].objname +' is required');
					form_name.elements[i].focus();
					return false;
				}
				else if(!reg.test(form_name.elements[i].value))
				{
					alert(form_name.elements[i].objname +' should be of letters and numbers');
					form_name.elements[i].focus();
					return false;					
				}
		}				

		if(form_name.elements[i].className=="alphabetic")
		{
				reg = /^([a-z]{1,})$/gi;				
				if(form_name.elements[i].value.length == 0)
				{
					alert(form_name.elements[i].objname +' is required');
					form_name.elements[i].focus();
					return false;
				}
				else if(!reg.test(form_name.elements[i].value))
				{
					alert(form_name.elements[i].objname +' should consist only alphabets');
					form_name.elements[i].focus();
					return false;					
				}
		}				


		
		if(form_name.elements[i].className == "zip")
		{
				if(form_name.elements[i].value.length == 0)
				{
					alert(form_name.elements[i].objname +' is required');
					form_name.elements[i].focus();
					return false;
				}
				else 
				{
					reg = /(\d{1,})/g; 
					reg1 = /(-)/g;
					for(j=0;j<=form_name.elements[i].value.length-1;j++)
					{
						if(reg.test(form_name.elements[i].value.substring(j,j+1)) == false && reg1.test(form_name.elements[i].value.substring(j,j+1)) == false)			
						{
							alert(form_name.elements[i].objname +' should be numbers only');
							form_name.elements[i].focus();
							return false;					
						}	
					}	
				}
		}						

		if(form_name.elements[i].className=="integer")
		{
				if( !isnum(form_name.elements[i]))
				{
					alert(form_name.elements[i].objname + ' should be integer only');
					form_name.elements[i].value=""
					form_name.elements[i].focus();										
					return false;
				}
		}


		if( (form_name.elements[i].className=="requiredemail") || (form_name.elements[i].className=="email") )
		{
			if  ( (form_name.elements[i].value=="") && (form_name.elements[i].className=="requiredemail") ) 
			{
				alert(form_name.elements[i].objname+ ' is required');
				form_name.elements[i].focus();
				return false;
			}			
			var eadd=form_name.elements[i].value;
			if (eadd.length != 0 )
			{
				if ((eadd.indexOf("@",1) == -1) || (eadd.indexOf(".",1) == -1) )
				{
				  alert(form_name.elements[i].objname+ ' should be a valid Email ID');	
				  form_name.elements[i].focus();				
				  return false;												 	
				}			
			}
		}
	}

	form_name.method = "Post"
	form_name.submit()
 	return true;
}


//************
function isnum(the)
{
  var checkOK = "0123456789";
  var checkStr = the.value;
  var allValid = true;
  var allNum = "";
  
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
        
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {    
    return (false);
  }
  return (true);
}

