/**
* This fuction is used to validate email address 
*
* @access   public
* @param    null
*           
* @return   null
*/

function checkEmail(str) 
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str))
	{
		return (true)
	}
	alert("Invalid E-mail Address! Please Enter valid E-mail Address.");
	return (false)
}


/**
* This fuction is used to save  Connect Details 
*
* @access   public
* @param    null
*           
* @return   null
*/
function saveConnect()
{
	if(connectValidation())
	{
		document.getElementById("action").value="SaveConnect";
        document.getElementById("pageform").submit();		
	}
}

/**
* This fuction is used to validate Connect form
*
* @access   public
* @param    null
*           
* @return   true / false
*/

function connectValidation()
{
	if(document.getElementById("name").value.match(/^ *$/))	
	{
		alert("Please enter your name");
		document.getElementById("name").focus();
		return;
	}
	
	else if(document.getElementById("title").value.match(/^ *$/))	
	{
		alert("Please enter the title.");
		document.getElementById("title").focus();
		return;
	}

	else if(document.getElementById("company").value.match(/^ *$/))	
	{
		alert("Please enter the company.");
		document.getElementById("company").focus();
		return;
	}

	else if(document.getElementById("address").value.match(/^ *$/))	
	{
		alert("Please enter the address.");
		document.getElementById("address").focus();
		return;
	}

	else if(document.getElementById("city").value.match(/^ *$/))	
	{
		alert("Please enter the city.");
		document.getElementById("city").focus();
		return;
	}

	else if(document.getElementById("state").value.match(/^ *$/))	
	{
		alert("Please enter the state.");
		document.getElementById("state").focus();
		return;
	}

	else if(document.getElementById("zip").value.match(/^ *$/))	
	{
		alert("Please enter the zipcode.");
		document.getElementById("zip").focus();
		return;
	}

	else if(checkEmail(document.getElementById("email").value)!=true)
	{
		//alert("*Invalid E-mail Address! Please Enter valid E-mail Address.");
		document.getElementById("email").value='';
		document.getElementById("email").focus();
		return;
	}
	
	else if(document.getElementById("phone").value.match(/^ *$/))	
	{
		alert("Please enter the phone.");
		document.getElementById("phone").focus();
		return;
	}

	else if(document.getElementById("comment").value.match(/^ *$/))	
	{
		alert("Please enter your comments.");
		document.getElementById("comment").focus();
		return;
	}
	
	return true;
}


/**
* This fuction is used to save  FreeTrial Details 
*
* @access   public
* @param    null
*           
* @return   null
*/
function saveFreeTrial()
{
	if(freeTrialValidation())
	{
		document.getElementById("action").value="SaveFreeTrial";
        document.getElementById("pageform").submit();		
	}
}




/**
* This fuction is used to validate FreeTrial form
*
* @access   public
* @param    null
*           
* @return   true / false
*/

function freeTrialValidation()
{
	if(document.getElementById("name").value.match(/^ *$/))	
	{
		alert("Please enter your name");
		document.getElementById("name").focus();
		return;
	}
	
	else if(document.getElementById("title").value.match(/^ *$/))	
	{
		alert("Please enter the title.");
		document.getElementById("title").focus();
		return;
	}

	else if(document.getElementById("company").value.match(/^ *$/))	
	{
		alert("Please enter the company.");
		document.getElementById("company").focus();
		return;
	}

	else if(document.getElementById("address").value.match(/^ *$/))	
	{
		alert("Please enter the address.");
		document.getElementById("address").focus();
		return;
	}

	else if(document.getElementById("city").value.match(/^ *$/))	
	{
		alert("Please enter the city.");
		document.getElementById("city").focus();
		return;
	}

	else if(document.getElementById("state").value.match(/^ *$/))	
	{
		alert("Please enter the state.");
		document.getElementById("state").focus();
		return;
	}

	else if(document.getElementById("zip").value.match(/^ *$/))	
	{
		alert("Please enter the zipcode.");
		document.getElementById("zip").focus();
		return;
	}

	else if(checkEmail(document.getElementById("email").value)!=true)
	{
		//alert("*Invalid E-mail Address! Please Enter valid E-mail Address.");
		document.getElementById("email").value='';
		document.getElementById("email").focus();
		return;
	}
	
	else if(document.getElementById("phone").value.match(/^ *$/))	
	{
		alert("Please enter the phone.");
		document.getElementById("phone").focus();
		return;
	}
	else if(document.getElementById("budget").value.match(/^ *$/))	
	{
		alert("Please enter budget.");
		document.getElementById("budget").focus();
		return;
	}

	else if(document.getElementById("goals").value.match(/^ *$/))	
	{
		alert("Please enter goals.");
		document.getElementById("goals").focus();
		return;
	}
	else if(document.getElementById("asset1").value.match(/^ *$/))	
	{
		alert("Please enter asset1.");
		document.getElementById("asset1").focus();
		return;
	}
	else if(document.getElementById("asset2").value.match(/^ *$/))	
	{
		alert("Please enter asset2.");
		document.getElementById("asset2").focus();
		return;
	}

	else if(document.getElementById("comment").value.match(/^ *$/))	
	{
		alert("Please enter your comments.");
		document.getElementById("comment").focus();
		return;
	}
	
	return true;
}

function viewEvents()
{
	document.getElementById("news").style.display="none";
	document.getElementById("events").style.display="";
}

function viewNews()
{
	document.getElementById("events").style.display="none";
	document.getElementById("news").style.display="";
}

function displayFreeTrial()
{
	document.getElementById("freeTrial01").style.display="";
}
function hideFreeTrial()
{
	document.getElementById("freeTrial01").style.display="none";
}

/**
* This fuction is used to Search Details 
*
* @access   public
* @param    null
*           
* @return   null
*/
function search()
{
	if(searchValidation())
	{
		document.getElementById("action").value="Search";
		document.getElementById("pageform").submit();
	}  		
}

function searchValidation()
{
	if(document.getElementById("txtsearch").value.match(/^ *$/))	
	{
		alert("Please enter your search text.");
		document.getElementById("txtsearch").focus();
		return;
	}
	else if(document.getElementById("txtsearch").value.toLowerCase()=='search')
	{
		alert("Please enter your search text.");
		document.getElementById("txtsearch").focus();	
		return;
	}

	return true;
}

/**
* This fuction is used to Search Box Details 
*
* @access   public
* @param    null
*           
* @return   null
*/
function searchbox()
{
//alert('df')
	
	if(searchboxValidation())
	{
		document.getElementById("action").value="Search";
		document.getElementById("txtsearch").value=document.getElementById("txtsearchbox").value;
	    document.getElementById("pageform").submit();		
	}

	
}
/**
* This fuction is used to Search Box Validation 
*
* @access   public
* @param    null
*           
* @return   null
*/
function searchboxValidation()
{
	if(document.getElementById("txtsearchbox").value.match(/^ *$/))	
	{
		alert("Please enter your search text.");
		document.getElementById("txtsearchbox").focus();
		return;
	}
	else if(document.getElementById("txtsearchbox").value.toLowerCase()=='search')
	{
		alert("Please enter your search text.");
		document.getElementById("txtsearchbox").focus();
		return;
	}

	return true;
}

/**
* This fuction is used to Search Result 
*
* @access   public
* @param    null
*           
* @return   null
*/
function resultpage(s,e)
{
  rtotal=document.getElementById("noresult").value;
  //alert(rtotal+'d');

   document.getElementById("pagerelsut").style.display="block";

   if(rtotal==0)document.getElementById("pagerelsut").style.display="none";

  for(i=0;i<rtotal;i++)
  {
    document.getElementById("sreslut"+i).style.display="none";
  }
   if(rtotal<=e)e=rtotal;

  j=s;

  if(s==0)j=1;

  for(i=j-1;i<e;i++)
  {
    document.getElementById("sreslut"+i).style.display="block";
  }
   i=e+1;
   j=i+6;
   if(rtotal<=j)j=rtotal;
   document.getElementById("startend").innerHTML=s +" - "+ e ;

   document.getElementById("resultnext").innerHTML="<a href=\"javascript:resultpage("+i+","+j+")\">Next</a>";

   document.getElementById("resultnext").style.display="block";
  

   if(rtotal<=i)document.getElementById("resultnext").style.display="none";
 //alert(s);
}
