﻿function chooseOption1() 
{
    $("#tbNewName")[0].style.visibility = "hidden";
    $("#chosenId")[0].value = 1;
}

function chooseOption2() {
    $("#tbNewName")[0].style.visibility = "visible";
    $("#chosenId")[0].value = 2;
}

function addImageToEditor(idOfImage) {
    var nameId = "#" + idOfImage;
    var str = $(nameId)[0].name;
    str = (str.substring(0, str.lastIndexOf("/") - 5) + "Images/" + str.substring(str.lastIndexOf("/") + 1, str.length));
    tinyMCE.activeEditor.execCommand('mceInsertContent', false, "<image src='" + str + "'" + "/>");
}

function addIdOfCategory(idOfCategory) {
    $('a[rel*=facebox]').facebox();
    AjaxPaging(1, "/PictureCategories.aspx/AjaxGetPicture", "picsContainer", idOfCategory);
    var jsonParams = $.toJSON(idOfCategory);
    $.ajax({
        type: "POST",
        url: "/PictureCategories.aspx/AjaxGetContent",
        data: jsonParams,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
            $("#" + "decscription").html(result.toString());
        }
    });
}

function addIdOfCategoryToShow(idOfCategory) {
    $('a[rel*=facebox]').facebox();
    AjaxPaging(1, "/PictureCategories.aspx/AjaxGetPictureToShow", "picsContainer", idOfCategory);
    var jsonParams = $.toJSON(idOfCategory);
    $.ajax({
        type: "POST",
        url: "/PictureCategories.aspx/AjaxGetContent",
        data: jsonParams,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
        $("#" + "description").html(result.toString());
        },
        error: function() {
            alert("Paging error");
        }
    });
}



function addIdOfArtCategory(idOfCategory) {
    $('a[rel*=facebox]').facebox();
    AjaxPaging(1, "/ArtCategories.aspx/AjaxGetPicture", "picsContainer", idOfCategory);
    var jsonParams = $.toJSON(idOfCategory);
    $.ajax({
        type: "POST",
        url: "/ArtCategories.aspx/AjaxGetContent",
        data: jsonParams,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
            $("#" + "description").html(result.toString());
        },
        error: function() {
            alert("Paging error");
        }
    });
}

function addIdOfArtCategoryToView(idOfCategory) {
    $('a[rel*=facebox]').facebox();
    AjaxPaging(1, "/ArtCategories.aspx/AjaxGetPictureToShow", "picsContainer", idOfCategory);
    var jsonParams = $.toJSON(idOfCategory);
    $.ajax({
        type: "POST",
        url: "/ArtCategories.aspx/AjaxGetContent",
        data: jsonParams,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
        $("#" + "description").html(result.toString());
        },
        error: function() {
            alert("Paging error");
        }
    });
}

function backToIndex(idOfCategory,pageIndex) {
    AjaxPaging(pageIndex, "/ArtCategories.aspx/AjaxGetPicture", "picsContainer", idOfCategory);
}

function backToIndexToView(idOfCategory, pageIndex) {
    AjaxPaging(pageIndex, "/ArtCategories.aspx/AjaxGetPictureToShow", "picsContainer", idOfCategory);
}

function select() {
    //alert($("#ProductCategoryId")[0].value);
    $("#selectChoose")[0].value = $("#ProductCategoryId")[0].value;
    //alert($("#selectChoose")[0].value);
}


function selectCulture() {
    //alert($("#ProductCategoryId")[0].value);
    $("#selectCultureChoose")[0].value = $("#CultureId")[0].value;
    //alert($("#selectChoose")[0].value);
}

function selectCategory() {
    $("#selectCategoryChoose")[0].value = $("#CategoryId")[0].value;
}

function selectService() {
    //alert($("#ServiceId")[0].value);
    $("#selectServiceChoose")[0].value = $("#ServiceId")[0].value;
    //alert($("#selectServiceChoose")[0].value);
}

function selectRating() {
    //alert($("#ServiceId")[0].value);
    $("#selectRating")[0].value = $("#RatingId")[0].value;
    //alert($("#selectServiceChoose")[0].value);
}

function selectBoolean() {
    //alert($("#lstString")[0].value);
    $("#selectBooleanChoose")[0].value = $("#lstString")[0].value;
    //alert($("#selectBooleanChoose")[0].value);
}

function pictureCategoriesSelect() {
    $("#selectChoose")[0].value = $("#PictureCategoriesId")[0].value;
}


function Say() {
    alert("What the hell!");
}

function showPicture(id, pageIndex) {
    var params = { Id: id, CurrentPageIndex: pageIndex }
    var jsonParams = $.toJSON(params);
    $.ajax({
        type: "POST",
        url: "/ArtCategories.aspx/ShowArtwork/",
        data: jsonParams,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
        $("#" + "picsContainer").html(result.toString());
        },
        error: function() {
            alert("Paging error");
        }
    });
}

function closeDiv() {
    $("#artwork")[0].style.display = 'none';
}

function alreadyToShow() {
    $("#artwork")[0].style.display = '';
}

function addIdOfPress(id) {
    AjaxPaging(1, "/Press.aspx/AjaxGetContent", "mainslide", id);
}

function addIdOfTip(id) {
    AjaxPaging(1, "/Tip.aspx/AjaxGetContent", "mainslide", id);
}

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons

function getCheckedValue(radioObj) {
    if (!radioObj)
        return "";
    var radioLength = radioObj.length;
    if (radioLength == undefined)
        if (radioObj.checked)
        return radioObj.value;
    else
        return "";
    for (var i = 0; i < radioLength; i++) {
        if (radioObj[i].checked) {
            return radioObj[i].value;
        }
    }
    return "";
}


// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
    if (!radioObj)
        return;
    var radioLength = radioObj.length;
    if (radioLength == undefined) {
        radioObj.checked = (radioObj.value == newValue.toString());
        return;
    }
    for (var i = 0; i < radioLength; i++) {
        radioObj[i].checked = false;
        if (radioObj[i].value == newValue.toString()) {
            radioObj[i].checked = true;
        }
    }
}
