﻿/// <reference path="jquery-1.3.2-vsdoc.js" />
function loadSlide() {

    var slideNo = 0;

    slideNo = Math.round((Math.random() * 5) + (Math.random() * 5));
    
    if (slideNo > 1 && slideNo < 9)
    {
        if ($("#home-search") != undefined) {
            $("#home-search").css("background", "transparent url(/images/home-bg-" + slideNo + ".jpg) no-repeat scroll 0 0");
        }
    }

}

function blockNullEntry(inputName, positionName) {

    var corners = [
       'bottomLeft', 'bottomRight', 'bottomMiddle',
       'topRight', 'topLeft', 'topMiddle',
       'leftMiddle', 'leftTop', 'leftBottom',
       'rightMiddle', 'rightBottom', 'rightTop'
    ];
    var opposites = [
       'topRight', 'topLeft', 'topMiddle',
       'bottomLeft', 'bottomRight', 'bottomMiddle',
       'rightMiddle', 'rightBottom', 'rightTop',
       'leftMiddle', 'leftTop', 'leftBottom'
    ];

    var chosenPos = 0;
    
    for (var i = 0; i < corners.length; i++) {
        if (positionName == corners[i]) {
            chosenPos = i;
            break;
        }
    }

    var booReturn = false;
    var searchVal = $("#" + inputName).val();

    if (searchVal != undefined) {

        if (searchVal.length == 0) {

            $("#" + inputName).qtip({
                content: "Please Enter a Search Term to Proceed", // Set the tooltip content to the current corner
                position: {
                    corner: {
                        tooltip: corners[chosenPos],      // Use the corner...
                        target: opposites[chosenPos]    // ...and opposite corner
                    }
                },
                show: {
                    when: { target: $("#" + inputName).parents("form"), event: "submit" }, // Don't specify a show event
                    ready: true // Show the tooltip when ready
                },
                hide: {
                    when: { target: $("#" + inputName), event: "focus" }
                }, // Don't specify a hide event
                style: {
                    width: 350,
                    border: {
                        width: 3,
                        radius: 10
                    },
                    padding: 10,
                    textAlign: 'center',
                    tip: true, // Give it a speech bubble tip with automatic corner detection
                    name: 'green' // Style it according to the preset 'cream' style
                }
            });
        }
        else {
            booReturn = true;
            if ($("#" + inputName).data("qtip"))    $("#" + inputName).qtip("destroy");
        }

    }

    return booReturn;
}

$(document).ready(function () { loadSlide(); });