﻿var horses = new Array();

function addHorse(horseNumber, name, price, priceOption, studFee, color, breed, gender, age, height, temperament, location) {
    //alert("hello");
    var newHorse = new Array();
    newHorse.HorseNumber = horseNumber;
    newHorse.Name = name;
    newHorse.Price = price;
    newHorse.PriceOption = priceOption;
    newHorse.StudFee = studFee;
    newHorse.Color = color;
    newHorse.Breed = breed;
    newHorse.Gender = gender;
    newHorse.Age = age;
    newHorse.Height = height;
    newHorse.Temperament = temperament;
    newHorse.Location = location;
    horses[horses.length] = newHorse;
}



//Resize the Home Page
function ResizeHome()
{
    var contentDiv = document.getElementById("mainContentsDiv");
    var rcDiv = document.getElementById("rotatorNcontentsDiv");
    var rsDiv = document.getElementById("rotatorSection");
    height = document.documentElement.clientHeight - (15 + 64 + 20 + 42 + 10);
    if( height < 420)
        height = 420;
    contentDiv.style.height = height + "px";
    
    height = document.documentElement.clientHeight - (15 + 42 + 10);
    if( height < 504)
        height = 504;
    rcDiv.style.height = height + "px";
    rsDiv.style.height = height + "px";
}

function RotatorSpeedAdjust(fast) {
    if (fast) {
        window.clearInterval(rco_Rotator1.qzix);
        rco_Rotator1.ScrollInterval = 1;
        rco_Rotator1.qzix = window.setInterval('scroll_NextSlideToView(' + rco_Rotator1.GlobalID + ')', rco_Rotator1.ScrollInterval);
    }
    else {
        window.clearInterval(rco_Rotator1.qzix);
        rco_Rotator1.ScrollInterval = 50;
        //rco_Rotator1.qzix = window.setInterval('scroll_NextSlideToView('+rco_Rotator1.GlobalID+')', rco_Rotator1.ScrollInterval);
    }
}


function PopUpClose(evt) {

    var wnd = document.getElementById("info");
    wnd.style.display = "none";
}

function GetImageId(evt, arrayIndex) {
    var wnd = document.getElementById("info");
    wnd.style.top = (mouseY(evt) - 270) + 'px';
    wnd.style.left = (mouseX(evt) + 5) + 'px';
    wnd.style.display = "block";

    populateHorseData(arrayIndex);
}
function populateHorseData( arrayIndex) {
    document.getElementById("h-horseNumber").innerHTML = horses[arrayIndex].HorseNumber;
    document.getElementById("h-name").innerHTML = horses[arrayIndex].Name;
    document.getElementById("h-price").innerHTML = (horses[arrayIndex].Price > 0)? "$" + horses[arrayIndex].Price : "";
    document.getElementById("h-priceOption").innerHTML = horses[arrayIndex].PriceOption;
    document.getElementById("h-studFee").innerHTML = (horses[arrayIndex].StudFee > 0) ? "$" + horses[arrayIndex].StudFee : "";
    document.getElementById("h-color").innerHTML = horses[arrayIndex].Color;
    document.getElementById("h-breed").innerHTML = horses[arrayIndex].Breed;
    document.getElementById("h-gender").innerHTML = horses[arrayIndex].Gender;
    document.getElementById("h-age").innerHTML = horses[arrayIndex].Age;
    document.getElementById("h-height").innerHTML = horses[arrayIndex].Height;
    document.getElementById("h-temperament").innerHTML = horses[arrayIndex].Temperament;
    document.getElementById("h-location").innerHTML = horses[arrayIndex].Location;    
}
function mouseX(evt) {
    if (evt.pageX) return evt.pageX;
    else if (evt.clientX)

        return evt.clientX + (document.documentElement.scrollLeft ?
                   document.documentElement.scrollLeft :
                   document.body.scrollLeft);
    else return null;
}
function mouseY(evt) {
    if (evt.pageY) return evt.pageY;
    else if (evt.clientY)
        return evt.clientY + (document.documentElement.scrollTop ?
                   document.documentElement.scrollTop :
                   document.body.scrollTop);
    else return null;
    
}