function emailCheck(s1) {
emailStr=s1;

		var emailPat=/^(.+)@(.+)$/
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		var validChars="\[^\\s" + specialChars + "\]"
		var quotedUser="(\"[^\"]*\")"
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		var atom=validChars + '+'
		var word="(" + atom + "|" + quotedUser + ")"
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		var matchArray=emailStr.match(emailPat)
		if (matchArray==null) 
		{
			alert("Email address seems incorrect (check @ and .'s)")
			return false;
		}
return true;
}

function newschk()
{
	var dom = document.topfrm2;
	if(!emailCheck(dom.news_email.value))
	{
		dom.news_email.focus();
		return false;
	}
	else
	{
		dom.action = "newsletter.php";
		return true;
	}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function searchfun()
{
	var dom = document.topfrm1;
	dom.action = "searchres.php";
	dom.submit();	
}

glbl_str123 = '1234567890()-';
function validMobileNo(mobileNumber)
{
  intFail = 0;
  //strip spaces
  
  /*if(!checkSpace(mobileNumber))
  {
  	intFail = intFail + 1;
    alert("Please remove any spaces");
    return false;
  }*/
  mobileNumber = trim(mobileNumber);
  mobile = str_replace(' ', '', mobileNumber);

  if (permitOnly1(glbl_str123, mobile) == 0)
  {
    intFail = intFail + 1;
    alert("Please enter only numeric characters in phone no.");
    return false;
    
  }
  if (mobile.length < 10)
  {
    alert("Phone Number must be 10 digits");
    intFail = intFail + 1;
    return false;
  }
  //is the first two characters '04'?
  /*if (mobile.substring(0,2) != '04')
  {
    intFail = intFail + 1;
    alert("Mobile Number Must start with 04");
    return false;
  }*/

  //are there any non-numeric characters?
  

  //is it ten characters long?  ie., 0411-111-111
  if (intFail == 0)
  {
    return true;
  }
  else
  {
    return false;
  }
}
function permitOnly1 (permissibleString, haystack)
{
  aryHaystack = haystack.split('');
  returnInt = 1;

  for (x = 0; x < aryHaystack.length; x++)
  {
    tmpIndex = permissibleString.indexOf(aryHaystack[x]);
    if (tmpIndex == -1)
    {
      returnInt = 0;
      break;
    }
  }
  return returnInt;
}
function isblank(s)
{
	for(var i=0; i < s.length; i++)
	{
		var c = s.charAt(i);
		
		if((c != ' ') && (c != '\n') && (c != '\t'))
			return false;
	}
	return true;
}
function checkSpace(s)
{
	for(var i=0; i < s.length; i++)
	{
		var c = s.charAt(i);
		
		if((c == ' ') || (c == '\n') || (c == '\t'))
			return false;
	}
	return true;
}

function str_replace(needle, newNeedle, haystack)
{
  maxLoop = haystack.length;
  newNeedleLength = newNeedle.length;
  needleLength = needle.length;

  x = 0;

  proceed = true

  while (proceed)
  {
    //if this is the needle we're looking for...
    if (haystack.substring(x, (x + needleLength)) == needle)
    {
      //get the substring before this character (watch out for the first character)
      if (x == 0)
      {
        preString = '';
      }
      else
      {
        preString = haystack.substring(0, x);
      }

      //get the substring after this character (watch out for the last character
      if (x == (haystack.length - needleLength))
      {
        postString = '';
      }
      else
      {
        postString = haystack.substring(x + needleLength);
      }

      //build new haystack
      haystack = preString + newNeedle + postString;

      x = x + newNeedleLength;

      //if the newNeedle is 0 characters long, the haystack is shorter, so run the search for charAt(x) again
      if (newNeedleLength == 0)
      {
        if (x != 0)
        {
          x = x - 1;
        }
      }
    }

    //Move along
    x = x + 1;

    //if we're shortened the haystack so that the new length is less than the original, and we're at the end of the new, then break.
    if (haystack.length < x)
    {
      proceed = false;
    }
    else
    {
      proceed = true;
    }

  }

  //return the new haystack
  return haystack;
}



function trim(sString)
{
  trimString = lTrim(rTrim(sString));
  return trimString;
}



function rTrim(sString)
{
  while (sString.substring(sString.length-1, sString.length) == ' ')
  {
    sString = sString.substring(0,sString.length-1);
  }
  return sString;
}



function lTrim(sString)
{
  while (sString.substring(0,1) == ' ')
  {
    sString = sString.substring(1, sString.length);
  }
  return sString;
}
function smsg(msgStr) { //v1.0
  status=msgStr;
  document.prs_return = true;
}
function nosmsg(msgStr) { //v1.0
  status=msgStr;
  document.prs_return = true;
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}