﻿
//---------------------------------------------------------------------||
// FUNCTION:    Display duplicate value                                ||
// PARAMETERS:   field ids                                             ||
// RETURNS:                                                            ||
// PURPOSE:  display selected value in another field.                  ||
//---------------------------------------------------------------------||   
 function GetValue(x)
 {                  
     var y=document.getElementById(x).value;	       
     document.getElementById("txt_supervisor").value=y.toUpperCase();		        
 }
//---------------------------------------------------------------------||
// FUNCTION:    clear field                                            ||
// PARAMETERS:   field ids                                             ||
// RETURNS:                                                            ||
// PURPOSE:  display none                                              ||
//---------------------------------------------------------------------||   
 function clearMe(x)
 {          
     document.getElementById(x).value="";	
 }
//---------------------------------------------------------------------||
// FUNCTION:    form validatation                                      ||
// PARAMETERS:   field ids                                             ||
// RETURNS:                                                            ||
// PURPOSE:  no null emtry is allowed                                  ||
//---------------------------------------------------------------------||   
 function formValidate()
{                
   var box="";
   if(document.getElementById("txt_Location").value.length < 1)
        box+=" - LOCATTION. \n";      
   if(document.getElementById("txt_supervisor").value.length < 1)
        box+=" - SUPERVISOR NAME. \n";         
   if(document.getElementById("txt_Description").value.length < 1)
        box+=" - DESCRIPTION. \n";
        
  if(box.length > 0)
        {
            alert( "_______________________________________________________________________________________\n" +
                   "WRD - INSTRUMENT SHOP \n\n" +
		           "Please double-check and complete the field(s) listed below before continuing:\n\n" + box +
		           "\n \n If you have any questions about these fields, feel free to contact the INTRUMENT SHOP at 1 626-458-0000. \n" +
		           "_______________________________________________________________________________________ ");		  
		           
		           return false; 
	    } 
	    else
	    {
	        return true;
	    }
}
//---------------------------------------------------------------------||
// FUNCTION:    Clear text Area                                        ||
// PARAMETERS:   field id                                              ||
// RETURNS:                                                            ||
// PURPOSE:  no user entry is allow in that field                      ||
//---------------------------------------------------------------------||   
function ClearTextArea(x)
{
   var y=document.getElementById(x).value;
   if(y.length > 0)
   {          
      alert( "___________________________________________________________________________________\n" +
             "WRD INSTRUMENT SHOP \n\n" +
	         " (*_*) Please click on the note image below to write your comment." +
	         "\n \n If you need help filling out these fields, feel free to contact our Web Admin at 1 626-458-4171. \n" +
		     "___________________________________________________________________________________");        
             document.getElementById(x).value="";
   }
            
}

//---------------------------------------------------------------------||
// FUNCTION:    Alert Message                                          ||
// PARAMETERS:   none                                                  ||
// RETURNS:                                                            ||
// PURPOSE:  Display alert                                             ||
//---------------------------------------------------------------------||   
function getMessage()
{
    alert( "___________________________________________________________________________________\n" +
           "WRD INSTRUMENT SHOP \n\n" +
		   " (*_*) Please click on the note image below to write your comment." +
		   "\n \n If you need help filling out these fields, feel free to contact our Web Admin at 1 626-458-4171. \n" +
		   "___________________________________________________________________________________");              
}

//---------------------------------------------------------------------||
// FUNCTION:    Calendar                                               ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:  Display Calendar                                          ||
//---------------------------------------------------------------------||   
function y2k(number)    { return (number < 1000) ? number + 1900 : number; }
function padout(number) { return (number < 10) ? '0' + number : number; }
var today = new Date();
var day = today.getDate(), month = today.getMonth(), year = y2k(today.getYear()), whichOne = 0;

function restart() {  
    document.getElementById(whichOne).value = '' + padout(month - 0 + 1) + '/'  + padout(day) + '/' + year;   
    mywindow.close();
}

function calendar(number) {  
    screenW = screen.width/2;
    screenH = screen.height/2; 
    whichOne = number;
    day = today.getDate(), month = today.getMonth(), year = y2k(today.getYear());
    mywindow=open("cal.htm","myname","resizable=no,top=250,left="+screenW+",width=350,height=270");
   
    if (mywindow.opener == null) mywindow.opener = self;
}
//---------------------------------------------------------------------||
// FUNCTION:    Calendar                                               ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:  checks if date passed is valid                            ||
//           will accept dates in following format:                    ||
//           isDate(dd,mm,ccyy), or                                    ||
//           isDate(dd,mm) - which defaults to the current year, or    ||
//           isDate(dd) - which defaults to the current month and year.||
//           Note,if passed the month must be between 1 and 12, and the||
//           year in ccyy format.                                      ||
//---------------------------------------------------------------------||   
function isDate (day,month,year) {
// 
    var today = new Date();
    year = ((!year) ? y2k(today.getYear()):year);
    month = ((!month) ? today.getMonth():month-1);
    if (!day) return false
    var test = new Date(year,month,day);
    if ( (y2k(test.getYear()) == year) &&
         (month == test.getMonth()) &&
         (day == test.getDate()) )
        return true;
    else
        return false
}

