﻿// Download Variables
var xtimerid;
var DownloadPlatform;
var x2timerid;
// End Download Variables

function ShowFloater(FloaterName) {
    var LockPane = 'DivLock';

    // Change Style to Make Visible/Invisible
    if (document.getElementById(FloaterName).style.display == "none") {
        document.getElementById(FloaterName).style.display = "block";
        document.getElementById(LockPane).style.display = "block";
    }
    else {
        document.getElementById(FloaterName).style.display = "none";
        document.getElementById(LockPane).style.display = "none";
    }

}

// Button Click Event Handler
function ButtonClick(sender, e) {
    __doPostBack(sender, e);
} 

function ShowProduct(Product) {
    var ElementName = Product + 'Div';
    var LockName = 'DivLock';

    // Change Style to Make Visible/Invisible
    if (document.getElementById(ElementName).style.display == "none") {
        document.getElementById(ElementName).style.display = "block";
        document.getElementById(LockName).style.display = "block";
    }
    else {
        document.getElementById(ElementName).style.display = "none";
        document.getElementById(LockName).style.display = "none";
    }
}
function ShowProductDiv(ProductDiv) {
    var ElementName = ProductDiv;
    var LockName = 'DivLock';

    // Change Style to Make Visible/Invisible
    if (document.getElementById(ElementName).style.display == "none") {
        document.getElementById(ElementName).style.display = "block";
        document.getElementById(LockName).style.display = "block";
    }
    else {
        document.getElementById(ElementName).style.display = "none";
        document.getElementById(LockName).style.display = "none";
    }
}
function DownloadHomePage()
{
x2timerid=self.setTimeout('DownloadHome()',10000);
}

function DownloadHome()
{
self.clearInterval(x2timerid);
window.location="../Default.aspx";
}

function StartDownload(Platform) {
    DownloadPlatform = Platform;
    xtimerid = self.setTimeout('Download()', 1500);  
}

function Download() {
    self.clearTimeout(xtimerid);
    window.location = "/store/autodownload.aspx?platform=" + DownloadPlatform.toString().toLowerCase();
}

function openWindow(page, status, scroll, width, height) {
    window.open(page, "Window", "status=" + status + ",scrollbars=" + scroll + ",width=" + width + ",height=" + height);
}

function ResizeBrowser() {
    window.resizeTo(1024, 768);
}

//Homepage flash videos
function openFlash(movie) {
    if (movie == 'teacher')
        window.open("/Media/Teachers_and_Students/teacher.htm", "SmartMusic", "status=none,scrollbars=no,width=540,height=304");
    if (movie == 'content')
        window.open("/Media/Teachers_and_Students/content.htm", "SmartMusic", "status=none,scrollbars=no,width=540,height=304");
    if (movie == 'parent')
        window.open("/Media/Teachers_and_Students/parent.htm", "SmartMusic", "status=none,scrollbars=no,width=540,height=304");
    if (movie == 'admin')
        window.open("/Media/Teachers_and_Students/admin.htm", "SmartMusic", "status=none,scrollbars=no,width=540,height=304");
    if (movie == 'experience')
        window.open("/Media/Teachers_and_Students/experience.htm", "SmartMusic", "status=none,scrollbars=no,width=540,height=304");
    if (movie == 'tour')
        window.open("/Media/SM2011_Tour/SM2011_Tour.html", "SmartMusic", "status=none,scrollbars=no,width=740,height=600");
}

//Wynton Marsalis videos
function stream(file,qlt) {
	var strURLw = 'mms://wm.streamingmediahosting.com/makemusic/'+file+'_'+qlt+'.wmv'; // Stream on Partner Streaming server
	//var strURLm = 'rtsp://qt.partner-streaming.com/makemusic/'+file+'_'+qlt+'.mov';
	var strURLm = 'rtsp://qt.streamingmediahosting.com/makemusic/' + file + '_' + qlt + '.mov'; // Stream on QuickTime server
	if(navigator.platform == "Win32") {
		document.location = strURLw;	
	} else {
		document.location = strURLm;
	}
}

function InitRollOvers() {
    $(function () {
        $('img[data-hover]').hover(function () {
            $(this).attr('tmp', $(this).attr('src')).attr('src', $(this).attr('data-hover')).attr('data-hover', $(this).attr('tmp')).removeAttr('tmp');
        }).each(function () {
            $('<img />').attr('src', $(this).attr('data-hover'));
        }); ;
        $('input[data-hover]').hover(function () {
            $(this).attr('tmp', $(this).attr('src')).attr('src', $(this).attr('data-hover')).attr('data-hover', $(this).attr('tmp')).removeAttr('tmp');
        }).each(function () {
            $('<input />').attr('src', $(this).attr('data-hover'));
        }); ;
    });
}


function getInnerText(spanTag) {
    var text = "";
    try {
        //IE
        if (document.all) {
            text = spanTag.innerText;
        }
        else //Firefox
        {
            text = spanTag.innerHTML;
        }
    }
    catch (e) { }
    return text;
}
function setinnerText(spanTag, text) {
    //IE
    if (document.all) {
        spanTag.innerText = text;
    }
    else {
        //Firefox
        if (text == '') {
            //FF won't reserve space for empty text
            spanTag.innerHTML = '&nbsp;';
        }
        else {
            spanTag.innerHTML = text;
        }
    }
}

function ValidateBirthDate(source, args) {    
    var Year=parseInt($('#ddlYear').val());
    var Month = parseInt($('#ddlMonth').val());
    if (Year != NaN && Month != NaN) {
        var TotalMonths = (( ((new Date).getFullYear()) - (Year + 1) ) * 12) +  ((new Date).getMonth() + 2) + (12 - Month);
        args.IsValid = (TotalMonths >= 157);
    }
    else {
        args.IsValid = false;
    }
}

function SetDefaultFocus() {
    var id = "";
    $('input[data-required], select[data-required]').each(function () {
        if ($(this).val().length == 0) {
            if (id.length == 0) {
                id = "#" + $(this).attr('id');
            }
        }
    });
    $(id).focus();
}

function ee() {
    var c = GetCookie("E").toString();
    if (c.indexOf("@smartmusic.com") > 0) {
//        $("#MainTable").attr("style", "background-image: url('/Images/ChzBurger.png'); background-repeat: no-repeat; background-position: center center;");
        $(".MiniCart").draggable();
    }
}

function GetCookie(sName) {
    // cookies are separated by semicolons
    var aCookie = document.cookie.split("; ");
    for (var i = 0; i < aCookie.length; i++) {
        // a name/value pair (a crumb) is separated by an equal sign
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0])
            return unescape(aCrumb[1]);
    }
    // a cookie with the requested name does not exist
    return null;
}
