﻿function getKeyCode(e) {

    if (window.event)
        return window.event.keyCode;
    else if (e)
        return e.which;
    else
        return null;
}
    
function Rejected(fileName, size, maxSize){
  var addMessage = (maxSize >= 0)?("exceeds "+maxSize+" bytes"):("-- session lost");
  alert("File "+fileName+" is rejected \nIts size ("+size+" bytes) "+addMessage);
}
function ClearedFiles(fileNames){
  alert("Invalid Video File:\n\n"+fileNames);
}

function uploaderReady() {
    document.getElementById('statusbox').innerHTML = 'ready';
    document.getElementById('statusbox').style.color = '#080';
}


function uploaderBusy() {
    document.getElementById('statusbox').innerHTML = 'busy';
    document.getElementById('statusbox').style.color = '#880';

}


function uploaderMaxReached() {
    document.getElementById('statusbox').innerHTML = 'limit reached';
    document.getElementById('statusbox').style.color = '#800';

}

function fixH(one, two) {
    if (document.getElementById(one)) {
        var lh = document.getElementById(one).offsetHeight;
        var rh = document.getElementById(two).offsetHeight;
        var nh = Math.max(lh, rh);
        document.getElementById(one).style.height = nh + "px";
        document.getElementById(two).style.height = nh + "px";
    }
}

function EnablePhotoUpload() {

//    var imCounter = parseInt(document.getElementById('imCounter').value);

//    if (imCounter == 0) {
//        if (document.getElementById('ctl00_ContentPlaceHolder1_CBox_tandc').checked) {
//            document.getElementById('ctl00_ContentPlaceHolder1_btnSubmit').disabled = false;
//        }
//        else {
//            document.getElementById('ctl00_ContentPlaceHolder1_btnSubmit').disabled = true;
//        }
//    }
//    else if (document.getElementById('ctl00_ContentPlaceHolder1_CBox_permission').checked && document.getElementById('ctl00_ContentPlaceHolder1_CBox_tandc').checked) {
//        document.getElementById('ctl00_ContentPlaceHolder1_btnSubmit').disabled = false;
//    }
//    else {
//        document.getElementById('ctl00_ContentPlaceHolder1_btnSubmit').disabled = true;
//    }
    }

function ShowPhoto(pic1) {
    var panelV = document.getElementById('ctl00_ContentPlaceHolder1_pnlVideo');
    panelV.style.display = "none";
    var panelP = document.getElementById('ctl00_ContentPlaceHolder1_pnlPhoto');
    panelP.style.display = "block";
     document.getElementById('mainImage').src = pic1;
}

function ShowVideo() {
    var panelV = document.getElementById('ctl00_ContentPlaceHolder1_pnlVideo');
    panelV.style.display = "block";
    var panelP = document.getElementById('ctl00_ContentPlaceHolder1_pnlPhoto');
    panelP.style.display = "none";
}

function clearFileInputs() {

    // get all inputs

    var inp = document.getElementsByTagName("input");

    for (var i = 0; i < inp.length; i++) {

        var el = inp[i];

        // input with type 'file' only and not empty

        if (el.type == "file" && el.value != "") {

            // clear it

            if (document.all && !window.opera) {

                el.parentNode.insertBefore(el.cloneNode(false), el);

                el.parentNode.removeChild(el);

            }

            else {

                var new_span = document.createElement("SPAN");

                el.parentNode.insertBefore(new_span, el);

                new_span.appendChild(el);

                new_span.innerHTML = new_span.innerHTML;

                new_span.parentNode.insertBefore(new_span.firstChild, new_span);

                new_span.parentNode.removeChild(new_span);

            }

        }

    }

    return true;
}

function validateKey(e) {

    var key = getKeyCode(e);

    if (key == null) return true;

    // Digits
    // Comment / remove this "if" statement if you don't want to allow digits
    if (key >= 48 && key <= 57) {
        return true;
    }

    // Letters
    // Comment / remove this "if" statement if you don't want to allow letters
    //    if ((key >= 65 && key <= 90) || (key >= 97 && key <= 122)) {
    //        return true;
    //    }


    if (key == null || key == 0 || key == 8 || key == 9 || key == 13 || key == 27) {
        return true;
    }

    return false;
}

function textboxMultilineMaxNumber(txt, maxLen) {
    try {
        if (txt.value.length > (maxLen - 1)) return false;
    } catch (e) {
    }
}

function Count(text, long) {

    var maxlength = new Number(long);

    if (text.value.length > maxlength) {

        text.value = text.value.substring(0, maxlength);
        return false;
    }
}


function validateKeyHeight(e) {

    var key = getKeyCode(e);

    if (key == null) return true;

    // Digits
    // Comment / remove this "if" statement if you don't want to allow digits
    if (key >= 48 && key <= 57) {
        return true;
    }

    if (key == null || key == 0 || key == 8 || key == 9 || key == 13 || key == 27 || key == 39) {
        return true;
    }

    return false;
}


function onEmptyCommand(record) {
}

function TimeOutRedirect() {

    try {
        if (self.parent.frames.length != 0)
            self.parent.location = document.location;

        parent.location = "confirmation.aspx";

    }
    catch (Exception) { }

}
		
function Navigate(callbackPanelName, containerName, pageName, itemid) {
    ClearMenus();
    ob_post.UpdatePanelFromPage(callbackPanelName, containerName, pageName);
    ob_em_SelectItem(itemid);
}
function NavigateSearch(callbackPanelName, containerName, pageName,textbox) {
    var strkeyword = document.getElementById(textbox).value;
    ob_post.UpdatePanelFromPage(callbackPanelName, containerName, pageName + '?v=' + strkeyword);
    ClearMenus();
}
function showDiv(divID) {
    e = document.getElementById(divID);
    if (e.style.display == "none") {
        e.style.display = "block";
    }
    else {
        e.style.display = "none";
    }
}
function ClearMenus(){
    ob_em_DeselectItem('mhome');
    ob_em_DeselectItem('mAboutUs');
    ob_em_DeselectItem('mAdvertising');
    ob_em_DeselectItem('mAdvert');
    ob_em_DeselectItem('mMyAccount');
    ob_em_DeselectItem('mLinks');
    ob_em_DeselectItem('mContactUs');
    ob_em_DeselectItem('mhorses');
    ob_em_DeselectItem('mtrailers');
    ob_em_DeselectItem('mboxes');
    ob_em_DeselectItem('mstallions');
    ob_em_DeselectItem('mdirectory');
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

   function RefreshItemsPerPage(pagename)
   
   {
       var ItemsPerPage = document.getElementById('ddlitems').value;
       var URL = pagename + ".aspx?v=0&it=" + ItemsPerPage;
       alert("hello2");
       //Navigate('callbackPanel', 'container', URL, menuitem);
    }

    //***********************************************************************************************************

    /***********************************************
    * Ultimate Fade-In Slideshow (v1.51): © Dynamic Drive (http://www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit http://www.dynamicdrive.com/ for this script and 100s more.
    ***********************************************/

    var fademaster1 = new Array()
    //SET IMAGE PATHS. Extend or contract array as needed
    fademaster1[0] = ["Images/ST001.jpg", "", ""]
    fademaster1[1] = ["Images/ST002.jpg", "", ""]
    fademaster1[2] = ["Images/ST003.jpg", "", ""]
    fademaster1[3] = ["Images/ST004.jpg", "", ""]
    fademaster1[4] = ["Images/ST005.jpg", "", ""]

    var fademaster2 = new Array()
    //SET IMAGE PATHS. Extend or contract array as needed
    fademaster2[0] = ["Images/ST006.jpg", "", ""]
    fademaster2[1] = ["Images/ST007.jpg", "", ""]
    fademaster2[2] = ["Images/ST008.jpg", "", ""]
    fademaster2[3] = ["Images/ST009.jpg", "", ""]
    fademaster2[4] = ["Images/ST010.jpg", "", ""]

    var fademaster3 = new Array()
    //SET IMAGE PATHS. Extend or contract array as needed
    fademaster3[0] = ["Images/ST011.jpg", "", ""]
    fademaster3[1] = ["Images/ST012.jpg", "", ""]
    fademaster3[2] = ["Images/ST013.jpg", "", ""]
    fademaster3[3] = ["Images/ST014.jpg", "", ""]
    fademaster3[4] = ["Images/ST015.jpg", "", ""]

    var fademaster4 = new Array()
    //SET IMAGE PATHS. Extend or contract array as needed
    fademaster4[0] = ["Images/ST016.jpg", "", ""]
    fademaster4[1] = ["Images/ST017.jpg", "", ""]
    fademaster4[2] = ["Images/ST018.jpg", "", ""]
    fademaster4[3] = ["Images/ST019.jpg", "", ""]
    fademaster4[4] = ["Images/ST020.jpg", "", ""]

    var fademaster5 = new Array()
    //SET IMAGE PATHS. Extend or contract array as needed
    fademaster5[0] = ["../Images/ST001.jpg", "", ""]
    fademaster5[1] = ["../Images/ST002.jpg", "", ""]
    fademaster5[2] = ["../Images/ST003.jpg", "", ""]
    fademaster5[3] = ["../Images/ST004.jpg", "", ""]
    fademaster5[4] = ["../Images/ST005.jpg", "", ""]

    var fademaster6 = new Array()
    //SET IMAGE PATHS. Extend or contract array as needed
    fademaster6[0] = ["../Images/ST006.jpg", "", ""]
    fademaster6[1] = ["../Images/ST007.jpg", "", ""]
    fademaster6[2] = ["../Images/ST008.jpg", "", ""]
    fademaster6[3] = ["../Images/ST009.jpg", "", ""]
    fademaster6[4] = ["../Images/ST010.jpg", "", ""]

    var fademaster7 = new Array()
    //SET IMAGE PATHS. Extend or contract array as needed
    fademaster7[0] = ["../Images/ST011.jpg", "", ""]
    fademaster7[1] = ["../Images/ST012.jpg", "", ""]
    fademaster7[2] = ["../Images/ST013.jpg", "", ""]
    fademaster7[3] = ["../Images/ST014.jpg", "", ""]
    fademaster7[4] = ["../Images/ST015.jpg", "", ""]

    var fademaster8 = new Array()
    //SET IMAGE PATHS. Extend or contract array as needed
    fademaster8[0] = ["../Images/ST016.jpg", "", ""]
    fademaster8[1] = ["../Images/ST017.jpg", "", ""]
    fademaster8[2] = ["../Images/ST018.jpg", "", ""]
    fademaster8[3] = ["../Images/ST019.jpg", "", ""]
    fademaster8[4] = ["../Images/ST020.jpg", "", ""]

    var fadebgcolor = "white"

    var fadearray = new Array() //array to cache fadeshow instances
    var fadeclear = new Array() //array to cache corresponding clearinterval pointers

    var dom = (document.getElementById) //modern dom browsers
    var iebrowser = document.all

    function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder) {
        this.pausecheck = pause
        this.mouseovercheck = 0
        this.delay = delay
        this.degree = 10 //initial opacity degree (10%)
        this.curimageindex = 0
        this.nextimageindex = 1
        fadearray[fadearray.length] = this
        this.slideshowid = fadearray.length - 1
        this.canvasbase = "canvas" + this.slideshowid
        this.curcanvas = this.canvasbase + "_0"
        if (typeof displayorder != "undefined")
            theimages.sort(function() { return 0.5 - Math.random(); }) //thanks to Mike (aka Mwinter) :)
        this.theimages = theimages
        this.imageborder = parseInt(borderwidth)
        this.postimages = new Array() //preload images
        for (p = 0; p < theimages.length; p++) {
            this.postimages[p] = new Image()
            this.postimages[p].src = theimages[p][0]
        }

        var fadewidth = fadewidth + this.imageborder * 2
        var fadeheight = fadeheight + this.imageborder * 2

        if (iebrowser && dom || dom) //if IE5+ or modern browsers (ie: Firefox)
            document.write('<div id="master' + this.slideshowid + '" style="position:relative;width:' + fadewidth + 'px;height:' + fadeheight + 'px;overflow:hidden;"><div id="' + this.canvasbase + '_0" style="position:absolute;width:' + fadewidth + 'px;height:' + fadeheight + 'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:' + fadebgcolor + '"></div><div id="' + this.canvasbase + '_1" style="position:absolute;width:' + fadewidth + 'px;height:' + fadeheight + 'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:' + fadebgcolor + '"></div></div>')
        else
            document.write('<div><img name="defaultslide' + this.slideshowid + '" src="' + this.postimages[0].src + '"></div>')

        if (iebrowser && dom || dom) //if IE5+ or modern browsers such as Firefox
            this.startit()
        else {
            this.curimageindex++
            setInterval("fadearray[" + this.slideshowid + "].rotateimage()", this.delay)
        }
    }

    function fadepic(obj) {
        if (obj.degree < 100) {
            obj.degree += 10
            if (obj.tempobj.filters && obj.tempobj.filters[0]) {
                if (typeof obj.tempobj.filters[0].opacity == "number") //if IE6+
                    obj.tempobj.filters[0].opacity = obj.degree
                else //else if IE5.5-
                    obj.tempobj.style.filter = "alpha(opacity=" + obj.degree + ")"
            }
            else if (obj.tempobj.style.MozOpacity)
                obj.tempobj.style.MozOpacity = obj.degree / 101
            else if (obj.tempobj.style.KhtmlOpacity)
                obj.tempobj.style.KhtmlOpacity = obj.degree / 100
            else if (obj.tempobj.style.opacity && !obj.tempobj.filters)
                obj.tempobj.style.opacity = obj.degree / 101
        }
        else {
            clearInterval(fadeclear[obj.slideshowid])
            obj.nextcanvas = (obj.curcanvas == obj.canvasbase + "_0") ? obj.canvasbase + "_0" : obj.canvasbase + "_1"
            obj.tempobj = iebrowser ? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
            obj.populateslide(obj.tempobj, obj.nextimageindex)
            obj.nextimageindex = (obj.nextimageindex < obj.postimages.length - 1) ? obj.nextimageindex + 1 : 0
            setTimeout("fadearray[" + obj.slideshowid + "].rotateimage()", obj.delay)
        }
    }

    fadeshow.prototype.populateslide = function(picobj, picindex) {
        var slideHTML = ""
        if (this.theimages[picindex][1] != "") //if associated link exists for image
            slideHTML = '<a href="' + this.theimages[picindex][1] + '" target="' + this.theimages[picindex][2] + '">'
        slideHTML += '<img src="' + this.postimages[picindex].src + '" border="' + this.imageborder + 'px">'
        if (this.theimages[picindex][1] != "") //if associated link exists for image
            slideHTML += '</a>'
        picobj.innerHTML = slideHTML
    }


    fadeshow.prototype.rotateimage = function() {
        if (this.pausecheck == 1) //if pause onMouseover enabled, cache object
            var cacheobj = this
        if (this.mouseovercheck == 1)
            setTimeout(function() { cacheobj.rotateimage() }, 100)
        else if (iebrowser && dom || dom) {
            this.resetit()
            var crossobj = this.tempobj = iebrowser ? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
            crossobj.style.zIndex++
            fadeclear[this.slideshowid] = setInterval("fadepic(fadearray[" + this.slideshowid + "])", 50)
            this.curcanvas = (this.curcanvas == this.canvasbase + "_0") ? this.canvasbase + "_1" : this.canvasbase + "_0"
        }
        else {
            var ns4imgobj = document.images['defaultslide' + this.slideshowid]
            ns4imgobj.src = this.postimages[this.curimageindex].src
        }
        this.curimageindex = (this.curimageindex < this.postimages.length - 1) ? this.curimageindex + 1 : 0
    }

    fadeshow.prototype.resetit = function() {
        this.degree = 10
        var crossobj = iebrowser ? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
        if (crossobj.filters && crossobj.filters[0]) {
            if (typeof crossobj.filters[0].opacity == "number") //if IE6+
                crossobj.filters(0).opacity = this.degree
            else //else if IE5.5-
                crossobj.style.filter = "alpha(opacity=" + this.degree + ")"
        }
        else if (crossobj.style.MozOpacity)
            crossobj.style.MozOpacity = this.degree / 101
        else if (crossobj.style.KhtmlOpacity)
            crossobj.style.KhtmlOpacity = this.degree / 100
        else if (crossobj.style.opacity && !crossobj.filters)
            crossobj.style.opacity = this.degree / 101
    }


    fadeshow.prototype.startit = function() {
        var crossobj = iebrowser ? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
        this.populateslide(crossobj, this.curimageindex)
        if (this.pausecheck == 1) { //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
            var cacheobj = this
            var crossobjcontainer = iebrowser ? iebrowser["master" + this.slideshowid] : document.getElementById("master" + this.slideshowid)
            crossobjcontainer.onmouseover = function() { cacheobj.mouseovercheck = 1 }
            crossobjcontainer.onmouseout = function() { cacheobj.mouseovercheck = 0 }
        }
        this.rotateimage()
    }
    function MM_swapImgRestore() { //v3.0
        var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
    }
    function MM_findObj(n, d) { //v4.01
        var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
            d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
        }
        if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
        for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
        if (!x && d.getElementById) x = d.getElementById(n); return x;
    }

    function MM_swapImage() { //v3.0
        var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
            if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
    }

    //***********************************************************************************************************


try
{
    if( Sys && Sys.Application ){
        Sys.Application.notifyScriptLoaded();
    }
}
catch(ex){}

// this event is fired before the menu is actually shown on the page
// menu - the menu that is being opened
// you can return false to prevent the menu from being displayed, or true to allow the open to continue
function ob_em_OnBeforeMenuOpen(menu)
{
	return true;
}

// this event is fired after the menu has been shown on the page
// menu - the menu that was opened
function ob_em_OnAfterMenuOpen(menu)
{
}

// this event is fired before the menu is closed
// menu - the menu that is being closed
// you can return false to prevent the menu from being closed, or true to allow the closing to continue
function ob_em_OnBeforeMenuClose(menu)
{
	alert('before menu close...')
	return true;
}

// this event is fired after the menu has been closed
// menu - the menu that was closed
function ob_em_OnAfterMenuClose(menu)
{
}

// this event is fired before the click on the item is processed
// item - the menu item that is being clicked
// menu - the menu to which the item belongs to
// element - the target element of this menu
// ev - the event that caused the click
// you can return false to prevent the item from being clicked, or true to allow the clicking to continue
function ob_em_OnBeforeItemClick(item, menu, element, ev)
{
	return true;
}

// this event is fired after the click on the item is processed
// item - the menu item that is being clicked
// menu - the menu to which the item belongs to
// element - the target element of this menu
// ev - the event that caused the click
function ob_em_OnAfterItemClick(item, menu, element, ev)
{
	alert('test');
}
