﻿function showUGC(_index, _pagenum)
{
    for (i=1; i<=_pagenum; ++i){
        document.getElementById("UGCNum" + i).className = "RROff";
        document.getElementById("UGC" + i).style.display = "none";
    }
    document.getElementById("UGCNum" + _index).className = "RROn";
    document.getElementById("UGC" + _index).style.display = "";
}

function PrevPage(_pagenum)
{
    if (_pagenum > 1) {
        var _curr = findCurrPage(_pagenum);
        if (_curr > -1) {
            var _prev = _curr - 1;
            if (_curr == 1) { _prev = _pagenum }
            document.getElementById("UGCNum" + _curr).className = "RROff";
            document.getElementById("UGC" + _curr).style.display = "none";
            document.getElementById("UGCNum" + _prev).className = "RROn";
            document.getElementById("UGC" + _prev).style.display = "";
        }
    }
}

function NextPage(_pagenum)
{
    if (_pagenum > 1) {
        var _curr = findCurrPage(_pagenum);
        if (_curr > -1) {
            var _next = _curr + 1;
            if (_curr == _pagenum) { _next = 1 }
            document.getElementById("UGCNum" + _curr).className = "RROff";
            document.getElementById("UGC" + _curr).style.display = "none";
            document.getElementById("UGCNum" + _next).className = "RROn";
            document.getElementById("UGC" + _next).style.display = "";
        }
    }
}

function findCurrPage(_pagenum)
{
    for (i=1; i<=_pagenum; ++i) {
        if(document.getElementById("UGC" + i).style.display == "")
        return i;
    }
    return -1;
}

function addNewReview(ObjectId, RowId, _baseurl)
{
    var newurl = _baseurl + 'common/addreview.aspx?objectid=' + ObjectId + '&rowid=' + RowId;
    window.open(newurl, "mywindow", "width=390,height=400,resizable=no,scrollbars=no,toolbar=no,menubar=no,titlebar=no");
}

function validateAllPage(_clientId)
{
    var _msg = new String();
    _msg = "";
   
    if (document.getElementById(_clientId + "txtNewName").value=="" || document.getElementById(_clientId + "txtNewName").value=="שם")
        _msg = "חובה להזין שם";
    if (document.getElementById(_clientId + "txtNewSubject").value=="" || document.getElementById(_clientId + "txtNewSubject").value=="נושא") {
        if (_msg!="") { _msg+= "\n"; }
        _msg += "חובה להזין נושא";
    }
        
    if (document.getElementById(_clientId + "txtNewEmail").value=="" || document.getElementById(_clientId + "txtNewEmail").value=="אימייל") {
        if (_msg!="") { _msg+= "\n"; }
        _msg += "חובה להזין כתובת דואר אלקטרוני";
    }
    else
    {
        var regExprEmail = new RegExp("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
        regExprEmail.exec(document.getElementById(_clientId + "txtNewEmail").value);
        if (!regExprEmail.test (document.getElementById(_clientId + "txtNewEmail").value))
        {
            if (_msg!="") { _msg+= "\n"; }
            _msg += "כתובת דואר אלקטרוני אינה תקינה";
        }
    }
    if (_msg!="")
     {
        alert( _msg );
        return false;
     }
     return true;
}
