﻿// JScript File



function ShowHideFaqAnswerDiv(AnswerDivID)
{
    DivAnswer = document.getElementById(AnswerDivID);
    
    if(DivAnswer.className == "DivFaqUserListAnswerHide")
        DivAnswer.className = "DivFaqUserListAnswerShow";
    else
        DivAnswer.className = "DivFaqUserListAnswerHide";
    
} // end method






function SelectGDate(controlName)
{
//alert("sd");
var strDate = document.getElementById(controlName).value;
//alert(strDate);

var wnd = null;
// Set up the look of the popup window
//'width=380,height=230,location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,status=no';
var settings='width=400,height=220,location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,status=no';
// Pass the control name that will receive the date
var url = 'Controls/SelectGDateDialog/SelectGDate.aspx?'+ 'CurDate=' + strDate +'&control=' + controlName ;//+ '&CurDate=' + strDate;
// Open the popup window
wnd = window.open(url,'DatePopup',settings);

// Give popup window the focus if browser
// supports this capability
if (wnd.focus){ wnd.focus(); }
}

function PickFile(controlName, AcceptedFileTypes)
{
alert(controlName);
alert(AcceptedFileTypes);
//return;

var strDate = document.getElementById(controlName).value;
//alert(strDate);

var wnd = null;
// Set up the look of the popup window
//'width=380,height=230,location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,status=no';
var settings='width=600,height=500,location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,status=no';
// Pass the control name that will receive the date
var url = 'FileChooser2.aspx?fileTypes=' + AcceptedFileTypes;
// Open the popup window
wnd = window.open(url,'DatePopup',settings);

// Give popup window the focus if browser
// supports this capability
if (wnd.focus){ wnd.focus(); }
}



function SelectGDateWithUrl(rootUrl, controlName)
{
//alert("sd");
var strDate = document.getElementById(controlName).value;
//alert(strDate);

var wnd = null;
// Set up the look of the popup window
//'width=380,height=230,location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,status=no';
var settings='width=400,height=220,location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,status=no';
// Pass the control name that will receive the date
var url = rootUrl + 'Controls/SelectGDateDialog/SelectGDate.aspx?'+ 'CurDate=' + strDate +'&control=' + controlName ;//+ '&CurDate=' + strDate;
// Open the popup window
wnd = window.open(url,'DatePopup',settings);

// Give popup window the focus if browser
// supports this capability
if (wnd.focus){ wnd.focus(); }
}




function SelectPDate(rootUrl, controlName)
{
    //alert("sd");
    var strDate = document.getElementById(controlName).value;
    //alert(strDate);

    var wnd = null;
    // Set up the look of the popup window
    //'width=380,height=230,location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,status=no';
    var settings='width=270,height=250,location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,status=no';
    // Pass the control name that will receive the date
    var url = rootUrl + 'Controls/SelectPDateDialog/SelectPDate.aspx?'+ 'CurDate=' + strDate +'&control=' + controlName ;//+ '&CurDate=' + strDate;
    // Open the popup window
    wnd = window.open(url,'DatePopup',settings);

    // Give popup window the focus if browser
    // supports this capability
    if (wnd.focus){ wnd.focus(); }
    }

    function PickFile(controlName, AcceptedFileTypes)
    {
    alert(controlName);
    alert(AcceptedFileTypes);
    //return;

    var strDate = document.getElementById(controlName).value;
    //alert(strDate);

    var wnd = null;
    // Set up the look of the popup window
    //'width=380,height=230,location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,status=no';
    var settings='width=600,height=500,location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,status=no';
    // Pass the control name that will receive the date
    var url = 'FileChooser2.aspx?fileTypes=' + AcceptedFileTypes;
    // Open the popup window
    wnd = window.open(url,'DatePopup',settings);

    // Give popup window the focus if browser
    // supports this capability
    if (wnd.focus){ wnd.focus(); }
}








 function GenerateNewCaptchaImage(captchaImageID)
    {
        var obj = document.getElementById(captchaImageID);
        var src = obj.src;
        var pos = src.indexOf('?');
        
        if (pos >= 0) 
        {
            src = src.substr(0, pos);
        }
        
        var date = new Date();
        obj.src = src + '?v=' + date.getTime();
    } // end method 
    
    
    function GenerateNewCaptchaImageWithPageID(captchaImageID, pageID)
    {
        var obj = document.getElementById(captchaImageID);
        var src = obj.src;
        var pos = src.indexOf('?');
        
        if (pos >= 0) 
        {
            src = src.substr(0, pos);
        }
        
        var date = new Date();
        obj.src = src + '?v=' + date.getTime() + "&PageID=" + pageID;
    } // end method 
    
    
    
    
     
         function ChangeCssClass(elementID, cssClassName)
         {
        
            var element = document.getElementById(elementID);
            element.className = cssClassName;
         }
         
         
         
        
        
        
        





function PickFileDlg(controlName, fileChooserUrl)
{
var strDate = document.getElementById(controlName).value;
//alert(strDate);

//alert(fileChooserUrl)

var wnd = null;
// Set up the look of the popup window
//'width=380,height=230,location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,status=no';
// ORIGINALvar settings='width=600,height=300,location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,status=no';
var settings='width=1000,height=500,location=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,top=60,left=5';
// Pass the control name that will receive the date
//var url = '../Admin/FileChooser.aspx?'+ 'CurDate=' + strDate +'&control=' + controlName ;//+ '&CurDate=' + strDate;
var url = fileChooserUrl + '?'+ 'CurDate=' + strDate +'&control=' + controlName ;//+ '&CurDate=' + strDate;
// Open the popup window
wnd = window.open(url,'DatePopup',settings);

// Give popup window the focus if browser
// supports this capability
if (wnd.focus){ wnd.focus(); }
}




function ShowChooserDialog(controlName, fileChooserUrl, dlgWidth, dlgHeight)
{
var strDate = document.getElementById(controlName).value;
//alert(strDate);

//alert(fileChooserUrl)

var wnd = null;
// Set up the look of the popup window
//'width=380,height=230,location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,status=no';
// ORIGINALvar settings='width=600,height=300,location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,status=no';
var settings='width='+dlgWidth+',height='+dlgHeight+',location=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,top=60,left=5';
// Pass the control name that will receive the date
//var url = '../Admin/FileChooser.aspx?'+ 'CurDate=' + strDate +'&control=' + controlName ;//+ '&CurDate=' + strDate;
var url = fileChooserUrl + '?'+ 'CurDate=' + strDate +'&control=' + controlName ;//+ '&CurDate=' + strDate;
// Open the popup window
wnd = window.open(url,'DatePopup',settings);

// Give popup window the focus if browser
// supports this capability
if (wnd.focus){ wnd.focus(); }
}


function ShowSkinChooserDialog(SknNmCtrlID, SknIDCtrlID, fileChooserUrl, dlgWidth, dlgHeight)
{
    var SknNmCtrlIDValue = document.getElementById(SknNmCtrlID).value;
    var SknIDCtrlIDValue = document.getElementById(SknIDCtrlID).value;

//var strDate = document.getElementById(controlName).value;
//alert(strDate);

//alert(fileChooserUrl)

var wnd = null;
// Set up the look of the popup window
//'width=380,height=230,location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,status=no';
// ORIGINALvar settings='width=600,height=300,location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,status=no';
var settings='width='+dlgWidth+',height='+dlgHeight+',location=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes,top=60,left=5';
// Pass the control name that will receive the date
//var url = '../Admin/FileChooser.aspx?'+ 'CurDate=' + strDate +'&control=' + controlName ;//+ '&CurDate=' + strDate;
var url = fileChooserUrl + '?'+ 'SknNmCtrlID=' + SknNmCtrlID + "&SknIDCtrlID=" + SknIDCtrlID;// +'&control=' + controlName ;//+ '&CurDate=' + strDate;
// Open the popup window
wnd = window.open(url,'DatePopup',settings);

// Give popup window the focus if browser
// supports this capability
if (wnd.focus){ wnd.focus(); }
}





//-------------------- [ Tell a Friend ] -----------------------------------------------------------------------------
var tafSuccessMsg = "عملیات با موفقیت انجام گردید";
var tafUnavailableServiceMsg = "سرویس در دسترس نمی باشد";

function AjaxTellAFriend(tafName, tafEmail, tafFriendName, tafFriendEmail)
      {
      
      this.LoadInfo = function()
      {
           var request;
           
                if (window.ActiveXObject) 
                {
                    request = new ActiveXObject("Microsoft.XMLHTTP");
                }
                else if (window.XMLHttpRequest) 
                {
                    request = new XMLHttpRequest();
                }  
             
            var body =  "tafName=" + tafName + "&tafEmail=" + tafEmail + "&tafFriendName=" + tafFriendName + "&tafFriendEmail=" + tafFriendEmail + "";
            request.open("POST", "_AjaxService.axd");
            request.setRequestHeader("UseMyAjaxServices", "true");
            request.setRequestHeader("AjaxServiceCode", "TellAFriend");
            request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            
            request.onreadystatechange = function()
            {
                if (request.readyState == 4)
                {
                   if(request.status == 200)
                   {
                        var DivTafLoading = document.getElementById("DivTafLoading");
                        var DivTafForm = document.getElementById("DivTafForm");
                        var DivTafMessage = document.getElementById("DivTafMessage");

                        DivTafLoading.className = "HiddenElement";
                        DivTafForm.className = "HiddenElement";
                        DivTafMessage.className = "VisibleElement";

                        DivTafMessage.innerHTML = request.responseText;//tafSuccessMsg;
                   }
                   else
                   {
                        var DivTafLoading = document.getElementById("DivTafLoading");
                        var DivTafForm = document.getElementById("DivTafForm");
                        var DivTafMessage = document.getElementById("DivTafMessage");

                        DivTafLoading.className = "HiddenElement";
                        DivTafForm.className = "HiddenElement";
                        DivTafMessage.className = "VisibleElement";

                        DivTafMessage.innerHTML = tafUnavailableServiceMsg;
                   }
                }
            };
            
            request.send(body);
      };
       
         
      }
      
      
      
      
      
      
      
      
      
      
      
      
        function AjaxCallTellAFriend()
         {
            if(Page_ClientValidate("TellAFriend"))
            {
                var tafNameValue = document.getElementById(tafNameID).value;
                var tafEmailValue = document.getElementById(tafEmailID).value;
                var tafFriendNameValue = document.getElementById(tafFriendNameID).value;
                var tafFriendEmailValue = document.getElementById(tafFriendEmailID).value;

                var personReq = new AjaxTellAFriend(tafNameValue, tafEmailValue, tafFriendNameValue, tafFriendEmailValue);
                personReq.LoadInfo();

                var DivTafLoading = document.getElementById("DivTafLoading");
                var DivTafForm = document.getElementById("DivTafForm");
                var DivTafMessage = document.getElementById("DivTafMessage");
                
                DivTafLoading.className = "VisibleElement";
                DivTafForm.className = "HiddenElement";
                DivTafMessage.className = "HiddenElement";
            }

            return false;
         }
         
         
         function AjaxCallTellAFriendNew()
         {
            //document.getElementById(tafNameID).value = "";
            //document.getElementById(tafEmailID).value = "";
            document.getElementById(tafFriendNameID).value = "";
            document.getElementById(tafFriendEmailID).value = "";


            var DivTaf = document.getElementById("DivTaf");
            var DivTafLoading = document.getElementById("DivTafLoading");
            var DivTafForm = document.getElementById("DivTafForm");
            var DivTafMessage = document.getElementById("DivTafMessage");

            DivTaf.className = "VisibleElement";
            DivTafLoading.className = "HiddenElement";
            DivTafForm.className = "VisibleElement";
            DivTafMessage.className = "HiddenElement";
         }
         
         
         
         
         
         function ChangeCssClass(elementID, cssClassName)
         {
            var element = document.getElementById(elementID);
            element.className = cssClassName;
         }
         
         
         
         //----------------------------------------------------------------------------------------------------------------------
         
         
         
         function DisplayPopUpWin
            (
                sURLValue, 
                menubarValue, 
                resizableValue, 
                scrollbarsValue, 
                statusValue, 
                titlebarValue, 
                toolbarValue, 
                topValue, 
                leftValue, 
                widthValue, 
                heightValue
            )
        {

            var strFeatures =   
                                //"location=false,"   +   
                                "menubar="      +   menubarValue    +   "," +
                                "resizable="    +   resizableValue  +   "," +
                                "scrollbars="   +   scrollbarsValue +   "," +
                                "status="       +   statusValue     +   "," +
                                "titlebar="     +   titlebarValue   +   "," +
                                "toolbar="      +   toolbarValue    +   "," +
                                "top="          +   topValue        +   "," +
                                "left="         +   leftValue       +   "," +
                                "width="        +   widthValue      +   "," +
                                "height="       +   heightValue     +   
                                "";

            window.open
                (
                    sURLValue, 
                    "_blank", 
                    strFeatures, 
                    false
                );

        } // end function
        
        
        
        /*---------------------------------------------------------------
            Tab Script by Arman Vasseghi
        ----------------------------------------------------------------*/
        
function SetActiveTab(mouseOveredTdID, tabDivID)
{
    var DivTabCtrl;
    var DivContent;
    
    // ------- [ Show, Hide Tabs ] -------
     for(i = 0; i < mouseOveredTdID.parentNode.childNodes.length; i++)
     {
        mouseOveredTdID.parentNode.childNodes[i].className = "TdInactiveTab";
     }
    
        mouseOveredTdID.className = "TdActiveTab";
         
          // ------- [ Finding DivTabCtrl ] -------
         DivTabCtrl = FindInParentHierarchyStartWith(mouseOveredTdID, "DivTabCtrl");
         // alert(DivTabCtrl.id);
         
          // ------- [ Finding DivContent ] -------
          DivContent = FindInChildNodesByClassName(DivTabCtrl, "DivContent");
          
          
           // ------- [ Show, Hide Tab Contents ] -------
        for(i = 0; i < DivContent.childNodes.length; i++)
        {
            DivContent.childNodes[i].className = "DivTabContentHide";
        }
           
    document.getElementById(tabDivID).className = "DivTabContentShow";
} // end function

function FindInParentHierarchyStartWith(sourceObj, startWithTargetID)
{
    var CurNode = sourceObj;

    for(i = 0; i < 20; i++)
    {
        if(CurNode.id.substr(0, startWithTargetID.length) == startWithTargetID)
        return CurNode;

        CurNode = CurNode.parentNode;
    }

    return null;
} // end function 

function FindInChildNodesByClassName(sourceObj, childClassName)
{
    for(i = 0; i < sourceObj.childNodes.length; i++)
    {
        if(sourceObj.childNodes[i].className == childClassName)
        return sourceObj.childNodes[i];
    }

    return null;
} // end function 
//-------------------------------------------------------------------------------------------------------
        
        //-------------------------- [ Rss Reader ] ---------------------
        
 function ShowRssReaderLoading(loadingDivID, rssContentDivID)
     {
        document.getElementById(loadingDivID).className = "VisibleElement";
        document.getElementById(rssContentDivID).className = "HiddenElement";
     }
     
     

//-------------------------- [ Site Search ] ---------------------
function SelectSearchType(txtSearchTypeID,lblSelectedSTypeID, typeValue, typeText)
{
    document.getElementById(txtSearchTypeID).value = typeValue;
    document.getElementById(lblSelectedSTypeID).innerText = typeText;
    //alert(typeValue);
}
