// Open a window with a parsed object, width and height.
function OpenWindow(obj,thisWidth,thisHeight)
{
	window.open(obj,'newWindow','width='+thisWidth+',height='+thisHeight+',scrollbars=no,resizable=yes,left=10,top=20');
}

// -------------------------------------------------------------------

// Open a sizable window with a parsed image name.
function OpenImageSizableWindow(thisWindowTitle, thisImage, thisWindowWidth, thisWindowHeight)
{		
         var thisWindowTitle = "Cortex7 :: Online|Offline";
	thisWindowWidth = thisWindowWidth + 20;
	thisWindowHeight = thisWindowHeight + 40;
	
	newWindow=window.open('','newWindow','width='+thisWindowWidth+',height='+thisWindowHeight+',scrollbars=yes, resizable, left=20,top=20');
	newWindow.document.open();
	newWindow.document.write("<html>");
	newWindow.document.write("<head>");
	newWindow.document.write("<title>"+thisWindowTitle+"</title>");
	newWindow.document.write('<LINK rel=stylesheet type="text/css" href="/stylesheets/clientstyles.css" title="style">');
	newWindow.document.write("</head>");
	newWindow.document.write("<body topmargin='10' leftmargin='10' rightmargin='10'>");
	newWindow.document.write("<center><img src='"+thisImage+"'><center><br>");
	newWindow.document.write('<center><a href="#" onclick="JavaScript:window.print();">[Print Photo]</a> &nbsp;&nbsp; <a href="#" onclick="JavaScript:window.close()">[Close Photo]</a></center>');
	newWindow.document.write("</body>");
	newWindow.document.write("</html>");
	newWindow.document.close();
	newWindow.focus();
}

// -------------------------------------------------------------------

// Open a pop-up window with the provided URL, width and height of the window.
function OpenPopWindow(thisURL,thisWidth,thisHeight)
{
	var thisWindowWidth = thisWidth + 30;
	var thisWindowHeight = thisHeight + 10;

	window.open(""+thisURL+"","OrderWindow","width="+thisWindowWidth+",height="+thisWindowHeight+",left=5,top=5,status=Yes,toolbar=no,scrollbars=yes, resizable");
}
	
// -------------------------------------------------------------------

// Open a pop-up frame type window with the provided URL, width and height of the window.
function OpenSmallPopWindowFrame(thisURL,thisWidth,thisHeight)
{
	window.open(""+thisURL+"","OrderWindow","width="+thisWidth+",height="+thisHeight+",left=50,top=100,status=no,toolbar=no,scrollbars=yes");
}

// -------------------------------------------------------------------

function CheckSecurity(thisWMSAddress)
{ // Alert the user before going to In-Control.
  if (confirm("                           - SECURITY WARNING -\n\nYou are about to be transferred to In-Control's secure login facility.\n\n  Please click 'CANCEL' if you are not authorised to utilise this facility.\n\n                  Unauthorised access is prohibited."))
    document.location.href = thisWMSAddress;
}

// -------------------------------------------------------------------

// Check for a valid email address.
function IsEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

// -------------------------------------------------------------------

// Check all required fields have been entered on the Contact Us Form.
function ValidateContact() 
{
    var formOk = true;
    var errormsg = "Please complete/check the following required fields:\n";
	
     if (theContactForm("Full_Name").value == "")
       {
       errormsg += "\n- Full Name";
       formOk = false;
       }

    if (theContactForm("Email_Address").value == "")
       {
       errormsg += "\n- Email Address";
       formOk = false;	
       }
		
    if ((theContactForm("Email_Address").value != "") && (!IsEmailAddr(theContactForm("Email_Address").value)))
       {
       errormsg += "\n- Email Address is invalid";
       formOk = false;
       }
	   
    if (theContactForm("Telephone").value == "")
       {
       errormsg += "\n- Telephone Number";
       formOk = false;	
       }	   

    if (theContactForm("Comments").value == "")
       {
       errormsg += "\n- Comments Number";
       formOk = false;	
       }	
	   	   
    if (!formOk)
       {
       alert(errormsg);
       return false;
       }
    else
       {
       alert("Thank you - your request will now be submitted.");
       return (true);
       }	
}  

// -------------------------------------------------------------------

// Check all required fields have been entered on the form.
function ValidateSEORequest() 
{ 
    var formOk = true;
    var errormsg = "Please complete/check the following required fields:\n";
	
    if (theSEORequestForm("Full_Name").value == "")
       {
       errormsg += "\n- Full Name";
       formOk = false;
       }

    if (theSEORequestForm("Email_Address").value == "")
       {
       errormsg += "\n- Email Address";
       formOk = false;	
       }
		
    if ((theSEORequestForm("Email_Address").value != "") && (!IsEmailAddr(theSEORequestForm("Email_Address").value)))
       {
       errormsg += "\n- Email Address is invalid";
       formOk = false;
       }
	   
    if (theSEORequestForm("Telephone").value == "")
       {
       errormsg += "\n- Telephone Number";
       formOk = false;	
       }	   

    if (theSEORequestForm("Website_Address").value == "")
       {
       errormsg += "\n- Website Address";
       formOk = false;	
       }	
	   	   
    if (!formOk)
       {
       alert(errormsg);
       return false;
       }
    else
       {
       alert("Thank you - your request will now be submitted.");
       return (true);
       }				 
}  

// -------------------------------------------------------------------
// Check all required fields have been entered on the form.
function ValidateWebsiteRequest() 
{
    var formOk = true;
    var errormsg = "Please complete/check the following required fields:\n";
	
    if (theWebsiteRequestForm("Full_Name").value == "")
       {
       errormsg += "\n- Full Name";
       formOk = false;
       }

    if (theWebsiteRequestForm("Email_Address").value == "")
       {
       errormsg += "\n- Email Address";
       formOk = false;	
       }
		
    if ((theWebsiteRequestForm("Email_Address").value != "") && (!IsEmailAddr(theWebsiteRequestForm("Email_Address").value)))
       {
       errormsg += "\n- Email Address is invalid";
       formOk = false;
       }
	   
    if (theWebsiteRequestForm("Telephone").value == "")
       {
       errormsg += "\n- Telephone Number";
       formOk = false;	
       }	   

    if (!formOk)
       {
       alert(errormsg);
       return false;
       }
    else
       {
       alert("Thank you - your request will now be submitted.");
       return (true);
       }
}  