/* CONFIGURATION AREA */
/*
	browsers:
		IE - Microsoft Internet Explorer
		FF - FireFox
		Safari - Safari browser
		Opera - Opera browser
		all - includes IE, FF, Opera and Safari
		
	parentId:
		any existing Id attribute 
	tagName:
		any valid tag name
	tagPosition:
		all - all inner elements 
		children - first level children only
	className:
		any valid class name
*/

var browsers = 'all';

if(typeof(config) == 'undefined') config = {};
config.hovers = new Array(
	{
		parentId:'menu',
		tagName:'li',
		tagPosition:'all',
		className:'hover'
	}
);


/* CODE AREA */

/* hovers */

var initHovers = function()
{
	for (var index in config.hovers){
		var conf = config.hovers[index];
		var topLevelElement = document.getElementById(conf.parentId);
		if (topLevelElement){
			var subElements = topLevelElement.getElementsByTagName(conf.tagName);
			for (var i = 0; i < subElements.length; i++){
				if (conf.tagPosition == 'all' || (conf.tagPosition == 'children' && subElements[i].parentNode.id == conf.parentId))
				{
					subElements[i].configIndex = index;
					subElements[i].onmouseover = function(){
						this.className += ' ' + config.hovers[this.configIndex].className;
					};
					subElements[i].onmouseout = function(){
						this.className = this.className.replace(config.hovers[this.configIndex].className,'');
					};
				}
			}
		}
	}
}

/* common */

var currentState = {};

var opera = window.opera;
var safari = navigator.appVersion.indexOf("Safari") != -1;
var ie = document.all && !window.opera;
var ff = navigator.userAgent.indexOf("Firefox") != -1;

var addEvent = function(browsers,event,initMethod)
{
	if (opera && (browsers.match(/Opera/) || browsers.match(/all/))) {
		window.addEventListener(event, initMethod, false);
	} else if (safari && (browsers.match(/Safari/) || browsers.match(/all/))) {
		window.addEventListener(event, initMethod, false);
	} else if (ie && (browsers.match(/IE/) || browsers.match(/all/))) {
		window.attachEvent("on" + event, initMethod);
	} else if (ff && (browsers.match(/FF/) || browsers.match(/all/))) {
		window.addEventListener(event, initMethod, false);
	} else if (!ie && !ff && !safari && !opera) {
		if (window.addEventListener){
			window.addEventListener(event, initMethod, false);
		}
		else if (window.attachEvent){
			window.attachEvent("on" + event, initMethod);
		}
	} 
}

addEvent(browsers,'load',initHovers);

function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=800,height=620,scrollbars=no,location=no,toolbar=no,titlebar=no,status=no,menubar=no');
return false;
}

function popup_viewer(link, windowname, title, filename){

    window.open(link+"?videoS="+filename+"&"+title, windowname, 'width=646,height=570,scrollbars=no,location=no,toolbar=no,titlebar=no,status=no,menubar=no');
    return false;
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}

function popup_gallery(link, windowname){

    window.open(link, windowname, 'width=646,height=570,scrollbars=no,location=no,toolbar=no,titlebar=no,status=no,menubar=no');
    return false;
}

function FindDealer(){

    var err = 0;
    if (document.frmDealer.city.value == '' || document.frmDealer.city.value == 'CITY'){
    err = err + 1;
    }
    if (document.frmDealer.state[document.frmDealer.state.selectedIndex].value == 'STATE ABBREVIATION'){
    err = err + 1;
    }
    if (document.frmDealer.zipcode.value == '' || document.frmDealer.zipcode.value == 'ZIP CODE'){
    err = err + 1;
    }
    if (err == 3){
        alert('You must enter a city and state or zipcode to continue.');
    }else{
        document.frmDealer.submit();
    }
}

function FindDealerByZip(){
    var err = 0;
    if (document.frmFindDealerByZip.zipcode.value == '' || document.frmFindDealerByZip.zipcode.value == 'ZIP CODE'){
    err = err + 1;
    }
    if (err == 1){
        alert('You must enter a zipcode to continue.');
    }else{
        document.frmFindDealerByZip.action = "/DealerLocator/SearchResults.asp";
        document.frmFindDealerByZip.submit();
    }
}

function SubmitSearch(){
    var err = 0;
    if (document.frmSiteSearch.SearchTerm.value == '' || document.frmSiteSearch.SearchTerm.value == 'SEARCH'){
    err = err + 1;
    }
    if (err == 1){
        alert('You must enter a search term to continue.');
        return false;
    }else{
        document.frmSiteSearch.action = "/SiteSearch/SearchResults.asp";
        document.frmSiteSearch.submit();
    }
}

function FindIntDealer(){

    var err = 0;
    if (document.intForm.stateprovince.options[document.intForm.stateprovince.selectedIndex].value == 'COUNTRY ABBREVIATION'){
    err = err + 1;
    }
    if (err == 1){
        alert('You must select an international location to continue.');
    }else{
        document.intForm.submit();
    }
}

function clearCity() {
queryBox = document.getElementById('city');
if( queryBox.value == 'CITY' ) 
queryBox.value = '';
}

function clearSearch() {
queryBox = document.getElementById('search');
if( queryBox.value == 'SEARCH' ) 
queryBox.value = '';
}

function clearZip() {
queryBox = document.getElementById('zipcode');
if( queryBox.value == 'ZIP CODE' ) 
queryBox.value = '';
}

function clearState() {
queryBox = document.getElementById('state');
if( queryBox.value == 'STATE ABBREVIATION' ) 
queryBox.value = '';
}

function SubmitDockQuestionairre(){
    var err = "0";

    if (document.frmDocQuest.firstname.value == 'FIRST NAME' || document.frmDocQuest.firstname.value == '') {
        err = "1";
    }
    if (document.frmDocQuest.lastname.value == 'LAST NAME' || document.frmDocQuest.lastname.value == '') {
        err = "1";
    }
    if (document.frmDocQuest.email.value == 'EMAIL' || document.frmDocQuest.email.value == '') {
        err = "1";
    }
    if (err == "0") {
        if (document.frmDocQuest.firstname.value == 'FIRST NAME') {
            document.frmDocQuest.firstname.value = '';
        }
        if (document.frmDocQuest.lastname.value == 'LAST NAME') {
            document.frmDocQuest.lastname.value = '';
        }
        if (document.frmDocQuest.phone.value == 'PRIMARY PHONE') {
            document.frmDocQuest.phone.value = '';
        }
        if (document.frmDocQuest.email.value == 'EMAIL') {
            document.frmDocQuest.email.value = '';
        }
        if (document.frmDocQuest.address1.value == 'ADDRESS 1') {
            document.frmDocQuest.address1.value = '';
        }
        if (document.frmDocQuest.address2.value == 'ADDRESS 2') {
            document.frmDocQuest.address2.value = '';
        }
        if (document.frmDocQuest.zipcode.value == 'ZIP CODE') {
            document.frmDocQuest.zipcode.value = '';
        }
        if (document.frmDocQuest.bodyofwater.value == 'BODY OF WATER') {
            document.frmDocQuest.bodyofwater.value = '';
        }
        if (document.getElementById("dock-other").value == 'OTHER') {
            document.getElementById("dock-other").value = '';
        }
        if (document.getElementById("usage-other").value == 'OTHER') {
            document.getElementById("usage-other").value = '';
        }
        if (document.frmDocQuest.docklength.value == 'DESIRED DOCK LENGTH') {
            document.frmDocQuest.docklength.value = '';
        }
        if (document.frmDocQuest.waterdepth.value == 'WATER DEPTH AT LENGTH') {
            document.frmDocQuest.waterdepth.value = '';
        }    
        document.frmDocQuest.action = "/questionairre/emaildock.asp";
        document.frmDocQuest.submit();
    } else {
        alert('Please enter your name and email address so we can get in touch with you about your request.');
    }
}


function SubmitLiftQuestionairre(){
    var err = "0";

    if (document.frmLiftQuest.firstname.value == 'FIRST NAME' || document.frmLiftQuest.firstname.value == '') {
        err = "1";
    }
    if (document.frmLiftQuest.lastname.value == 'LAST NAME' || document.frmLiftQuest.lastname.value == '') {
        err = "1";
    }
    if (document.frmLiftQuest.email.value == 'EMAIL' || document.frmLiftQuest.email.value == '') {
        err = "1";
    }

    if (err == "0") {
        if (document.frmLiftQuest.firstname.value == 'FIRST NAME') {
            document.frmLiftQuest.firstname.value = '';
        }
        if (document.frmLiftQuest.lastname.value == 'LAST NAME') {
            document.frmLiftQuest.lastname.value = '';
        }
        if (document.frmLiftQuest.phone.value == 'PRIMARY PHONE') {
            document.frmLiftQuest.phone.value = '';
        }
        if (document.frmLiftQuest.email.value == 'EMAIL') {
            document.frmLiftQuest.email.value = '';
        }
        if (document.frmLiftQuest.address1.value == 'ADDRESS 1') {
            document.frmLiftQuest.address1.value = '';
        }
        if (document.frmLiftQuest.address2.value == 'ADDRESS 2') {
            document.frmLiftQuest.address2.value = '';
        }
        if (document.frmLiftQuest.zipcode.value == 'ZIP CODE') {
            document.frmLiftQuest.zipcode.value = '';
        }
        if (document.frmLiftQuest.bodyofwater.value == 'BODY OF WATER') {
            document.frmLiftQuest.bodyofwater.value = '';
        }
        if (document.frmLiftQuest.boatlength.value == 'BOAT LENGTH') {
            document.frmLiftQuest.boatlength.value = '';
        }
        if (document.frmLiftQuest.boatweight.value == 'BOAT WEIGHT') {
            document.frmLiftQuest.boatweight.value = '';
        }
        if (document.frmLiftQuest.beam.value == 'BEAM') {
            document.frmLiftQuest.beam.value = '';
        }
        if (document.frmLiftQuest.brand.value == 'BRAND') {
            document.frmLiftQuest.brand.value = '';
        }
        if (document.frmLiftQuest.modelyear.value == 'YEAR') {
            document.frmLiftQuest.modelyear.value = '';
        }
        if (document.frmLiftQuest.model.value == 'MODEL') {
            document.frmLiftQuest.model.value = '';
        }

        document.frmLiftQuest.action = "/questionairre/emaillift.asp";
        document.frmLiftQuest.submit();
    } else {
        alert('Please enter your name and email address so we can get in touch with you about your request.');
    }
}
