// JavaScript Document

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


// clear input value

function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}


// Validate form

function validate_form(form)
{
you = form.realname.value;
two = form.email.value;


if(you == "")
{
   alert("Please enter your full name in the name field.");
   return false;
}

if(!checkemail(form))
{
   return false;
}

return true;
}


function checkemail(formincoming)
{
	var str=formincoming.email.value
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
	{
		return true;
	}
	else
	{
		alert("Please enter a valid email address.");
		return false
	}

}


 // Rotate tips & testimonials

var curcontentindex=0;
var tips=new Array();

var curmycontentindex=0;
var testimonials=new Array();

 // for tips
function getElementByClass(classname){
 var inc=0;
 var alltags=document.all? document.all : document.getElementsByTagName("*");
 for (i=0; i<alltags.length; i++){
   if (alltags[i].className==classname)
     tips[inc++]=alltags[i];
 }
}

function rotatecontent(){
curcontentindex = Math.floor(Math.random() * tips.length);
 tips[curcontentindex].style.display="block"; //show current message
}


// for testimonials
function doSomethingWithClasses(theClass){
 var inc=0;
 var alltags=document.all? document.all : document.getElementsByTagName("*");
 for (i=0; i<alltags.length; i++){
   if (alltags[i].className==theClass)
     testimonials[inc++]=alltags[i];
 }
}

function rotatemycontent(){
curmycontentindex = Math.floor(Math.random() * testimonials.length);
 testimonials[curmycontentindex].style.display="block"; //show current message
}

//load functions for tips & testimonials
window.onload=function(){
	
	
  
    if (document.all || document.getElementById){
		 
    //for tips
   getElementByClass("rotateTips");
   //setInterval("rotatecontent()", 2000);
   rotatecontent();
   
   //for testimonials
      doSomethingWithClasses("rotateTestimonial");
   //setInterval("rotatecontent()", 2000);
   rotatemycontent();
  
 }

}


  
 


//Email this link


function mailThisUrl(){
var	u = window.location;
	
mail_str = "mailto:?subject="+document.title+"&body=For details please visit: "+location.href;
location.href = mail_str;
} 


/*// Fix enter-to-submit functionality for searchbox
function addInputSubmitEvent(form, input) {
    input.onkeydown = function(e) {
        e = e || window.event;
        if (e.keyCode == 13) {
            form.submit();
            return false;
        }
    };
}

window.onload = function() {
    var forms = document.getElementsByTagName('form');

    for (var i=0;i < forms.length;i++) {
        var inputs = forms[i].getElementsByTagName('input');

        for (var j=0;j < inputs.length;j++)
            addInputSubmitEvent(forms[i], inputs[j]);
    }
};*/



//EOF