function runSubmit() {
 	if ( validateFields() == true ) {
	     document.forms[0].submit();
		return true;
	}

	return false;

}

function isStrEmpty (theField) {
  var tmpStr = theField.value;
  for (i = 0;  i < tmpStr.length;  i++)
  {
    var ch = tmpStr.charAt(i);
    if (ch != ' ') {
        return (false);
    }
  }
  return (true);
}


var whitespace = " \t\n\r";

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}



function isWhitespace (s)

{   var i;

    if (isEmpty(s)) return true;

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    return true;
}



function isEmail (s)
{   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);
   
    if (isWhitespace(s)) return false;
    
    var i = 1;
    var sLength = s.length;

    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

var exampleText = "This is an example";
var exampleTextTitle = "This is an example title";


function showHelp(x, y) {
    var OpenWindow=window.open("", "helpwin", "height=350,width=350,scrollbar=yes");
    OpenWindow.document.write("<HTML><HEAD>");
    OpenWindow.document.write("<TITLE>Help Window</TITLE>");
    OpenWindow.document.write("<base href=\"http://www.oriyamatrimonials.com/\">");
    OpenWindow.document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"css/omstyle.css\">");
    OpenWindow.document.write("</HEAD><BODY bgcolor=#ffcccc>");
    OpenWindow.document.write("<CENTER>");
    OpenWindow.document.write("<table width=100% border=0 cellpadding=3 cellspacing=1 bgcolor=#ffcccc><tr><td bgcolor=black><font color=#ffcccc><b>");
    OpenWindow.document.write(y);
    OpenWindow.document.write("</b></font></td></tr><tr><td>");
    OpenWindow.document.write(x);
    OpenWindow.document.write("<a href='' onClick='self.close()'> <center><p><b>Close window</b></p></center></a><p>");
    OpenWindow.document.write("</td></tr></table>");
    OpenWindow.document.write("</CENTER>");
    OpenWindow.document.write("</BODY></HTML>");
}

function clickclear(thisfield, defaulttext) {
    if (thisfield.value == defaulttext) {
        thisfield.value = "";
    }
}

function clickrecall(thisfield, defaulttext) {
    if (thisfield.value == "") {
        thisfield.value = defaulttext;
    }
}

function toggle_it(itemID){
      // Toggle visibility between none and inline
      if ((document.getElementById(itemID).style.display == 'none'))
      {
        document.getElementById(itemID).style.display = 'inline';
      } else {
        document.getElementById(itemID).style.display = 'none';
      }
                  
}

function switchDivs (elem1, elem2) {
    document.getElementById(elem1).style.display = 'inline';
    document.getElementById(elem2).style.display = 'none';
}


// All this does is to see if the selected index is the same as the second param
// which would mostly be 0 - If so it returns false after an alert.  This is
// Simple to ensure that the user has selected an item from a list and not
// left it at 'pick one' or something like that

function checkSelectedIndex (element, idx, name) {
	var msg = 'You must select a(n) ' + name;
	if (element.selectedIndex == idx) {
		alert (msg);
		return false;
	}
	return true;
}

function openNewWindow (url,name,wd, ht, addlParam) {

	var resizableParam = "";
	var myRegExp = /resizable/i;
	var match = addlParam.search(addlParam);
	if (match == -1) {
		resizableParam = "resizable=yes,";
	}

    if (addlParam != '') {
        addlParam = ',' + addlParam;
    }
	var leftVal = (screen.width/2)-(wd/2);
	var topVal = (screen.height/2)-(ht/2);

    var winParam = resizableParam + 'toolbar=no,menubar=no,directories=no,location=no,status=yes' + ',width=' + wd + ',height=' + ht + ',top=' + topVal + ',left=' + leftVal + addlParam;

    newwindow=window.open(url,name,winParam);
	//newwindow.moveTo(leftVal, topVal);
    newwindow.focus();
	return newwindow;
}

// poptastic was used with php121 chat
function poptastic(url,name) {
	var newwindow;
    newwindow=window.open(url,name,'height=600, width=750, left=40, top=40, toolbar=no, menubar=no, directories=no, location=no, scrollbars=no, status=no, resizable=yes, fullscreen=no');
    newwindow.focus();
}

function isValidDate(day,month,year){
	/*
	Purpose: return true if the date is valid, false otherwise

	Arguments: day integer representing day of month
	month integer representing month of year
	year integer representing year

	Variables: dteDate - date object

	*/
	var dteDate;

	//set up a Date object based on the day, month and year arguments
	//javascript months start at 0 (0-11 instead of 1-12)
	dteDate=new Date(year,month,day);

	/*
	Javascript Dates are a little too forgiving and will change the date to a reasonable guess if it's invalid. We'll use this to our advantage by creating the date object and then comparing it to the details we put it. If the Date object is different, then it must have been an invalid date to start with...
	*/

	return ((day==dteDate.getDate()) && (month==dteDate.getMonth()) && (year==dteDate.getFullYear()));
}


function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}
