function shownext(img_id) {
    if (img_num==img_tomb.length) img_num=0;
    if (document.getElementById(img_id)) {
        document.getElementById(img_id).src = img_tomb[img_num];
        img_num++;
        img_timer = setTimeout("shownext('"+img_id+"')", 750);
        }
    }
function startslide(img_id, tomb) {
    img_num = 0;
    img_tomb = tomb;
    if (img_tomb.length) {
        if (document.getElementById(img_id))
            img_orig = document.getElementById(img_id).src;
        img_timer = setTimeout("shownext('"+img_id+"')", 750);
        }
    }
function stopslide(img_id) {
    if (img_timer>0) {
      clearTimeout(img_timer);
      if (document.getElementById(img_id))
          document.getElementById(img_id).src = img_orig;
    }
    img_orig = '';
    }

function ChangeSkin(newskin) {
    var expdate = new Date();
    expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 30));
    document.cookie = 'member_skin='+newskin+'; expires='+expdate.toGMTString()+'; path=/; domain=.needlive.com';
    document.location.reload();
    }

function setimage(forras) {
    document.index.preview.src=forras; }

function delimage(imagename) {
    document.index.postdata.value=imagename;
    document.index.submit();}
    
function setflash(flash_src, flash_id) {
    var strFlash = "<object id='"+flash_id+"' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0'><param name='movie' value='"+flash_src+"' /><param name='quality' value='high' /><embed id='"+flash_id+"' src='"+flash_src+"' quality='high' pluginspage='https://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'></embed></object>";
    return strFlash; }
    
function ablaknyitas(filenev, szel, mag) {
    if (!szel) szel = 920;
    if (!mag) mag = 450;
    window.open(filenev,"ablak","width="+szel+",height="+mag+",top=10,left=10,titlebar=0,status=no,toolbar=no,menubar=no,resizable=no,scrollbars=yes"); }

function ablaknyitas2(filenev,w,h,t,l,nev) {
    window.open(filenev,nev,"width="+w+",height="+h+",top="+t+",left="+l+",titlebar=0,status=no,toolbar=no,menubar=no,resizable=no,scrollbars=yes"); }

function TextAreaLimit(field, maxlen) {
    if (field.value.length > maxlen)
    field.value = field.value.substring(0, maxlen);
    }
    
function trim(str) {
    if(!str || typeof str != 'string') 
        return null;
    else
        return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
    }
function bezar() {
    close();
    }

function SetVideoOverlay(divid) {
    if (document.getElementById(divid).style.display=="block") {
        document.getElementById(divid).style.display="none";
        document.getElementById(divid+'_text').style.display="none";
        }
    else {
        document.getElementById(divid).style.display="block";
        document.getElementById(divid+'_text').style.display="block";
        }
    }

function bookmarksite(){
    var title="NeedLive.com - Free Live WebCams";
    var url="http://www.needlive.com/online/";
    if (document.all)
        window.external.AddFavorite(url, title);
    else
        if (window.sidebar)
            window.sidebar.addPanel(title, url, "")
    }
    
function bubble(mit, mire) {
    if (mire=="on") document.getElementById(mit).style.display='inline';
    else document.getElementById(mit).style.display='none';
    }

function creditrendszer() {
    open("/adminmenu/credit-rendszer.php","creditrendszer","width=900,height=380,top=5,left=5,status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
    }

function stopRKey(evt) {
    var evt = (evt) ? evt : ((event) ? event : null);
    var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
    if ((evt.keyCode == 13) && (node.type=="text"))  {return false;}
    else {return true;}
    }
    
function SetStatDate(beginyear, beginmonth, beginday, endyear, endmonth, endday) {
    for (i=0; i<document.getElementById('beginyear').length; i++)
        if (document.getElementById('beginyear').options[i].value==beginyear) {
            document.getElementById('beginyear').options[i].selected=true;
            break;
            }
    for (i=0; i<document.getElementById('beginmonth').length; i++)
        if (document.getElementById('beginmonth').options[i].value==beginmonth) {
            document.getElementById('beginmonth').options[i].selected=true;
            break;
            }
    for (i=0; i<document.getElementById('beginday').length; i++)
        if (document.getElementById('beginday').options[i].value==beginday) {
            document.getElementById('beginday').options[i].selected=true;
            break;
            }
    for (i=0; i<document.getElementById('endyear').length; i++)
        if (document.getElementById('endyear').options[i].value==endyear) {
            document.getElementById('endyear').options[i].selected=true;
            break;
            }
    for (i=0; i<document.getElementById('endmonth').length; i++)
        if (document.getElementById('endmonth').options[i].value==endmonth) {
            document.getElementById('endmonth').options[i].selected=true;
            break;
            }
    for (i=0; i<document.getElementById('endday').length; i++)
        if (document.getElementById('endday').options[i].value==endday) {
            document.getElementById('endday').options[i].selected=true;
            break;
            }
    document.index.submit();
    }
    
    
/*******************************************************************************
 * uj fuggvenyek
 ******************************************************************************/

// POST-al elküldi a frontpage-en a bejelentkezős form-ot
function updateLoginResponseDiv(){
    //Spry.Utils.setInnerHTML('loginform', req.xhRequest.responseText);
    obj = new Object;
    header = new Object;
    header["Content-Type"] = "application/x-www-form-urlencoded";
    obj["method"] = "POST";
    str =   'connectiontest='+encodeURIComponent(document.getElementById('loginf').connectiontest.value)+
            '&connection_datetime='+encodeURIComponent(document.getElementById('loginf').connection_datetime.value)+
            '&v_username='+encodeURIComponent(document.getElementById('loginf').v_username.value)+
            '&v_password='+encodeURIComponent(document.getElementById('loginf').v_password.value)+
            '&login_url='+encodeURIComponent(document.getElementById('loginf').login_url.value)+
            '&v_loginbutton='+encodeURIComponent(document.getElementById('loginf').v_loginbutton.value)+
            '&jsenabled=1';
    obj["postData"] = str;
    obj["headers"] = header;
    return obj;
    }

function updateNewPasswordDiv(){
    //Spry.Utils.setInnerHTML('loginform', req.xhRequest.responseText);
    obj = new Object;
    header = new Object;
    header["Content-Type"] = "application/x-www-form-urlencoded";
    obj["method"] = "POST";
    str =   'email='+encodeURIComponent(document.getElementById('loginf').email.value)+
            '&newpass='+encodeURIComponent(document.getElementById('loginf').newpass.value);
    obj["postData"] = str;
    obj["headers"] = header;
    return obj;
    }

function sendNewComment() {
    if (agr=document.getElementById('comm_agree')) {
      if (agr.checked) {
        str = 'agree='+encodeURIComponent(agr.value)+'&';
      } else {
        str='';
        alert('Please check this box to send your comment!');
      }
      if (str!='') {
        obj = new Object;
        header = new Object;
        header["Content-Type"] = "application/x-www-form-urlencoded";
        obj["method"] = "POST";
        obj["postData"] = str+'comment='+encodeURIComponent(document.getElementById('txtComment').value);
        obj["headers"] = header;
        return obj;
      }
    } else {
      str='';
      obj = new Object;
      header = new Object;
      header["Content-Type"] = "application/x-www-form-urlencoded";
      obj["method"] = "POST";
      obj["postData"] = str+'comment='+encodeURIComponent(document.getElementById('txtComment').value);
      obj["headers"] = header;
      return obj;
    }
}

// POST-al elküldi a frontpage-en a feliratkozós form-ot
function updateSignupResponseDiv(req) {
    Spry.Utils.setInnerHTML('mainbody', req.xhRequest.responseText);
    }

// ellenőrzi, hogy a frontpage-en lévő feliratkozós formon a megadott username foglalt-e vagy nem
function checkavailability() {
    available_checker.loadContent('/ajax/get_viewerid_available.php?vid='+document.getElementById('ViewerID').value);
    }

// flash connectiontest-nél beállítja a hidden field értékét
function SetResult(txt) {
    document.getElementById('connectiontest').value = txt;
    if (document.getElementById('connectiontest1')) { document.getElementById('connectiontest1').value = txt; }
    }

function signup_check() {
    var cp = checkPasswordMatch();
    var ve = validEmail(document.getElementById('EmailAddr'));
    if (cp && ve)
        return true;
    else
        return false;
    }

function validEmail(addr) {
    var valid = js_validateEmail(addr.value,1,1,'email_text');
    if (valid)
        return true;
    else
        return false;
    }

function js_validateEmail(addr,man,db,hova) {
    di = document.index;
    var strtext='';
    if (addr == '' && man) {
        if (db) {
            strtext='Email address is mandatory';
            (hova==undefined) ? alert(strtext) : document.getElementById(hova).innerHTML=strtext;
            return false;
            }
        }
    var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
    for (i=0; i<invalidChars.length; i++) {
        if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
            if (db) {
                strtext='Email address contains invalid characters';
                (hova==undefined) ? alert(strtext) : document.getElementById(hova).innerHTML=strtext;
                return false;
                }
            }
       }
    for (i=0; i<addr.length; i++) {
        if (addr.charCodeAt(i)>127) {
            if (db) {
                strtext='Email address contains non ascii characters.';
                (hova==undefined) ? alert(strtext) : document.getElementById(hova).innerHTML=strtext;
                return false;
                }
            }
       }
    var atPos = addr.indexOf('@',0);
    if (atPos == -1) {
        if (db) {
            strtext='Email address must contain an @';
            (hova==undefined) ? alert(strtext) : document.getElementById(hova).innerHTML=strtext;
            return false;
            }
        }
    if (atPos == 0) {
        if (db) {
            strtext='Email address must not start with @';
            (hova==undefined) ? alert(strtext) : document.getElementById(hova).innerHTML=strtext;
            return false;
            }
        }
    if (addr.indexOf('@', atPos + 1) > - 1) {
        if (db) {
            strtext='Email address must contain only one @';
            (hova==undefined) ? alert(strtext) : document.getElementById(hova).innerHTML=strtext;
            return false;
            }
        }
    if (addr.indexOf('.', atPos) == -1) {
        if (db) {
            strtext='Email address must contain a period in the domain name';
            (hova==undefined) ? alert(strtext) : document.getElementById(hova).innerHTML=strtext;
            return false;
            }
        }
    if (addr.indexOf('@.',0) != -1) {
        if (db) {
            strtext='Period must not immediately follow @ in email address';
            (hova==undefined) ? alert(strtext) : document.getElementById(hova).innerHTML=strtext;
            return false;
            }
        }
    if (addr.indexOf('.@',0) != -1){
        if (db) {
            strtext='Period must not immediately precede @ in email address';
            (hova==undefined) ? alert(strtext) : document.getElementById(hova).innerHTML=strtext;
            return false;
            }
        }
    if (addr.indexOf('..',0) != -1) {
        if (db) {
            strtext='Two periods must not be adjacent in email address';
            (hova==undefined) ? alert(strtext) : document.getElementById(hova).innerHTML=strtext;
            return false;
            }
        }
    var suffix = addr.substring(addr.lastIndexOf('.')+1);
    if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
        if (db) {
            strtext='Invalid primary domain in email address';
            (hova==undefined) ? alert(strtext) : document.getElementById(hova).innerHTML=strtext;
            return false;
            }
        }
    if (hova!=undefined) document.getElementById(hova).innerHTML='';
    return true;
    }
    
function correctPNG() { // correctly handle PNG transparency in Win IE 5.5 or higher.
    for(var i=0; i<document.images.length; i++) {
        var img = document.images[i];
        var imgName = img.src.toUpperCase();
        if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
            var imgID = (img.id) ? "id='" + img.id + "' " : "";
            var imgClass = (img.className) ? "class='" + img.className + "' " : "";
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
            var imgStyle = "display:inline-block;" + img.style.cssText;
            if (img.align == "left") imgStyle = "float:left;" + imgStyle;
            if (img.align == "right") imgStyle = "float:right;" + imgStyle;
            var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
            img.outerHTML = strNewHTML;
            i = i-1
            }
        }
    }

function widgetload(mit, mire) {
    panelWidget.loadContent('/ajax/member_settings.php?mit=Widget_'+mit+'&mire='+mire);
    switch (mit) {
        case 'widgets' : { w_widgets.loadContent('/ajax/widget_loader.php?mit='+mit+'&status='+mire); break; }
        case 'opinionpoll' : { w_opinionpoll.loadContent('/ajax/widget_loader.php?mit='+mit+'&status='+mire); break; }
        case 'modeloftheday' : { w_modeloftheday.loadContent('/ajax/widget_loader.php?mit='+mit+'&status='+mire); break; }
        case 'newperfpromo' : { w_newperfpromo.loadContent('/ajax/widget_loader.php?mit='+mit+'&status='+mire); break; }
        case 'lastnews' : { w_lastnews.loadContent('/ajax/widget_loader.php?mit='+mit+'&status='+mire); break; }
        }
    }

function sysdetect() {
    open("../sysdetect/systemDeterminer.html","SysDetect","width=620,height=620,top=50,left=100");
    }

/*******************************************************************************
 * memberareahoz tartozó függvények
 ******************************************************************************/
function PollRequest() {
    var j=-1;
    for (i=0; i<=10; i++) {
        if (document.getElementById('pollvalue_'+i) && document.getElementById('pollvalue_'+i).checked) j=i;
        }
    if (j>-1 && j<=10) {
        if (j==10)
            area_poll.loadContent('/ajax/poll.php?other=y&pollvalue='+document.getElementById('pollvalue_'+j).value);        
        else
            area_poll.loadContent('/ajax/poll.php?pollvalue='+document.getElementById('pollvalue_'+j).value);
        } 
    }
function memberarea_logout() {
    if (confirm("Are You Sure You want to Logout?")) document.location.href="../memberarea/logout.php";
    }
function memberarea_notewindow(n) {
    open("../memberarea/notes.php"+(n>"" ? "?Performer="+n : ""),"widgetnotes","width=700,height=500,top=50,left=50,status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
    }
function memberarea_tellafriend() {
    open("../memberarea/tellafriend.php","widgettellafriend","width=700,height=360,top=50,left=50,status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
    }
function memberarea_support() {
    open("../help/ticket.php");
    }
    
    
/*******************************************************************************
 * performerareahoz tartozó függvények
 ******************************************************************************/
function performerarea_logout() {
    if (confirm("Are You Sure You want to Logout?")) document.location.href="../performerarea/logout.php";
    }
function performerarea_tutorialwindowopen() {
    open("../help/flash-tutorial/flash-tutorial.html","Tutorial","width=825,height=555,top=20,left=50,status=no,toolbar=no,menubar=no,resizable=no,scrollbars=yes");
    }
function performerarea_flashwindowopen() {
    open("../modelsend/main.php","SenderWindow","width=897,height=662,top=50,left=100,status=no,toolbar=no,menubar=no,resizable=no,scrollbars=no");
    }
function performerarea_mailwindowopen() {
    open("../performerarea/mailboxlogin.php","mailablak","width=950,height=550,top=50,left=50,status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
    }
function performerarea_notewindowopen(viewerid) {
    if (viewerid>"") { n = "ViewerID="+viewerid; } else { n = ""; }
    open("../modelnotes/index.php?"+n,"noteablak","width=680,height=480,top=50,left=50,status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
    }
function performerarea_speedtestwindowopen() {
    open("../bwchecker/bwchecker.php","speedtest","width=220,height=350,top=50,left=50,status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
    }
function performerarea_awardswindowopen() {
    open("../performerarea/awards.php","awardsablak","width=770,height=550,top=50,left=50,status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
    }
function performerarea_support() {
    open("../help/ticket.php");
    }
    
/*******************************************************************************
 * studioareahoz tartozó függvények
 ******************************************************************************/
function studioarea_logout() {
    if (confirm("Are You Sure You want to Logout?")) document.location.href="../studioarea/logout.php";
    }
function studioarea_speedtestwindowopen() {
    open("../bwchecker/bwchecker.php","speedtest","width=220,height=350,top=50,left=50,status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
    }
function studioarea_support() {
    open("../help/ticket.php");
    }

/**/
  xdivfix = new Object();

  function xshowdiv(divid,cname,th) {
    th.className=cname;
    if (!(xdivfix[divid])) { xdivfix[divid] = false; }
    if (xdivfix[divid]==false) {
      document.getElementById(divid).style.display='block';
    }
  }
      
  function xhidediv(divid,cname,th) {
    th.className=cname;
    if (!(xdivfix[divid])) { xdivfix[divid] = false; }
    if (xdivfix[divid]==false) {
      document.getElementById(divid).style.display='none';
    }
  }

  function xclickdiv(divid) {
    if (!(xdivfix[divid])) { xdivfix[divid] = false; }
    xdivfix[divid] = !xdivfix[divid];
    document.getElementById('cl'+divid).style.display = (xdivfix[divid] ? 'block' : 'none');
  }

  function xclickhidediv(divid) {
    xdivfix[divid] = false;
    document.getElementById(divid).style.display='none';
    document.getElementById('cl'+divid).style.display = 'none';
  }
