function postForm(event_target, event_arguments, postbackURL)
{
    var theForm = document.forms['gapSingleForm'];
    
    if (!theForm)
        theForm = document.gapSingleForm;
    
    if (!theForm)
    {
    
        if (!theForm && document.getElementById)
        {
            document.getElementById('event_target').value = event_target;
            document.getElementById('event_arguments').value = event_arguments;
        }
        else if (!theForm && document.all)
        {
            document.all['event_target'].value = event_target;
            document.all['event_arguments'].value = event_arguments;
        }

        if (document.forms)
        {
            if (postbackURL && postbackURL.length > 0)
                document.forms[0].action = postbackURL;
            document.forms[0].submit();     
        }
        else
            alert('Your information could not be submitted, please use your contact us page to inform us of this issue');
    }
    else
    {
        if (!theForm.onsubmit || (theForm.onsubmit() != false)) 
        {
            theForm.event_target.value = event_target;
            theForm.event_arguments.value = event_arguments;
            if (postbackURL)
                theForm.action = postbackURL;
            theForm.submit();
        }
    }
    
}

function postQuoteDetailsForm(event_target, event_arguments, postbackURL)
{
    var theForm = document.forms['viewQuoteDetails'];
    
    if (!theForm)
        theForm = document.gapSingleForm;
    
    if (!theForm)
    {
    
        if (!theForm && document.getElementById)
        {
            document.getElementById('event_target').value = event_target;
            document.getElementById('event_arguments').value = event_arguments;
        }
        else if (!theForm && document.all)
        {
            document.all['event_target'].value = event_target;
            document.all['event_arguments'].value = event_arguments;
        }

        if (document.forms)
        {
            if (postbackURL && postbackURL.length > 0)
                document.forms[0].action = postbackURL;
            document.forms[0].submit();     
        }
        else
            alert('Your information could not be submitted, please use your contact us page to inform us of this issue');
    }
    else
    {
        if (!theForm.onsubmit || (theForm.onsubmit() != false)) 
        {
            theForm.event_target.value = event_target;
            theForm.event_arguments.value = event_arguments;
            if (postbackURL)
                theForm.action = postbackURL;
            theForm.submit();
        }
    }
    
}

function checkDate(day, month, year)
{  
    var monthLength = new Array(31,28,31,30,31,30,31,31,30,31,30,31);  
    if (!day || !month || !year)    
        return false;  // check for bisestile year  
        
    if (year/4 == parseInt(year/4))   
        monthLength[1] = 29;  
    if (month < 1 || month > 12)    
        return false;  
    if (day > monthLength[month-1])    
        return false;    
        
    return true;
}

function findDelimiter(field)
{
    if (field.indexOf('/')) return '/';
    if (field.indexOf('\\')) return '\\';
    if (field.indexOf('-')) return '-';
    if (field.indexOf('.')) return '.';
    if (field.indexOf(' ')) return ' ';
    
    return '|';
}

function ValidateEmail(str) 
{
	var at="@", dot=".";
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	
	if (str.indexOf(at)==-1) return false;
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
	if (str.indexOf(at,(lat+1))!=-1) return false;
    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false;
	if (str.indexOf(dot,(lat+2))==-1) return false;
	if (str.indexOf(" ")!=-1) return false;

    return true;
}


