﻿function hideshow(which, DescTitle)
{
    if (!document.getElementById)
        return
    if (which.style.display=="block")
    {
        which.style.display="none";
        DescTitle.innerHTML = "Description in English";
    }
    else
    {
        which.style.display="block";
        DescTitle.innerHTML = "Hide Description";
    }
}

//=======================================================================================

function hidedesc(item)
{
    document.getElementById(item).style.display="none";
}

//=======================================================================================

function getimage(idurl)
{    
    PageMethods.GetContactName(idurl, GetProductPriceCallSuccess, ServerFunctionCallFailed);
}
 
function ServerFunctionCallFailed(Error, DestCtrl, MethodName)
{
    alert(Error.get_message());
}

function GetProductPriceCallSuccess(ReturnVal, DestCtrl, MethodName)
{   
    document.getElementById(imageID).src = "GetPicHandler.ashx?ph="+ ReturnVal[0];
    document.getElementById(DesPanelID).innerHTML = ReturnVal[1];
    
    if (ReturnVal[2]=="False")
        ReturnVal[2]="Left"
    else
        ReturnVal[2]="Right"
    document.getElementById(DesPanelID).style.textAlign = ReturnVal[2];    
    document.getElementById(TxtSubjectID).value = ReturnVal[3];    
    document.getElementById(imgLinkID).href = ReturnVal[4];
}   

//========================================================================================
 
function clic(id,url)
{    
    PageMethods.AddVisitorNo(id, url, AddVisitorNoCallSuccess, AddVisitorNoCallFailed);
}
 
function AddVisitorNoCallFailed(Error, DestCtrl, MethodName) 
{
    alert(Error.get_message());
}

function AddVisitorNoCallSuccess(url, DestCtrl, MethodName)
{  
    //window.location.reload( true ); 
    window.open(url);
}

//========================================================================================

function addtofavorite(siteid,userid)
{    
    PageMethods.AddFavorite(siteid, userid, AddToFavoriteCallSuccess, AddToFavoriteCallFailed);
}
 
function AddToFavoriteCallFailed(Error, DestCtrl, MethodName) 
{
    alert(Error.get_message());
}

function AddToFavoriteCallSuccess(ReturnVal, DestCtrl, MethodName)
{  
    if (ReturnVal[0]=="false")
    { 
        window.open("Register.aspx?id=" + ReturnVal[1],"_self");
    }
    if (ReturnVal[0]=="true")
        alert(" Successfully added to your favorite! ");
}


//========================================================================================

function removefavorite(siteid,userid)
{    
    PageMethods.removefavorite(siteid, userid, removefavoriteCallSuccess, removefavoriteCallFailed);
}
 
function removefavoriteCallFailed(Error, DestCtrl, MethodName) 
{
    alert(Error.get_message());
}

function removefavoriteCallSuccess(ReturnVal, DestCtrl, MethodName)
{  
    window.location.reload();
}

//========================================================================================


function AddWebsiteBookMark()
{
    var BookmarkURL="http://www.bahailinks.org/"
    var BookmarkTitle="Bahai Links"
 
    // If the browser is Internet Explorer
    if (document.all)
    {
        // Add to Favorites (Internet Explorer)
        window.external.AddFavorite(BookmarkURL,BookmarkTitle)
    }
    else
    {
        // Add to Bookmarks (Mozilla Firefox)
        window.sidebar.addPanel(BookmarkTitle, BookmarkURL, ''); 
    }
}

var arrRadios ='http://38.117.88.148/Radio_Bahailink|http://38.117.88.148/Radio_YekjahanLink ';

function playRadio(which)
{
    window.open('PlayRadio.aspx?src=' + arrRadios.split('|')[which],"radio",'resizable=0,toolbar=0,menubar=0,statusbar=0,location=0,width=200,height=100');
}

//========================================================================================

function SortLinksBy(idurl)
{    
    PageMethods.SortLinksBy(idurl, GetProductPriceCallSuccess, ServerFunctionCallFailed);
}
 
function ServerFunctionCallFailed(Error, DestCtrl, MethodName)
{
    alert(Error.get_message());
}

function GetProductPriceCallSuccess(ReturnVal, DestCtrl, MethodName)
{   
    document.getElementById(imageID).src = "GetPicHandler.ashx?ph="+ ReturnVal[0];
    document.getElementById(DesPanelID).innerHTML = ReturnVal[1];
    
    if (ReturnVal[2]=="False")
        ReturnVal[2]="Left"
    else
        ReturnVal[2]="Right"
    document.getElementById(DesPanelID).style.textAlign = ReturnVal[2];    
    document.getElementById(TxtSubjectID).value = ReturnVal[3];    
    document.getElementById(imgLinkID).href = ReturnVal[4];
}   

//=========================================================================================

function AddChrTo(id)
{    
    var str="";
    var obj1 = document.getElementById("ctl00_ContentPlaceHolder1_fname").value;
    if (obj1=='undefined')
        obj1='';
    
    str = obj1 + id;
    var url="Home.aspx?lan=&ap=" + str + "&f=1&t=10";
       
    window.open(url,"_self");
}   

//========================================================================================

function updatsrch()
{
    var obj1=document.getElementById("ctl00_ContentPlaceHolder1_fname").value;

    var url="Home.aspx?lan=&ap=" + obj1 + "&f=1&t=10";
      
    window.open(url,"_self");

}

//========================================================================================

function remove()
{
    var obj1=document.getElementById("ctl00_ContentPlaceHolder1_fname");
    var l=obj1.value.length;
    var chr =obj1.value.substring(0,l-1);
    
    var url="Home.aspx?lan=&ap=" + chr + "&f=1&t=10";
    window.open(url,"_self");

}

//=========================================================================================

function searchFor(id)
{    
    var str="";
    var obj1 = document.getElementById("ctl00_ContentPlaceHolder1_Fname").value;
    var obj2 = document.getElementById("ctl00_ContentPlaceHolder1_LanguageSelection").value;
    var obj3 = document.getElementById("ctl00_ContentPlaceHolder1_DD_Subject").value;
            
    if (obj1=='undefined')
        obj1='';
    
    str = obj1 + id;
    
    var url="search.aspx?f=1&t=10&key=" + str + "&lan=" + obj2 + "&sub=" + obj3;
       
    window.open(url,"_self");
}   

//=========================================================================================

function searchForFavorite(id)
{    
    var str="";
    var obj1 = document.getElementById("ctl00_ContentPlaceHolder1_Fname").value;
    var obj2 = document.getElementById("ctl00_ContentPlaceHolder1_LanguageSelection").value;
    var obj3 = document.getElementById("ctl00_ContentPlaceHolder1_DD_Subject").value;
            
    if (obj1=='undefined')
        obj1='';
    
    str = obj1 + id;
    
    var url="favorites.aspx?f=1&t=10&key=" + str + "&lan=" + obj2 + "&sub=" + obj3;
       
    window.open(url,"_self");
}   
//========================================================================================

function CreateShortcut()
{
    try
    {
//        if (ActiveXObject)
//        {
            var WshShell = new ActiveXObject("WScript.Shell");
            strDesktop = WshShell.SpecialFolders("Desktop");
            var oShellLink = WshShell.CreateShortcut(strDesktop + "\\Bahá’íLinks.url");
            oShellLink.TargetPath = "http://www.bahailinks.org/";
            oShellLink.Save();
        //}
    }
    catch(e){}
}

//========================================================================================


function SwitchLangDesc(language)
{
    var EngDes = document.getElementById('EngDesc'); 
    var FarcDes = document.getElementById('FarcDesc'); 
    var ArbDesc = document.getElementById('ArbDesc'); 
        
    switch (language)
    {
        case "Eng":
            EngDes.style.display = "";
            FarcDes.style.display = "none";
            ArbDesc.style.display = "none";
            break;              
        case "Far":
            EngDes.style.display = "none";
            FarcDes.style.display = "";
            ArbDesc.style.display = "none";
            break;
        case "Arb":
            EngDes.style.display = "none";
            FarcDes.style.display = "none";
            ArbDesc.style.display = "";
            break;
        default:
            EngDes.style.display = "";
            FarcDes.style.display = "none";
            ArbDesc.style.display = "none";
    }
}
