﻿// JScript File
function BannerTarget(banner_id)
{
    RS.Execute("page_utils.aspx", "GetBannerLinkAndTarget", banner_id , callback_banner_link, errorCallback);
}

function index_videos_menu(e, cls , tabID){
    lastSelected = null;
	var all_btns = document.getElementById('video_tabs_tabs').getElementsByTagName("a");
	for (var i=0; i < all_btns.length; i++){
	    if (all_btns[i].className != "normal")
	        lastSelected = all_btns[i];
		all_btns[i].setAttribute("class", "normal")
		all_btns[i].setAttribute("className", "normal")
	}		
	e.className = cls;
	if (lastSelected == null || e != lastSelected)
	    RS.Execute("page_utils.aspx", "GetMainVideoArea", tabID , callback_main_video_area, errorCallback);
}

function tagClick(tagID)
{
    RS.Execute("page_utils.aspx", "TagClick", tagID , callback_tag_click, errorCallback);
    sURL = "video.aspx?tag_id=" + tagID;
    window.location.href = sURL;
}

function MoveGalleryToPage(thePage , theGalleryID)
{
    RS.Execute("page_utils.aspx", "MoveGalleryToPage", thePage , theGalleryID , callback_move_gallery_to_page, errorCallback);
}

/*function chapter_selected(theObjID)
{
    theSeasonNum = window.document.getElementById("season").value;
    theChapterNum = window.document.getElementById("episode").value;
    RS.Execute("page_utils.aspx", "ChapterSelected", theObjID , theSeasonNum , theChapterNum , callback_chapter_selected, errorCallback);
}*/

function chapter_selected()
{
    theSeasonNum = window.document.getElementById("season").value;
    theChapterNum = window.document.getElementById("episode").value;
    RS.Execute("page_utils.aspx", "ChapterSelected", chpater_obj_id , theSeasonNum , theChapterNum , callback_chapter_selected, errorCallback);
}

function text_pic_clicked(objID, categoryID, pageID)
{
    RS.Execute("page_utils.aspx", "TextPicClicked", objID , categoryID , pageID , callback_text_pic, errorCallback);
}

function text_pic_clicked1(objID, categoryID, pageID)
{
    RS.Execute("page_utils.aspx", "TextPicClicked", objID , categoryID , pageID , callback_text_pic1, errorCallback);
}

function full_message_clicked(objID, categoryID, pageID , idClicked)
{
    RS.Execute("page_utils.aspx", "TextPicFullClicked", objID , categoryID , pageID , idClicked , callback_text_pic, errorCallback);
}

function schedule_move_to_date(theDay , theMounth , theYear)
{
    RS.Execute("page_utils.aspx", "MoveScheduleToDate", theDay , theMounth , theYear , callback_scedule_change, errorCallback);
}

function callback_scedule_change(result)
{
    document.getElementById("schedule_location").innerHTML = result;  
}

function callback_text_pic(result)
{
    window.scroll(0,60) ;
    callback_text_pic1(result)
}

function callback_text_pic1(result)
{
    var split_array=result.split("|");
    theID = split_array[0];
    theHtml = split_array[1];
    theReplace = "text_pic_location";
    theReplace = theReplace + theID;
    document.getElementById(theReplace).innerHTML = theHtml;  
}

function callback_chapter_selected(result)
{
    document.getElementById("chapters_location").innerHTML = result;  
}

function callback_move_gallery_to_page(result)
{
    var split_array=result.split("|");
    theID = split_array[0];
    first_pics = split_array[1];
    last_pics = split_array[2];
    selectLi = first_pics;
    theResult = split_array[3];
    theDivID = 'theGallery_' + theID;
    
    document.getElementById(theDivID).innerHTML = theResult;
    TB_init();
}

function callback_tag_click(result)
{
    
}

function callback_main_video_area(result)
{
    document.getElementById('inside_videos').innerHTML = result;
}

function callback_Send_pic_mail_page(result)
{
    document.getElementById('TB_closeWindowButton').click();
}

function callback_banner_link(result)
{
    var split_array=result.split("|");
    theTarget = split_array[0];
    theLink = split_array[1];
    if (theTarget == "2")
    {
        window.location.href=theLink;
    }
    if (theTarget == "1")
    {
    
        if (theLink != "")
        {
            window.document.getElementById('banner_link').href=theLink;
            window.document.getElementById('banner_link').click();
            void(0);
        }
    }
}

function errorCallback(result)
{
    alert(result);
}

function tn_clicked(theID)
{
    theBigID = 'tn_big_' + theID;
    theDesc = 'tn_desc_' + theID;
    theAlt = 'tn_alt_' + theID;
    theFull = 'tn_full_' + theID;
    window.document.getElementById('big_image').src=window.document.getElementById(theBigID).value;
    window.document.getElementById('big_image_desc').innerHTML = window.document.getElementById(theDesc).value;
    window.document.getElementById('big_image').alt = window.document.getElementById(theAlt).value;
    window.document.getElementById('enlarge_btn').href = window.document.getElementById(theFull).value;
    window.document.getElementById('enlarge_btn').title = window.document.getElementById(theDesc).value;
    window.document.getElementById('img_preloader').src = window.document.getElementById(theFull).value;
    
    
    selectLi = Number(theID);
}

function MoveNext()
{
    theTNID = "tn_" + selectLi;
    
    if (Number(selectLi) < Number(last_pics) - 1)
    {
        window.document.getElementById(theTNID).className = "";
        tn_clicked(Number(selectLi) + 1);    
        theTNID = "tn_" + selectLi;
        window.document.getElementById(theTNID).className = "active";
    }
}

function MovePrev()
{
    theTNID = "tn_" + selectLi;
    if (Number(selectLi) > Number(first_pics))
    {
        window.document.getElementById(theTNID).className = "";
        tn_clicked(Number(selectLi) - 1);    
        theTNID = "tn_" + selectLi;
        window.document.getElementById(theTNID).className = "active";
    }
}
function openBig()
{
    //theBigID = 'tn_full_' + selectLi;
    //photomaxindiv(window.document.getElementById(theBigID).value,'bigest_image','');
}

function send_link_to_friend(theLink)
{
    sendto = document.getElementById('sendto').value;
    email = document.getElementById('email').value;
    sender = document.getElementById('sender').value;
    sender_mail = document.getElementById('sender_mail').value;
    theBigID = 'tn_full_' + window.parent.selectLi;
    theDesc = 'tn_desc_' + window.parent.selectLi;
    pic_header = window.document.getElementById(theDesc).value;
    RS.Execute("page_utils.aspx", "SendPicMail", sendto , email , sender_mail , sender , window.document.getElementById(theBigID).value , pic_header , callback_Send_pic_mail_page, errorCallback);    
}
