//MV client-side scripts

//$(function() { $('a[@rel*=lightbox]').lightBox(); })// Select all links that contains lightbox in the attribute rel}


jQuery(document).ready(function() {
    $('.toggler475c').addClass('toggler475');
    $('.toggler475').click(function() {

        $(this).toggleClass('toggler475c');
        $(this).next().slideToggle('slow');

    }).next().hide();
  
    $('.toggler475').eq(0).addClass('toggler475c'); // open the first section
    $('.toggler475').eq(0).next().slideToggle('slow');


    $('a[rel^=lightbox]').lightBox(
       {
           imageLoading: '/images/loading.gif',
           imageBtnClose: '/images/closelabel.gif',
           imageBtnPrev: '/images/prevlabel.gif',
           imageBtnNext: '/images/nextlabel.gif'
       }
    );

});



   function flashFileLoad(paraID, fileloc, imageloc, strCaptionsFile, strLink, blnWidescreenFormat) {
       var intVideoHeight = 376;
       if (blnWidescreenFormat == "True") {
           intVideoHeight = 267;
       }
    jQuery(document).ready(function () {
        var s5 = new SWFObject("/flash/flvplayer.swf", "single", "475", intVideoHeight, "7");
        s5.addParam("allowfullscreen", "true");
        s5.addVariable("file", fileloc);
        s5.addVariable("image", imageloc);
        s5.addVariable("width", "475");
        s5.addVariable("height", intVideoHeight);
        if (strCaptionsFile != null && strCaptionsFile != "") {
            s5.addVariable("plugins", "captions-1");
            s5.addVariable("captions.file", strCaptionsFile);
        }
        if (strLink != null && strLink != "") {
            s5.addVariable("link", strLink);
            s5.addVariable("linktarget", "_self");
        }
        s5.write(paraID);
    });

}

function VideoDetails(pageID)
{
    alert('VideoDetailsStart5');
   var jsonRequest = new Request.JSON({
               headers: "{'Content-Type':'application/json;charset=UTF-8'}",
		       urlEncoded: false, 
                url: '/general.asmx/VideoDetails', 
                data: "{pageID:'"+ pageID +"'}",
                onFailure: function(t){
                    alert(t);
                
                    alert('failed');  
                },
                onSuccess: function(t,text){
                    
                    var details = JSON.decode(t.d);

 
                    alert(details.VidLocation);
                    alert(details.CapLocation);
                   
                }
                }                       
          );
          jsonRequest.post();

}

function pausecomp(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
} 

function InsertVideo(pageID, paraID){

   var jsonRequest = new Request.JSON({
               headers: "{'Content-Type':'application/json;charset=UTF-8'}",
		       urlEncoded: false, 
                url: '/general.asmx/VideoDetails', 
                data: "{pageID:'"+ pageID +"'}",
                onFailure: function(t){
                alert("We're sorry, but there was an error in retrieving the video " + pageID + ":" + t);  
                },
                onSuccess: function(t,text){
                    
                    var details = JSON.decode(t.d);
                    flashFileLoad(paraID, details.VidLocation, details.HoldImageLocation);
                    
                }
                }                       
          );
          jsonRequest.post();



}

function JSONCallTest(pageid) {
    alert(pageid);
    $.getJSON("http://localhost/general.asmx?videodetails", { pageID: "4329"}, function(json) {
        alert("JSON Data Found: ");
    });

}


/*
var MultipleOpenAccordion = new Class({
	Extends: Accordion,
	options: {
		openAll: false,	
		allowMultipleOpen: true


	},
	initialize: function(togglers,togglees,options){
	this.parent(togglers,togglees,this.options); 
	this.options.openAll = options.openAll;
	this.options.allowMultipleOpen = options.allowMultipleOpen;

	if (this.options.openAll && this.options.allowMultipleOpen) this.showAll();

	},
	/*	Property: showAll
		Opens all the elements in the accordion immediately; used on startup	*/
	/*showAll: function(){
      
    		if(this.options.allowMultipleOpen){
			this.elements.each(function(el,idx){
					this.display(idx);
			}, this);
	
		}
	},

	display: function(index){
		index = ($type(index) == 'element') ? this.elements.indexOf(index) : index;
		if ((this.timer && this.options.wait) || (index === this.previous && !this.options.alwaysHide)) return this;
		
		var obj = {};
		if(this.options.allowMultipleOpen){
			var el = this.elements[index];
			
			obj[index] = {};
			var hide = (el.offsetHeight > 0);
			
			this.fireEvent(hide ? 'onBackground' : 'onActive', [this.togglers[index], el]);
			if (hide) {
			    this.togglers[index].className='toggler475';
			}
			else
			{
			    this.togglers[index].className='toggler475c';
			}

			for (var fx in this.effects) obj[index][fx] = hide ? 0 : el[this.effects[fx]]; 
		}else{
			this.previous = index;
			this.elements.each(function(el, i){
				obj[i] = {};
				var hide = (i != index) || (this.options.alwaysHide && (el.offsetHeight > 0));
				this.fireEvent(hide ? 'onBackground' : 'onActive', [this.togglers[i], el]);
				if (hide) {
			         this.togglers[index].className='toggler475';
			    }
			    else {
			           this.togglers[index].className='toggler475c';
			    }
				for (var fx in this.effects) obj[i][fx] = hide ? 0 : el[this.effects[fx]];
			}, this);
			
		}
		return this.start(obj);
	}
});

*/
