function frmchng(value) {
    var select = document.getElementById("selectperpage");
    for (i = 0; i < select.length; i++) {
        if (select.options[i].value == value) {
            select.selectedIndex = i
        }
    }
}

function redirect(value) {

    window.location = "?page=0&perpage=" + value;
}





//============================ Standard text in textbox ============================

//onfocus = remName(this, 'voer hier de titel of isbn van het boek in en');
function remName(a, b) {
    if (a.value == b) {
        a.value = '';
    } else if (a.value == '') {
        a.value = b;
    } else {
        a.value = a.value;
    }
}

//onblur = chkName(this, 'voer hier de titel of isbn van het boek in en');
function chkName(a, b) {
    if (a.value == '') {
        a.value = b;
    } else {
        a.value = a.value;
    }
}

//============================ SHAREWARE DROPDOWN CATEGORY SWITCH =================

$(document).ready(function () {
    $(".sharewareGroups input").click(function () {
        var value = $(this).attr("value");
        $(".categoryList").hide()          
        $("." + value).fadeIn("slow");       
    });
});

//============================ SHAREWARE DROPDOWN CATEGORY SWITCH =================
function ConfirmBox(message, destination) {
    var agree = confirm(message);
    if (agree) {
        toParentProfile(destination); return false;
    }
    else {
        return false;
    }
}

//============================ Jquery Effect functions ============================


$(document).ready(function () {

    /*
    //BROWSE TWEETS IN TWEETBOX
    $(".btnTwLeft").click(function () {
    var currentpage = parseFloat($(this).attr("rel"));
    if (currentpage > 1) {

    $(".litw" + currentpage).hide();
    $(".litw" + (currentpage - 1)).fadeIn();

    $(this).attr("rel", (currentpage - 1));
    $(".btnTwRight").attr("rel", (currentpage - 1));

    if ((currentpage - 1) == 1) $(this).hide();
    if ($(".litw" + (currentpage)).length > 0) $(".btnTwRight").show();
    }
    });

    $(".btnTwRight").click(function () {
    var currentpage = parseFloat($(this).attr("rel"));

    $(".litw" + currentpage).hide();
    $(".litw" + (currentpage + 1)).fadeIn();

    $(this).attr("rel", (currentpage + 1));
    $(".btnTwLeft").attr("rel", (currentpage + 1));

    if ((currentpage + 1) > 1) $(".btnTwLeft").show();
    if ($(".litw" + (currentpage + 2)).length == 0) $(this).hide();

    });

    //BROWSE TWEETS IN TWEETBOX    
    $(".btnVcLeft").click(function () {
    var currentpage = parseFloat($(this).attr("rel"));
    if (currentpage > 1) {

    $(".vctw" + currentpage).hide();
    $(".vctw" + (currentpage - 1)).fadeIn();

    $(this).attr("rel", (currentpage - 1));
    $(".btnVcRight").attr("rel", (currentpage - 1));

    if ((currentpage - 1) == 1) $(this).hide();
    if ($(".vctw" + (currentpage)).length > 0) $(".btnVcRight").show();
    }
    });

    $(".btnVcRight").click(function () {
    var currentpage = parseFloat($(this).attr("rel"));

    $(".vctw" + currentpage).hide();
    $(".vctw" + (currentpage + 1)).fadeIn();

    $(this).attr("rel", (currentpage + 1));
    $(".btnVcLeft").attr("rel", (currentpage + 1));

    if ((currentpage + 1) > 1) $(".btnVcLeft").show();
    if ($(".vctw" + (currentpage + 2)).length == 0) $(this).hide();

    });*/


    //PLAY VIDEO FROM PLAYLIST
    $(".PlayVideo").click(function () {
        jwplayer("container").setup({
            flashplayer: "/usercontrols/jwplayer/player.swf",
            file: $(this).attr('rel'),
            height: 180,
            width: 320,
            skin: "/usercontrols/jwplayer/bekle.zip",
            plugins: { "sharing-3": { link: $(this).attr('rel') } }
        });
    });

    $(".PlayVideoPage").click(function () {
        jwplayer("container").setup({
            flashplayer: "/usercontrols/jwplayer/player.swf",
            file: $(this).attr('rel'),
            height: 301,
            width: 534,
            skin: "/usercontrols/jwplayer/bekle.zip",
            plugins: { "sharing-3": { link: $(this).attr('rel')} }        
        });
    });

    //VIMEA ADDITION
    $(".PlayVimeo").click(function () {
        jwplayer("container").setup({
            flashplayer: "/usercontrols/jwplayer/player.swf",
            type: "/usercontrols/jwplayer/vimeo.swf",
            file: $(this).attr('rel'),
            height: 180,
            width: 320,
            skin: "/usercontrols/jwplayer/bekle.zip",
            plugins: { "sharing-3": { link: $(this).attr('rel')} }
        });
    });

    $(".PlayVimeoPage").click(function () {
        jwplayer("container").setup({
            flashplayer: "/usercontrols/jwplayer/player.swf",
            type: "/usercontrols/jwplayer/vimeo.swf",
            file: $(this).attr('rel'),
            height: 301,
            width: 534,
            skin: "/usercontrols/jwplayer/bekle.zip",
            plugins: { "sharing-3": { link: $(this).attr('rel') } }
        });
    });




});


function OnSubmitForm(url)
{     
   document.getElementById('aspnetForm').action = url;
}





  //============================ FANCYBOX =======================
  $(document).ready(function () {
      $(".fancybackground").fancybox({
          'type': 'iframe',
          'overlayColor': '#000',
          'overlayOpacity': 0.7,
          'width': 360,
          'height': 330,
          'titleShow': true,
          'showCloseButton': false,
          'padding': 10,
          'titleFormat': formatTitle1
      });

      $(".fancylogin").fancybox({
          'type': 'iframe',
          'overlayColor': '#000',
          'overlayOpacity': 0.7,
          'width': 320,
          'height': 310,
          'titleShow': true,
          'showCloseButton': false,
          'padding': 10,
          'titleFormat': formatTitle2
      });

      $(".fancywachtwoord, .fancyemail, .fancyforum").fancybox({
          'type': 'iframe',
          'overlayColor': '#000',
          'overlayOpacity': 0.7,
          'width': 320,
          'height': 150,
          'titleShow': true,
          'showCloseButton': false,
          'padding': 10,
          'titleFormat': formatTitle2
      });

      $(".fancylidworden").fancybox({
          'type': 'iframe',
          'overlayColor': '#000',
          'overlayOpacity': 0.7,
          'width': 320,
          'height': 360,
          'titleShow': true,
          'showCloseButton': false,
          'padding': 10,
          'titleFormat': formatTitle2
      });

      $(".fancyavatar").fancybox({
          'type': 'iframe',
          'overlayColor': '#000',
          'overlayOpacity': 0.7,
          'width': 520,
          'height': 600,
          'titleShow': true,
          'showCloseButton': false,
          'padding': 10,
          'titleFormat': formatTitle5
      });

      $(".fancyupload").fancybox({
          'type': 'iframe',
          'overlayColor': '#000',
          'overlayOpacity': 0.7,
          'width': 420,
          'height': 600,
          'titleShow': true,
          'showCloseButton': false,
          'padding': 10,
          'titleFormat': formatTitle4
      });

      $(".fancydownload").fancybox({
          'type': 'iframe',
          'overlayColor': '#000',
          'overlayOpacity': 0.7,
          'width': 320,
          'height': 332,
          'titleShow': true,
          'showCloseButton': false,
          'padding': 10,
          'titleFormat': formatTitle2
      });

      $(".fancyupload, .fancyuploadlink").fancybox({
          'type': 'iframe',
          'overlayColor': '#000',
          'overlayOpacity': 0.7,
          'width': 420,
          'height': 420,
          'titleShow': true,
          'showCloseButton': false,
          'padding': 10,
          'titleFormat': formatTitle4
      });
           
  });
  

  function formatTitle1(title, currentArray, currentIndex, currentOpts) {

      //return '<div id="tip7-title"><span><a href="javascript:;" onclick="$.fancybox.close();"><img src="/data/closelabel.gif" /></a></span>' + (title && title.length ? '<b>' + title + '</b>' : '') + 'Image ' + (currentIndex + 1) + ' of ' + currentArray.length + '</div>';    
      //return '<div id="tip7-title"><h1>' + title + '</h1>' + '<span><a href="javascript:void(0);" onclick="$.fancybox.close();">x</a></span></div>';

      $("#fancybox-title").attr("style", "width:360px;");
      return '<div id="tip7-title">' + ChangeToBold(title, 'NGJ') + '<span><a href="javascript:void(0);" onclick="$.fancybox.close();"><img src="/css/Fancybox/fancy_close.png" alt=""/></a></span></div>';
  }

  function formatTitle2(title, currentArray, currentIndex, currentOpts) {
      $("#fancybox-title").attr("style", "width:320px;");
      return '<div id="tip7-title">' + ChangeToBold(title, 'NGJ') + '<span><a href="javascript:void(0);" onclick="$.fancybox.close();"><img src="/css/Fancybox/fancy_close.png" alt=""/></a></span></div>';
  }

  function formatTitle3(title, currentArray, currentIndex, currentOpts) {      
      $("#fancybox-title").attr("style", "width:520px;");
      return '<div id="tip7-title">' + ChangeToBold(title, 'NGJ') + '<span><a href="javascript:void(0);" onclick="$.fancybox.close();"><img src="/css/Fancybox/fancy_close.png" alt=""/></a></span></div>';
  }

  function formatTitle4(title, currentArray, currentIndex, currentOpts) {
      $("#fancybox-title").attr("style", "width:420px;");
      return '<div id="tip7-title">' + ChangeToBold(title, 'NGJ') + '<span><a href="javascript:void(0);" onclick="$.fancybox.close();"><img src="/css/Fancybox/fancy_close.png" alt=""/></a></span></div>';
  }

  function formatTitle5(title, currentArray, currentIndex, currentOpts) {
      $("#fancybox-title").attr("style", "width:520px;");
      return '<div id="tip7-title">' + ChangeToBold(title, 'NGJ') + '<span><a href="javascript:void(0);" onclick="$.fancybox.close();"><img src="/css/Fancybox/fancy_close.png" alt=""/></a></span></div>';
  }

  function ChangeToBold(text, strToChange) {

//      if (text.indexOf(strToChange) > -1) return '<b>' + strToChange.toUpperCase() + '</b>' + text.replace(strToChange, '').toUpperCase();
//      else return text;
      return '<b>' + strToChange.toUpperCase() + '</b>' + text.replace(strToChange, '').replace(' ','').toUpperCase();

  }


  //============================ DROPMENU =======================
  $(document).ready(function () {
      $(".topNavigation #dropmenu").dropmenu({
          effect: "slide",       //  "slide", "fade", or "none"
          speed: "fast",     //  "normal", "fast", "slow", 100, 1000, etc
          timeout: 250,
          nbsp: false,
          maxWidth: 0
      });
  });


  //============================ LOGIN REFRESH ===================

  function LoginRefresh(url) {
      $.fancybox.close();
      window.location.href = url;

  }

  function ToParentPage() {
      parent.$.fancybox.close();     

  }

  //============================ REGISTRATION REFRESH ===================

  function toParentProfile(url) {
      window.top.location.href = url;
  }

  function resizeFancy() {
      $(document).ready(function () {
          
          //parent.$("#fancybox-outer").css({ 'height': (parseFloat($('.bg_container').height()) + 20) + 'px' });
          parent.$("#fancybox-content").css({ 'height': (parseFloat($('.bg_container').height())) + 'px' });          
          parent.$.fancybox.resize(); 


      });

  }


  //============================ PROFILE LIST SWITCH ===================
  $(document).ready(function () {
//      $(".profileNewList").click(function () {
//          $(".profileLink").each(function () {
//              $(this).removeClass("selectedA");
//          });
//          $(".TopicListDiv:visible").slideUp(function () {
//              $(".newestDiv").slideDown();

//              $(".profileNewList").addClass("selectedA");
//          });
//      });

//      $(".profileYourList").click(function () {
//          $(".profileLink").each(function () {
//              $(this).removeClass("selectedA");
//          });
//          $(".TopicListDiv:visible").slideUp(function () {
//              $(".yourDiv").slideDown();
//              $(".profileYourList").addClass("selectedA");
//          });
//      });

//      $(".profilePopList").click(function () {
//          $(".profileLink").each(function () {
//              $(this).removeClass("selectedA");
//          });
//          $(".TopicListDiv:visible").slideUp(function () {
//              $(".popularDiv").slideDown();
//              $(".profilePopList").addClass("selectedA");
//          });
//      });


      // Subscribe to topic subscribedtotopic
      $(".Pnotsubscribedtotopic").click(function () {
          var topicid = $(this).attr('rel');
          $(this).slideUp('fast');
          $(this).html('Afmelden');
          $(this).removeClass('Pnotsubscribedtotopic').addClass('Psubscribedtotopic');
          $(this).slideDown();
          $.get("/base/Solution/SubScribeToTopic/" + topicid + ".aspx",
        function (data) {
            var result = $('value', data).text();
        });
          return false;
      });

      // UnSubscribe to topic subscribedtotopic
      $(".Psubscribedtotopic").click(function () {
          var topicid = $(this).attr('rel');
          $(this).slideUp('fast');
          $(this).html('Aanmelden');
          $(this).removeClass('Psubscribedtotopic').addClass('Pnotsubscribedtotopic');
          $(this).slideDown();
          $.get("/base/Solution/UnSubScribeToTopic/" + topicid + ".aspx",
        function (data) {
            var result = $('value', data).text(); 
        });
          return false;
      });

  });

  //============================ PROFIEL INFORMATION SWITCH ===================
  $(document).ready(function () {
//      $(".ProfielPersonal").click(function () {
//          $(".profileLinkP").each(function () {
//              $(this).removeClass("selectedA");
//          });
//          $(".ForumInfTab").fadeOut(function () {
//              $(".PersonalInfTab").fadeIn();
//              $(".ProfielPersonal").addClass("selectedA");
//          });
//      });

//      $(".ProfielForum").click(function () {
//          $(".profileLinkP").each(function () {
//              $(this).removeClass("selectedA");
//          });
//          $(".PersonalInfTab").fadeOut(function () {
//              $(".ForumInfTab").fadeIn();
//              $(".ProfielForum").addClass("selectedA");
//          });
//      });
  });

//============================ RECENT DOWNLOADS SWITCH ===================
$(document).ready(function () {
//   $(".downloadRecent").click(function () {
//      $(".downloadLink").each(function () {
//          $(this).removeClass("selectedA");
//      });
//      $(".downloadSwitchDiv:visible").slideUp(function () {
//          $(".mostRecent").slideDown();

//          $(".downloadRecent").addClass("selectedA");
//      });
//  });

//  $(".downloadPopular").click(function () {
//      $(".downloadLink").each(function () {
//          $(this).removeClass("selectedA");
//      });
//      $(".downloadSwitchDiv:visible").slideUp(function () {
//          $(".mostPopular").slideDown();
//          $(".downloadPopular").addClass("selectedA");
//      });
//  });
});
