/****************************************************************
 *                                                              *
 * Moc 10 Media                                                 *
 * A Division of The Working Man Group, L.L.C.                  *
 * http://www.moc10media.com/                                   *
 *                                                              *
 * Script Name: scripts.js                                      *
 * Script Version: 1.0                                          *
 * Script Info: Basic Config/Load Scripts                       *
 *                                                              *
 ****************************************************************/

// Function to preload images.

function preLoad() {
	if (document.images) {
        aboutoff = new Image();
        aboutoff.src = "/img/nav/about_off.gif";
        contactoff = new Image();
        contactoff.src = "/img/nav/contact_off.gif";
        newsoff = new Image();
        newsoff.src = "/img/nav/news_off.gif";
        portfoliooff = new Image();
        portfoliooff.src = "/img/nav/portfolio_off.gif";
        servicesoff = new Image();
        servicesoff.src = "/img/nav/services_off.gif";

        abouton = new Image();
        abouton.src = "/img/nav/about_on.gif";
        contacton = new Image();
        contacton.src = "/img/nav/contact_on.gif";
        newson = new Image();
        newson.src = "/img/nav/news_on.gif";
        portfolioon = new Image();
        portfolioon.src = "/img/nav/portfolio_on.gif";
        serviceson = new Image();
        serviceson.src = "/img/nav/services_on.gif";
    }
}

// Function to create dynamic pop up window, currently set to center window on screen.

function newWindow(url, name, wid, hgt, scr, res, stat, loc, mnu, tool, x, y) {
    if (screen) {
        widthOfScreen = screen.width;
        heightOfScreen = screen.height;
    }
    if ((x == null) || (y == null)) {
        midX = widthOfScreen / 2;
        midY = heightOfScreen / 2;
        midWid = wid / 2;
        midHgt = hgt / 2;
        x = midX - midWid;
        y = midY - midHgt;
    }
    windowOpts = "width=" + wid + ",height=" + hgt + ",scrollbars=" + scr + ",resizable=" + res + ",status=" + stat + ",location=" + loc + ",menubar=" + mnu + ",toolbar=" + tool + ",left=" + x + ",top=" + y;
    popUpWindow = window.open(url, name, windowOpts);
}

// Function to dynamically write out the flash code to work around the IE flash "white box" issue.

function flashBanner(name, width, height) {
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '" id="' + name + '" align="middle">');
    document.write('    <param name="allowScriptAccess" value="sameDomain" />');
    document.write('    <param name="movie" value="/swf/' + name + '" />');
    document.write('    <param name="quality" value="high" />');
    document.write('    <param name="wmode" value="transparent" />');
    document.write('    <param name="bgcolor" value="#01325b" />');
    document.write('    <embed src="/swf/' + name + '" quality="high" wmode="transparent" bgcolor="#01325b" width="' + width + '" height="' + height + '" name="' + name + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    document.write('    </embed>');
    document.write('</object>');
}

// Set the window onload function

// Set the window onload function, checking to make sure an older function isn't overwritten

var oldonload = window.onload;
if (typeof window.onload != 'function'){
    window.onload = function() {
        preLoad();
        initMenus();
    }
} else {
    window.onload = function(){
    oldonload();
    preLoad();
    initMenus();
    }
}

// Validate the form

function validate(obj) {
    formId = document.getElementById(obj);

    if (formId.name.value.length < 1) {
	    alert("Please enter your name.");
	    formId.name.focus();
	    return false;
    }
    if ((formId.email.value.indexOf("@") == -1) || (formId.email.value.indexOf(".") == -1) || (formId.email.value.length < 5))  {
	    alert("Please enter a valid email.");
	    formId.email.focus();
	    return false;
    }
    if (formId.subject.value.length < 1) {
	    alert("Please enter a subject.");
	    formId.subject.focus();
	    return false;
    }
    if (formId.message.value.length < 1) {
	    alert("Please enter a message.");
	    formId.message.focus();
	    return false;
    }

    return true;
}