
// script to use text as a submit button in the login.inc include file
function ltype ( selectedtype )
{
  document.form1.ltype.value = selectedtype ;
  document.form1.submit() ;
}

// script to use text as a submit button 'google mini home.asp
function type ( selectedtype )
{
  document.searchform.type.value = selectedtype ;
  document.searchform.submit() ;
}

// function use image as a submit button in the file /cgp/getpassword.asp
function getpassword ( selectedtype )
{
  document.form2.getpassword.value = selectedtype ;
  document.form2.submit() ;
}
	

// this variable will hold the window obect
// we only allow one pop-up at a time
var popup = null;

/*/
/ / PURPOSE:
/ /		To create and center a pop-up window.
/ /
/ / COMMENTS:
/ /		It will replace to old pop-up if called
/ / 	without calling DestroyWnd() first..
/*/

function CreateWnd (file, width, height, resize)
{
	var doCenter = false;

	if((popup == null) || popup.closed)
	{
		attribs = "";

		/*/ there's no popup displayed /*/

		// assemble some params
		if(resize) size = "yes"; else size = "no";

		/*/
		/ / We want to center the pop-up; however, to do this we need to know the
		/ / screen size.  The screen object is only available in JavaScript 1.2 and
		/ / later (w/o Java and/or CGI helping), so we must check for the existance
		/ / of it in the window object to determine if we can get the screen size.
		/ /
		/ / It is safe to assume the window object exists because it was implemented
		/ / in the very first version of JavaScript (that's 1.0).
		/*/
		for(var item in window)
			{ if(item == "screen") { doCenter = true; break; } }

		if(doCenter)
		{	/*/ center the window /*/

			// if the screen is smaller than the window, override the resize setting
			if(screen.width <= width || screen.height <= height) size = "yes";

			WndTop  = (screen.height - height) / 2;
			WndLeft = (screen.width  - width)  / 2;

			// collect the attributes
			attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=" + size + "," + 
			"status=no,toolbar=no,directories=no,menubar=no,location=no,top=" + WndTop + ",left=" + WndLeft;
		}
		else
		{
			/*/
			/ / There is still one last thing we can do for JavaScrpt 1.1
			/ / users in Netscape.  Using the AWT in Java we can pull the
			/ / information we need, provided it is enabled.
			/*/
			if(navigator.appName=="Netscape" && navigator.javaEnabled())
			{	/*/ center the window /*/

				var toolkit = java.awt.Toolkit.getDefaultToolkit();
				var screen_size = toolkit.getScreenSize();

				// if the screen is smaller than the window, override the resize setting
				if(screen_size.width <= width || screen_size.height <= height) size = "yes";

				WndTop  = (screen_size.height - height) / 2;
				WndLeft = (screen_size.width  - width)  / 2;

				// collect the attributes
				attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=" + size + "," + 
				"status=no,toolbar=no,directories=no,menubar=no,location=no,top=" + WndTop + ",left=" + WndLeft;
			}
			else
			{	/*/ use the default window position /*/

				// override the resize setting
				size = "yes";

				// collect the attributes
				attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=" + size + "," + 
				"status=no,toolbar=no,directories=no,menubar=no,location=no";
			}
		}

		// create the window
		popup = open(file, "", attribs);
	}
	else
	{
		// destory the current window
		DestroyWnd();
		// recurse, just once, to display the new window
		CreateWnd(file, width, height, resize);
	}
}

/*/
/ / PURPOSE:
/ /		To destroy the pop-up window.
/ /
/ / COMMENTS:
/ /		This is available if wish to destroy
/ / 	the pop-up window manually.
/*/

function DestroyWnd ()
{
	// close the current window
	if(popup != null)
	{
		popup.close();
		popup = null;
	}
}

// S T A R T  C H E C K B O X  C O N T R O L

	function checkUncheckAll(theElement) {
     var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  theForm[z].checked = theElement.checked;
	  }
     }
    }
	
function checkUncheckSome(controller,theElements) {
     var formElements = theElements.split(',');
	 var theController = document.getElementById(controller);
	 for(var z=0; z<formElements.length;z++){
	  theItem = document.getElementById(formElements[z]);
	  if(theItem){
	  if(theItem.type){
        if(theItem.type == 'checkbox' && theItem.id != theController.id){
	     theItem.checked = theController.checked;
	    }
	  } else {

	    var nextArray = '';
	     for(var x=0;x <theItem.childNodes.length;x++){
	      if(theItem.childNodes[x]){
	        if (theItem.childNodes[x].id){
	          nextArray += theItem.childNodes[x].id+',';
		    }
	      }
	     }
	     checkUncheckSome(controller,nextArray);
	   }
	  }
     }
    }
	
// E N D  C H E C K B O X  C O N T R O L	

// S T A R T  E M A I L  C H E C K

function fixElement(element, message) { 
alert(message); element.focus(); 
} 

function isMailReady(form) { 
var passed = false;

if (form.first.value == "") { 
        	 fixElement(form.first, "Please fill in your first name.");
	}
	else if (form.last.value == "") { 
        	 fixElement(form.last, "Please fill in your last name.");
	}
	else if (form.email.value.indexOf("@") == -1 || form.email.value.indexOf(".") == -1) {
			 fixElement(form.email, "Please check your email address.");
	}
	else if (form.title.value == "") {
			 fixElement(form.title, "Please fill in your title.");
	}
	else if (form.company.value == "") {
			 fixElement(form.company, "Please fill in your company name.");
	}
	else if (form.address1.value == "") {
			 fixElement(form.address1, "Please fill in your mailing address.");
	}
	else if (form.city.value == "") {
			 fixElement(form.city, "Please fill in your city.");
	}
	else if (form.zip.value == "") {
			 fixElement(form.zip, "Please fill in your zip code.");
	}
	else if (form.country.value == "none") {
			 fixElement(form.country, "Please fill in your country.");
	}
	else if (form.customer_type.value == "none") {
			 fixElement(form.customer_type, "Please select your business type.");
	}					
	else
	{ 
	passed = true; 
	} 
return passed; 
}

// S T A R T  E M A I L  C H E C K for Briefing page

function isMailReady(formbriefing) { 
var passed = false;

if (formbriefing.first.value == "") { 
        	 fixElement(formbriefing.firstname, "Please fill in your first name.");
	}
	else if (formbriefing.last.value == "") { 
        	 fixElement(formbriefing.lastname, "Please fill in your last name.");
	}
	else if (formbriefing.email.value.indexOf("@") == -1 || form.email.value.indexOf(".") == -1) {
			 fixElement(formbriefing.email, "Please check your email address.");
	}
	else if (formbriefing.company.value == "") {
			 fixElement(formbriefing.company, "Please fill in your company name.");
	}
	else if (formbriefing.address.value == "") {
			 fixElement(formbriefing.address, "Please fill in your mailing address.");
	}
	else
	{ 
	passed = true; 
	} 
return passed; 
}


