function loadPage(list){
location.href=list.options[list.selectedIndex].value
}

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}







var gateway = "http://cams.dnxlive.com/webservices/gateway.php";
function getFavorites() {
  $.getJSON(gateway + "?task=getAllPreferences&jsoncallback=?",
    function(data) {
      if($.isArray(data.favorites)) {
        $.get("http://www.webcamtube.be/favos.php?favorites=" + data.favorites,
          function(htmldata) {
            $("#accounts").html(htmldata);	
	});
      }
      else {
        $("#accounts").html("No favorites found");
      }
  });
}



function getAllFavorites() {
  $.getJSON(gateway + "?task=getAllPreferences&jsoncallback=?",
    function(data) {
      if($.isArray(data.favorites)) {
        $.get("http://www.webcamtube.be/all_favos.php?favorites=" + data.favorites,
          function(htmldata) {
            $("#accounts_all").html(htmldata);	
	});
      }
      else {
        $("#accounts_all").html("No favorites found");
      }
  });
}





function addToFavorites(account) {
$.getJSON(gateway + "?task=addToFavorites&account=" + account + "&jsoncallback=?",
function(data) {
getFavorites();
getAllFavorites();
$("#accounts").html("Loading");
});
}

function removeFromFavorites(account) {
$.getJSON(gateway + "?task=removeFromFavorites&account=" + account +
"&jsoncallback=?", function(data) {
getFavorites();
getAllFavorites();
$("#accounts").html("Loading");

});
}
function getSearchCategories() {
$.getJSON(gateway + "?task=getAllPreferences&jsoncallback=?",
function(data) {
var txt = "";
if($.isArray(data.search_criteria.sex)) {
jQuery.each(data.search_criteria.sex, function(i, value) {
if(i > 0) txt += "\n";
txt += value;
});
}
else {
txt = "No categories found";
}
$("textarea#search_output").val(txt);
});
}
function setCategories(cat) {
$.getJSON(gateway + "?task=updateSearchCriteria&sex=" + cat + "&jsoncallback=?",
function(data) {
alert("setCategories result: " + data.status);
});
}
function getLanguage() {
$.getJSON(gateway + "?task=getAllPreferences&response_format=json&jsoncallback=?",
function(data) {
var txt = "";

if(data.preferences.language != null) {
txt = data.preferences.language;
}
else {
txt = "No language found";
}
$("textarea#language_output").val(txt);
});
}
function setLanguage(lang) {
$.getJSON(gateway + "?task=updatePreferences&language=" + lang + "&jsoncallback=?",
function(data) {
alert("setLanguage result: " + data.status);
});
}

