﻿//var jlang = 'cy';
var lang = (jlang != 'undefined') ? jlang : 'cy';


var dom = {};
dom.query = jQuery.noConflict(true);

// var dom = {};
// dom.query = jQuery.noConflict(true);

dom.query(document).ready(function () {


  


    /*
    *   Examples - various
    */
    if (document.getElementById('fancybox') != null) {
        document.getElementById('fancybox').style.display = 'none';


    }

    dom.query(".gwybodaeth-popup").fancybox({
        'titlePosition': 'inside',
        'transitionIn': 'none',
        'transitionOut': 'none'
    });

    dom.query("a.single_image").fancybox();

    //Fideo Selector IF NO Flash  $("#slide").animate({width:'toggle'},350);
    if (document.getElementById('vid-holder') != null) {
        document.getElementById('vid-holder').style.overflow = 'hidden';
        document.getElementById('flash-video-selector').style.height = '264px';
        document.getElementById('flash-video-selector').style.overflow = 'hidden';

        dom.query('#left').click(function () {

            dom.query('#vid-holder').animate({ left: 0 });

        });

        dom.query('#right').click(function () {

            dom.query('#vid-holder').animate({ left: -228 });

        });



    }

    document.getElementById('cyswllt-off').style.display = 'none';
    document.getElementById('cyswllt').style.display = 'block';

    //dom.query("div#dropdown-header").animate({ height: "200px" }, "fast").animate({ height: "0px" }, "slow");

    dom.query("#cyswllt").click(function () {
        document.getElementById('cyswllt-off').style.display = 'block';
        // myFx.start(0, 188);
        // expand = true;
        dom.query("div#dropdown-header").animate({ height: "200px" }, "slow").animate({ height: "188px" }, "fast");
        document.getElementById('cyswllt').style.display = 'none';

        //dom.query("div#cyswllt").toggle();
    });




    dom.query("#cyswllt-off").click(function () {
        //myFx.start(188, 0);
        //expand = true;
        dom.query("div#dropdown-header").animate({ height: "200px" }, "fast").animate({ height: "0px" }, "slow");
        document.getElementById('cyswllt-off').style.display = 'none';
        document.getElementById('cyswllt').style.display = 'block';
        // dom.query("div#cyswllt-off").toggle();
    });

    //

    //ACCORDION BUTTON ACTION	
    var togglerString = ".toggler" + lang;


    dom.query(togglerString).click(function () {

        //dom.query("div.element").slideUp('normal');
        // alert("!!: " + dom.query(this).parent().next().html());
        dom.query(this).parent().next().slideDown();


        if (dom.query(this).parent().attr("class") == "headoff") {
            dom.query(this).parent().next().slideUp('normal');
            dom.query(this).html((jlang == 'cy') ? 'Darllen' : 'Read')
            //alert("!!: " + dom.query("span").html());
            dom.query(this).parent().removeClass("headoff").addClass("head");

        } else {
            dom.query(this).parent().next().slideDown('slow');

            dom.query(this).html((jlang == 'cy') ? 'Cau' : 'Close')
            dom.query(this).parent().removeClass("head").addClass("headoff");

        };

        //dom.query(this).attr("class" , "off");
        //alert("!!: " + dom.query(this).attr("class" , "off"));

    });



    //HIDE THE DIVS ON PAGE LOAD	
    dom.query("div.element").hide();

    function hide(p_togler) {
        if (p_togler != 'undefined') {
            p_togler.innerHTML = (jlang == 'cy') ? 'Cau' : 'Close';
        }
    }

    function show(p_togler) {
        if (p_togler != 'undefined') {
            p_togler.innerHTML = (jlang == 'cy') ? 'Darllen' : 'Read';
        }
    }



});


   


     

function MoreInfo_Clicked(p_id) {

    dom.query('#box-gwybodaeth').html("");
    dom.query('.gwybodaeth-popup').trigger('click');
    var jsonText = "{courseID:"+p_id+"}";

    dom.query.ajax({
        type: "POST",
        url: "/assets/webmethod/GwybodaethCwrs.asmx/GetGwybodaethCwrs",
        data: jsonText,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            dom.query('#box-gwybodaeth').html(msg.d);
        },
        error: function (msg) {
            alert("Error: "+msg.d);
        }
    });
            
           
            
}
