function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}





function stretchdiv() {
	var container = document.getElementById('main-body-content');
	container.style.height = 'auto';
	var deltay = container.offsetHeight;
	container.style.height = deltay + "px";
}

function golink() {
	if (document.jump.menu.options[document.jump.menu.selectedIndex].value!='') {
		location=document.jump.menu.options[document.jump.menu.selectedIndex].value;
	}
}

function openbumper(gotourl) {
	window.open("http://www.bandai.com/links/popup_bumper.php?gotostring="+escape(gotourl), '_blank', 'width=735,height=300,resizable=no,scrollbars=no');
}
function showpic(imgname) {
	window.document.form1.cardname.value=imgname;
	window.document.form1.submit();
}


function popup(link) {
	var remotewin = null;
	remoteWin = window.open(link,"remotewin","toolbar=yes,menubar=yes,status=yes,scrollbars=yes,resizable=yes");
    // window.location=link
}


function doCategory(opVal) {
    if (opVal == 'Employment')  { // Employment
        popup('../about/employment.html');
    }
    if (opVal == 'Replacement Parts')  { // Repair and Parts
        popup('contact_repair.html');
    }    
}   


// ---DTB, 03 Jan 1999 --- 
//Validate email, must contain '@' and '.' and no internal or leading spaces, minimum sizes enforced.
// Contact Support form

function validate() {

	var inputStr="";
	var validInput=false;


	// CHECK TO SEE IF ALL FIELDS ARE FILLED

		inputStr=document.checkit.fname.value;
		if ((inputStr==null) || (inputStr=="")) {
			alert('Please enter your first name.');
			document.checkit.fname.focus();
			return validInput;
		}
	if (!IsEmail(document.checkit.email.value)) {
		alert("Please Enter Your Valid Email Address");
		document.checkit.email.focus();
		return validInput;
	}

//		inputStr=document.checkit.email.value;
//		if ((inputStr==null) || (inputStr=="")) {
//			alert('Please enter your email address.');
//			document.checkit.email.focus();
//			return validInput;
//		}

		inputStr=document.checkit.subject.value;
		if ((inputStr==null) || (inputStr=="")) {
			alert('Please enter a subject for your message.');
			document.checkit.subject.focus();
			return validInput;
		}

		if (document.checkit.comment.value.length<10) {
			alert('Please enter a valid message.');
			document.checkit.comment.focus();
			return validInput;
		}

        var SelIndex = document.checkit.category.selectedIndex; 
		if (SelIndex==0) {
			alert('You must select a category.');
			document.checkit.category.focus();
			return validInput;
		}

		for (var counter=0; counter < document.checkit.msgType.length; counter++){
		    if (document.checkit.msgType[counter].checked) {
		        var TypeOk = "yup";
		    }
		}
		if (TypeOk != "yup") {
			    alert('Please indicate whether this is a Comment, Suggestion, Question or Complaint.');
			    document.checkit.fname.focus();
			    return validInput;
		}

        var SelIndex = document.checkit.hearabout.selectedIndex; 
		if (SelIndex==0) {
			alert('Please tell us how you heard about us.');
			document.checkit.hearabout.focus();
			return validInput;
		}

	validInput = true;
	return validInput;
}




function inputchk(form) {

	if (!IsEmpty(form.txt_fromname.value)) {
		alert("Please Enter Your Name");
		form.txt_fromname.focus();
		return false;
	}
	if (!IsEmail(form.txt_fromemail.value)) {
		alert("Please Enter Your Valid Email Address");
		form.txt_fromemail.focus();
		return false;
	}
	if (!IsEmpty(form.txt_toname.value)) {
		alert("Please Enter Your Friend's Name");
		form.txt_toname.focus();
		return false;
	}
	if (!IsEmpty(form.txt_toemail.value)) {
		alert("Please Enter Your Friend's Valid Email Address");
		form.txt_toemail.focus();
		return false;
	}
	if (!IsEmpty(form.txt_msg.value)) {
		alert("Please Enter Message");
		form.txt_msg.focus();
		return false;
	}
	
	
}


// Text Input Check Function
function IsEmpty(string) {
	var inputString="";
	var validInput=false;
	inputStr=string;

	if ((inputStr=="") || (inputStr==null)) {
		return validInput;
	}
	
	validInput=true;
	return validInput;
}






// Email Check Function
function IsEmail(string) {

	var inputString="";
	var validInput=false;
	inputStr=string;

	if ((inputStr==null) || (inputStr=="")) {
		return validInput;
	}

	a=inputStr.indexOf('@'); 		 
	b=inputStr.indexOf('.',a);	
	c=inputStr.indexOf(' ');	
	d=inputStr.length;

	if  (a < 2) { 			// there must be at least xx@ 
		return validInput;
	}

	dotcom=inputStr.substring(b+1, d);
	if  (dotcom.length < 2) { 		// there must be at least @xx.xx 
		return validInput;
	}

	if  (b < 5) {			// there must be at least xx@xx.
		return validInput;
	}

	// If users enter 2 or more trailing spaces the email name will be rejected.
	for (i = 0; i<(d-1); i++) {
		if (inputStr.substring(i,i+1)==' ') {
			return validInput;
		}
	}
	
	validInput=true;
	return validInput;
	
}

