var errSubjectRequired="The field 'Subject' is required to proceed.";
var errAccountRequired = "The field 'OnStar Account#' is required to proceed. \n The length should not be more than 12 characters. \n Should only consist of numbers and '-'.";
var errAccountNotRequired = "You can enter the 'OnStar Account#' only if you are a OnStar Subscriber.";
var errFirstName = "The field 'First Name' is required to proceed. \n The length should not be more than 30 characters.";
var errLastName = "The field 'Last Name' is required to proceed. \n The length should not be more than 30 characters.";
var errEmail = "The field 'Email Address' is required to proceed and it should be a valid email address. \n The length should not be more than 50 characters.";
var errAddress = "The field 'Address' is required to proceed. \n The length should not be more than 35 characters.";
var errAddress2 = "The field 'Address 2' should not be more than 35 characters.";
var errCity = "The field 'City' is required to proceed. \n The length should not be more than 35 characters.";
var errState = "The field 'State' is required to proceed.";
var errZip = "The field 'Zip' is required to proceed and should only have 5 numbers.";
var errDayPhone = "The field 'Daytime Phone' should not be more than 12 characters. \n It can only have numbers and '-'.";
var errEveningPhone = "The field 'Evening Phone' should not be more than 12 characters. \n It can only have numbers and '-'.";
var errHwSoon = "The field 'How soon do you expect to make a purchase?' is required to proceed.";
var errHwSoonNotReq = "You can select the value for 'How soon do you expect to make a purchase?' \n if you are currently shopping for a vehicle.";

var errStorySelect = "Year,Make and Model selection can be done only if subject is Share Story";
var errYear = "The model year you entered is invalid. Please reenter the year, making sure to include 4 digits.";
var errModel = "The field 'Vehicle Model' should not be more than 30 characters.";
var errFileWrongAttach = "In order to submit a photo, \"Share Story\" must be selected from the \"Subject\" dropdown menu.";
var errFileAbsent = "In order to submit a photo, \"Share Story\" must be selected from the \"Subject\" dropdown menu.";
var errImproperFileExtension="Your photo file type must be GIF or JPEG.";
var errImproperFileType="Your photo file type must be GIF or JPEG.";
var varMyStory = "Share Story";
var errPublishStory = "In order to submit a photo, \"Share Story\" must be selected from the \"Subject\" dropdown menu.";
var errCheckbox = "If you'd like to give OnStar permission to use your story and photo in future publications, please check the box before clicking \"Submit.\"";

var errDealerFullName = "The field 'Your Full Name' is required to proceed. \n The length should not be more than 60 characters.";
var errDealerTitle = "The length of the field 'Title' should not be more than 20 characters.";
var errDealershipName = "The field 'Dealership Name' is required to proceed. \n The length should not be more than 50 characters.";
var errDealerBac = "The length of the field 'BAC #' should not be more than 20 characters.";
var errDealerBroadcastDate = "The field 'IDL Broadcast Date' is required to proceed. \n The length should not be more than 20 characters.";
var errDealerBroadcastTime = "The field 'IDL Broadcast Time' is required to proceed. \n The length should not be more than 10 characters.";
var errDealerBroadcast = "The field 'Which broadcast did you view?' is required to proceed.";
var errDealerContact = "The field 'Dealership Contact' is required to proceed. \n The length should not be more than 60 characters.";
var errDealerPhone = "The field 'Dealership Phone' is required to proceed. \n The length should not be more than 12 characters. \n It can only have numbers and '-'.";
var errDealerAddress = "The field 'Dealership Address' is required to proceed. \n The length should not be more than 35 characters.";
var errDealerQuantity = "The field 'Quantity' is required to proceed. \n The length should not be more than 10 characters. \n Should have only numbers.";
var errBarsDealerCode = "The field 'Bars Dealer Code' is required to proceed. \n The length should not be more than 20 characters.";

function isNumHyphen(strTemp) {
    for (i=0; i < strTemp.length; i++) {
        chTemp = strTemp.charAt(i);
        if (!( ((chTemp >= 0) && (chTemp <= 9)) || ((chTemp == "-")) ))
            return false;
    }
    return true;
}

function IsNumeric(strString)
{
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

 //test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
 }



function emailCheck(emailStr) {
    //var emailFilter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    var emailFilter=/^([\w-]+(\.[\w-]+)*)@(([\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(\.[a-z]{2})?)$/i;
        if (!(emailFilter.test(emailStr))) { 
            alert(errEmail);
            return false;
        }
    return true;
}


 function trim(inputString) {
        if (typeof inputString != "string"){
            return inputString;
        }
        var retValue = inputString;
        var ch = retValue.substring(0, 1);
        while (ch == " ") { 
            retValue = retValue.substring(1, retValue.length);
            ch = retValue.substring(0, 1);
        }
        ch = retValue.substring(retValue.length-1, retValue.length);
        while (ch == " ") { 
            retValue = retValue.substring(0, retValue.length-1);
            ch = retValue.substring(retValue.length-1, retValue.length);
        }
        while (retValue.indexOf("  ") != -1) { 
          retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
        }
       return retValue; 
 } 
 function newwindowopen(str,winwidth,winheight){		
		popup = window.open(str,'blank','width='+winwidth+',height='+winheight+',menubar=no,toolbar=no,location=no,status=no,resizable=yes,scrollbars=yes,wrap=yes,screenX=100,screenY=125,left=100,top=125');
		return;
}
function yearCheck(vehyear)
{
	if(!(IsNumeric(vehyear)))
		return false;
	
	return true;
}