// Main.js  :   misc routines 
//  


//    Put the 'msg_alert' box on the page for possible use  __________________


function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
	} 
	}


//<![CDATA[
function UNhideObj(ThisObj){
	nav=document.getElementById(ThisObj).style ;
	nav.display='block';
}

function HideandUNhideObj(ThisObj){
	nav=document.getElementById(ThisObj).style ;
		if(nav.display=="none"){
			nav.display='block';
		 }
		else{
				nav.display='none';
				}
}


function HideObj(ThisObj){
	nav=document.getElementById(ThisObj).style ;
	nav.display='none';
}

function Changeimage(ThisImg, whichfile) {
	var chngimg=document.getElementById(ThisImg) ;
	chngimg.src = whichfile;
}

function Changebgimage(ThisImg, whichfile) {
	var chngimg=document.getElementById(ThisImg) ;
	chngimg.background.image = whichfile;
}

//  End -->
//]]>


function writedatehiddeninputvalue()
{
	var d = new Date() ;
	var dateofquest =  d.toDateString() ;
	var timeofquest = d.toTimeString() ;
	var timeonly = timeofquest.substr(0,5);
	var datenoday = dateofquest.substr(4,11);
	var date_time = datenoday + ", "+ timeonly ;
//	var date_time = datenoday + ",&nbsp;"+ timeonly ;
	document.write("<input name='dateq' id='dateq' value='"+ date_time  + "' type='hidden' />" );
//	alert(date_time ) ; 

}  

function checkdropval(minnum, maxnum)
	{
		var priceform = document.forms[0];
		var choice = "0";
		var numberdesired = priceform.item_quantity_1.value ;
		if (numberdesired >= minnum && numberdesired <= maxnum )   {    return true; }
		switch (numberdesired)
		{
		case "0":     {   alert(" Choose a number from the drop down list.\n  A number must be specified \n To retry, click this 'OK' below to try again."); return false;  break;   }
		default:	    {     
				      alert(" Choose a number from the drop down list.\n  A number must be specified \n  To retry, click this 'OK' below to try again."); 
				      return false; break;   
				}
		 }
	}

function checksix_greater(minnum, maxnum)
	{
		var numberdesired = document.getElementById("item_quantity_1").value ;
		if (numberdesired >= minnum && numberdesired <= maxnum )   {    return true; }
		switch (numberdesired)
		{
		case "0":     {   alert("Type a number 6 or greater up to 99.\n A non-decimal number must be specified. \n To re-specify a number less than 6, use the back arrow to reset price range. \n For more than 99 DVD's, call 360 378 9541 \n To retry, click this 'OK' below to try again."); return false;  break;   }
		default:	    {     
				      alert("Type a number 6 or greater up to 99.\n A non-decimal number must be specified. \n To re-specify a number less than 6, use the back arrow to reset price range. \n For more than 99 DVD's, call 360 378 9541 \n To retry, click this 'OK' below to try again."); 
				      return false; break;   
				}
		 }
	}

function check_minmax(minnum, maxnum)
	{
		var numberdesired = document.getElementById("item_quantity_1").value ;
		if (numberdesired >= minnum && numberdesired <= maxnum )   {    return true; }
		switch (numberdesired)
		{
		case "0":     {   alert("Type a number 1 or greater up to 99.\n A non-decimal number must be specified. \n For more than 99 DVD's, call 360 378 9541 \n To retry, click this 'OK' below to try again."); return false;  break;   }
		default:	    {     
				      alert("Type a number 1 or greater up to 99.\n A non-decimal number must be specified. \n For more than 99 DVD's, call 360 378 9541 \n To retry, click this 'OK' below to try again."); 
				      return false; break;   
				}
		 }
	}

	function msgbox()
{
/*	msg="Please Wait while Server is updated? ..."             */
/*	txt="<div id='adbox_t13_w_backg'><br>"+msg+"<br></div>"    */
/*	z_msgwindow= window.open ("waitmsg.htm", "z_msgwindow", "location=0,status=0,directories=0,scrollbars=0,width=400,height=110");   */
	z_msgwindow= window.open ("waitmsg.htm", "z_msgwindow", "width=400,height=110");
	z_msgwindow.moveTo(550,300);   
	
}

	function do_msg_alert(msg)
{
/*	e.g. msg="<br><b>Please Wait<b> while the server is updated ...<br>"             */
	txt="<span class=\'t11b_red\'><br>&nbsp;&nbsp;&nbsp;&nbsp;"+msg+"<br></span>"   ; 
/*	z_msgwindow= window.open ("waitmsg.htm", "z_msgwindow", "location=0,status=0,directories=0,scrollbars=0,width=400,height=110");   */
	document.getElementById("msg_alert").innerHTML=txt;
	UNhideObj("msg_alert");
}   

	function wait_button_disabled(whichid)
{
	msg="Please Wait ..." ;         
	var opbutton =document.getElementById(whichid);   
	opbutton.value=msg;
	opbutton.disabled=true;
}
	
function wait_disable_form(whichform) 
{
		if (document.all || document.getElementById) 
			{
			  for (i = 0; i < whichform.length; i++) 
				{
					var tempobj = whichform.elements[i];
					if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
						tempobj.disabled = true;
				}
			}
}			

function disableForm(theform) {
if (document.all || document.getElementById) {
for (i = 0; i < theform.length; i++) 
	{
		var tempobj = theform.elements[i];
		if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
		tempobj.disabled = true;
	}
		setTimeout('alert("Your form has been submitted.  Notice how the submit and reset buttons were disabled upon submission.")', 2000);
		return true;
	}
else {
alert("The form has been submitted.  But, since you're not using IE 4+ or NS 6, the submit button was not disabled on form submission.");
return false;
   }
}
//  End -->