﻿if (document.URL.indexOf("iseeboard") >= 0)
    var pipe5Path = document.URL.substr(0, document.URL.lastIndexOf('/')) + "/NET/cyberPath.php";
else
    var pipe5Path = "http://www.iseeboard.net/cyberPath.php";
var currFilm = '';
function loadBoard(name, u1, u2) {
   var d = new Date();
   if (currFilm.length > 0)
     eval(currFilm + ".style.border = ''");
   switch (name) {
       case "Fashion":
           p1.style.border = "3px solid red";
           currFilm = "p1";
           document.getElementById('MainShow').innerHTML = '<DIV style="position:relative"><img src="iseeboard/Images/fashionbk2.JPG" width=610/>' +
            '<img src="iseeboard/Images/Tag.GIF" style="left: 100px; width: 80px; position: absolute; top: 15px; height: 20px" />' +
            '<img src="iseeboard/Images/tv3.JPG" style="left: 70px; width: 140px; position: absolute; top: 36px; height: 191px" />' +
            '<IFRAME id="' + name + '1" name="' + name + '1" frameborder=0 marginheight=0 marginwidth=0 scrolling=no src="' + pipe5Path + '?UserId=' +
                u1 + '&dtime=' + d.getTime() + '&SS=X" style="left: 78px; width: 124px; position: absolute; top: 42px; height: 178px"></IFRAME>' +
            '<img src="iseeboard/Images/Tag.GIF" style="left: 390px; width: 80px; position: absolute; top: 177px; height: 20px" />' +
            '<img src="iseeboard/Images/tv2.JPG" style="left: 345px; width: 170px; position: absolute; top: 27px; height: 150px" />' +
            '<IFRAME id="' + name + '2" name="' + name + '2" frameborder=0 marginheight=0 marginwidth=0 scrolling=no src="' + pipe5Path + '?UserId=' +
                u2 + '&dtime=' + d.getTime() + '&SS=X" style="left: 350px; width: 160px; position: absolute; top: 33px; height: 134px"></IFRAME></DIV>';
           break;
       case "OutDoor":
           p2.style.border = '3px solid red';
           currFilm = "p2";
           document.getElementById('MainShow').innerHTML = '<DIV style="position:relative"><img src="iseeboard/Images/outdoorbk2.JPG" width=610/>' +
            '<img src="iseeboard/Images/tv2.JPG" style="left: 95px; width: 158px; position: absolute; top: 137px; height: 120px" />'+
            '<IFRAME id="'+name+'1" name="'+name+'1" frameborder=0 marginheight=0 marginwidth=0 scrolling=no src="'+pipe5Path+'?UserId='+
                u1+'&dtime='+d.getTime()+'&SS=X" style="left: 101px; width: 146px; position: absolute; top: 144px; height: 106px"></IFRAME>'+
            '<IFRAME id="'+name+'2" name="'+name+'2" frameborder=0 marginheight=0 marginwidth=0 scrolling=no src="'+pipe5Path+'?UserId='+
                u2 + '&dtime=' + d.getTime() + '&SS=X" style="left: 283px; width: 283px; position: absolute; top: 12px; height: 66px"></IFRAME></DIV>';
        break;
    case "FoodCourt":
        p3.style.border = '3px solid red';
        currFilm = "p3";
        document.getElementById('MainShow').innerHTML = '<DIV style="position:relative"><img src="iseeboard/Images/foodcourtbk2.JPG" width=610/>' +
            '<img src="iseeboard/Images/Tag.GIF" style="left: 110px; width: 80px; position: absolute; top: 60px; height: 20px" />'+
            '<img src="iseeboard/Images/tv2.JPG" style="left: 46px; width: 212px; position: absolute; top: 80px; height: 126px" />'+
            '<IFRAME id="'+name+'1" name="'+name+'1" frameborder=0 marginheight=0 marginwidth=0 scrolling=no src="'+pipe5Path+'?UserId='+
                u1+'&dtime='+d.getTime()+'&SS=X" style="left: 52px; width: 200px; position: absolute; top: 86px; height: 112px"></IFRAME>'+
            '<img src="iseeboard/Images/Tag.GIF" style="left: 345px; width: 80px; position: absolute; top: 22px; height: 20px" />'+
            '<img src="iseeboard/Images/tv2.JPG" style="left: 295px; width: 180px; position: absolute; top: 42px; height: 122px" />'+
            '<IFRAME id="'+name+'2" name="'+name+'2" frameborder=0 marginheight=0 marginwidth=0 scrolling=no src="'+pipe5Path+'?UserId='+
                u2 + '&dtime=' + d.getTime() + '&SS=X" style="left: 301px; width: 168px; position: absolute; top: 48px; height: 110px"></IFRAME></DIV>';
        break;
    case "SuperMarket":
        p4.style.border = '3px solid red';
        currFilm = "p4";
        document.getElementById('MainShow').innerHTML = '<DIV style="position:relative"><img src="iseeboard/Images/supermarketbk2.JPG" width=610/>' +
            '<img src="iseeboard/Images/Tag.GIF" style="left: 80px; width: 80px; position: absolute; top: 140px; height: 20px" />'+
            '<img src="iseeboard/Images/tv2.JPG" style="left: 20px; width: 202px; position: absolute; top: 20px; height: 120px" />'+
            '<IFRAME id="'+name+'1" name="'+name+'1" frameborder=0 marginheight=0 marginwidth=0 scrolling=no src="'+pipe5Path+'?UserId='+
                u1+'&dtime='+d.getTime()+'&SS=X" style="left: 26px; width: 190px; position: absolute; top: 26px; height: 106px"></IFRAME>'+
            '<img src="iseeboard/Images/Tag.GIF" style="left: 460px; width: 80px; position: absolute; top: 132px; height: 20px" />'+
            '<img src="iseeboard/Images/tv3.JPG" style="left: 441px; width: 118px; position: absolute; top: 10px; height: 172px" />'+
            '<IFRAME id="'+name+'2" name="'+name+'2" frameborder=0 marginheight=0 marginwidth=0 scrolling=no src="'+pipe5Path+'?UserId='+
                u2 + '&dtime=' + d.getTime() + '&SS=X" style="left: 447px; width: 108px; position: absolute; top: 16px; height: 160px"></IFRAME></DIV>';
        break;
    case "Restaurant":
        p5.style.border = '3px solid red';
        currFilm = "p5";
        document.getElementById('MainShow').innerHTML = '<DIV style="position:relative"><img src="iseeboard/Images/restaurantbk2.JPG" width=610/>' +
            '<img src="iseeboard/Images/Tag.GIF" style="left: 128px; width: 80px; position: absolute; top: 140px; height: 20px" />'+
            '<img src="iseeboard/Images/tv2.JPG" style="left: 20px; width: 202px; position: absolute; top: 20px; height: 120px" />'+
            '<IFRAME id="'+name+'1" name="'+name+'1" frameborder=0 marginheight=0 marginwidth=0 scrolling=no src="'+pipe5Path+'?UserId='+
                u1+'&dtime='+d.getTime()+'&SS=X" style="left: 26px; width: 190px; position: absolute; top: 26px; height: 106px"></IFRAME>'+
            '<img src="iseeboard/Images/Tag.GIF" style="left: 376px; width: 80px; position: absolute; top: 140px; height: 20px" />'+
            '<img src="iseeboard/Images/tv3.JPG" style="left: 315px; width: 202px; position: absolute; top: 20px; height: 120px" />'+
            '<IFRAME id="'+name+'2" name="'+name+'2" frameborder=0 marginheight=0 marginwidth=0 scrolling=no src="'+pipe5Path+'?UserId='+
                u2+'&dtime='+d.getTime()+'&SS=X" style="left: 321px; width: 190px; position: absolute; top: 26px; height: 106px"></IFRAME></DIV>';
        break;
    case "Foyer":
        p6.style.border = '3px solid red';
        currFilm = "p6";
        document.getElementById('MainShow').innerHTML = '<DIV style="position:relative"><img src="iseeboard/Images/foyer.JPG" width=610/>' +
            '<img src="iseeboard/Images/tv3.JPG" style="left: 370px; width: 170px; position: absolute; top: 20px; height: 280px" />' +
            '<IFRAME id="' + name + '1" name="' + name + '1" frameborder=0 marginheight=0 marginwidth=0 scrolling=no src="' + pipe5Path + '?UserId=' +
                u1 + '&dtime=' + d.getTime() + '&SS=X" style="left: 376px; width: 156px; position: absolute; top: 26px; height: 264px"></IFRAME></DIV>';
        break;
    case "Diamond":
        p7.style.border = '3px solid red';
        currFilm = "p7";
        document.getElementById('MainShow').innerHTML = '<DIV style="position:relative"><img src="iseeboard/Images/diamond.JPG" width=610/>' +
            '<img src="iseeboard/Images/tv3.JPG" style="left: 10px; width: 170px; position: absolute; top: 20px; height: 280px" />' +
            '<IFRAME id="' + name + '1" name="' + name + '1" frameborder=0 marginheight=0 marginwidth=0 scrolling=no src="' + pipe5Path + '?UserId=' +
                u1 + '&dtime=' + d.getTime() + '&SS=X" style="left: 16px; width: 156px; position: absolute; top: 26px; height: 264px"></IFRAME></DIV>';
        break;       
    case "Phone":
        p8.style.border = '3px solid red';
        currFilm = "p8";
        document.getElementById('MainShow').innerHTML = '<DIV style="position:relative"><img src="iseeboard/Images/phone.JPG" width=610/>' +
            '<img src="iseeboard/Images/tv3.JPG" style="left: 50px; width: 242px; position: absolute; top: 30px; height: 140px" />' +
            '<IFRAME id="' + name + '1" name="' + name + '1" frameborder=0 marginheight=0 marginwidth=0 scrolling=no src="' + pipe5Path + '?UserId=' +
                u1 + '&dtime=' + d.getTime() + '&SS=X" style="left: 56px; width: 230px; position: absolute; top: 36px; height: 126px"></IFRAME></DIV>';
        break;        
    case "Restaurant2":
        p9.style.border = '3px solid red';
        currFilm = "p9";
        document.getElementById('MainShow').innerHTML = '<DIV style="position:relative"><img src="iseeboard/Images/restaurant.JPG" width=610/>' +
            '<img src="iseeboard/Images/tv2.JPG" style="left: 280px; width: 270px; position: absolute; top: 30px; height: 160px" />' +
            '<IFRAME id="' + name + '1" name="' + name + '1" frameborder=0 marginheight=0 marginwidth=0 scrolling=no src="' + pipe5Path + '?UserId=' +
                u1 + '&dtime=' + d.getTime() + '&SS=X" style="left: 286px; width: 258px; position: absolute; top: 36px; height: 144px"></IFRAME></DIV>';
        break;                
    case "ThankYou":
        p0.style.border = '3px solid red';
        currFilm = "p0";
        document.getElementById('MainShow').innerHTML = '<DIV style="position:relative"><img src="iseeboard/Images/desk.JPG" width=610/>' +
            '<img src="iseeboard/Images/tv3.JPG" style="left: 100px; width: 460px; position: absolute; top: 15px; height: 280px" />' +
            '<IFRAME id="' + name + '1" name="' + name + '1" frameborder=0 marginheight=0 marginwidth=0 scrolling=no src="' + pipe5Path + '?UserId=' +
                u1 + '&dtime=' + d.getTime() + '&SS=X" style="left: 106px; width: 448px; position: absolute; top: 21px; height: 266px"></IFRAME></DIV>';
        break;
    }
}
function showRoomOut(who) {
    if (currFilm != who.id)
        who.style.border = "";
}
function showRoomOver(who) {
    if (currFilm != who.id)
        who.style.border = "3px solid yellow";
}
function viewTV(name, id) {
  if (id == 1)
      s = window.open("TVwindow.php?n=" + name + "&id=" + id + "&dir=" + document.URL, "popup2", "fullscreen=0, width=460, height=310, location=0, menubar=0, status=0, toolbar=0, resizable=1");
  else
      s = window.open("TVwindow.php?n=" + name + "&id=" + id + "&dir=" + document.URL, "popup2", "fullscreen=0, width=283, height=490, location=0, menubar=0, status=0, toolbar=0, resizable=1");
  s.focus();
}
function ajaxLoad(fname, idx) { // idx: ReqUserName / ReqPassword

    var MxHttp = new XmlHttpObject;
    if (MxHttp.Get() == null)
        return;
    var url = "iseeboard/ajaxServer.php?f=" + fname + "&d=" + idx + "&sid=" + Math.random();
    //alert(url);
    MxHttp.httpObj.onreadystatechange = function() {
        if (MxHttp.httpObj.readyState == 4 || MxHttp.httpObj.readyState == "complete") {
            if (MxHttp.httpObj.responseText.substring(0, 3) == String.fromCharCode(0xef, 0xbb, 0xbf))  // BOM
                MxHttp.httpObj.responseText = MxHttp.httpObj.responseText.substring(3);
            //alert(MxHttp.httpObj.responseText);
            var temp = MxHttp.httpObj.responseText.split("<$$$>");
            if (temp.length > 1 && temp[0].indexOf("ALERT") >= 0)
                alert(temp[1]);
            else if (temp.length > 1) {
                document.getElementById("txtHead").innerHTML = temp[0];
                document.getElementById("txtDesc").innerHTML = temp[1];
            }    
            else 
                document.getElementById("txtDesc").innerHTML = temp[0];
        }
    }
    MxHttp.httpObj.open("GET", url, true);  // if post, '&'ed name-value pair in $par is sent in xmlHttp.send($par);
    MxHttp.httpObj.send(null);
}
function loadContent(idx) { // idx: hour
    document.getElementById('func').value = idx;
    document.FORM1.submit();
}
function pageInit() {
    document.getElementById("UserId").focus();
    if (document.getElementById("carousel") != null)
        carousel();
}
function submitenter(thisfld, e, note) {
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;

    if (keycode == 13 && thisfld.name == "UserId")
        document.getElementById(note).focus();
    else if (keycode == 13 && thisfld.name == "UserPass")
        lengthCheck(note);
    else
        return true;
    return false;
}
function changeLang() {
    var cty = document.getElementById('Languages').options[document.getElementById("Languages").selectedIndex].value;
    var ExpireDate = new Date();
    ExpireDate.setDate(ExpireDate.getDate() + 30);
    document.cookie = "ISBLANG=" + escape(cty) + "; expires=" + ExpireDate.toGMTString();
    //document.getElementById('lang').value = unescape(cty);
    document.FORM1.submit();
}
function lengthCheck(txt1) {
    if (document.getElementById('UserId').value.length > 0 &&
      document.getElementById('UserPass').value.length > 0)
        doLogin(document.getElementById('UserId').value, document.getElementById('UserPass').value, "cyberCtrl.php", callbackLogin);
    else
        alert(txt1);
}
function chkEmail(txt1) {
    var eAddr = document.getElementById('emailname').value;
    var atPos = eAddr.indexOf('@');
    if (atPos > 0)   // must contain '@' and is not in the 1st position
    {
        var dotPos = eAddr.lastIndexOf('.');
        if (dotPos > 0 && dotPos > (atPos + 1))  // must conatin '.' and is not in the 1st position
            return true;                          // and '@' must be in front of '.'
    }
    alert(txt1);
    return false;
}

function callPass(txt) {
    if (document.getElementById("uname").value.length <= 0)
      alert(txt);
    else
      callServer('ReqPassword', document.getElementById("uname").value, callbackPass)
}
function callbackPass(result) {
    document.getElementById("func").value = 'sendOk';
    if (result > 0) {
      document.getElementById("func").value = 'sendFail';
      document.getElementById("parm").value = parseInt(result);
    }
    document.FORM1.submit();
}
function callUser() {
    callServer('ReqUserName', document.getElementById("emailname").value, callbackUser);
}
function callbackUser(result) {
    document.getElementById("func").value = 'sendOk';
    if (result > 0) {
        document.getElementById("func").value = 'sendFail';
        document.getElementById("parm").value = parseInt(result) + 10;
    }
    document.FORM1.submit();
}
function createReg(txt, callbackURL) {
  //  if (typeof (callbackURL) == "undefined" || callbackURL == '')
  //      callbackURL = callbackCreateReg;
  if (document.getElementById('gCustName').value.length <= 0)
      alert(missAcctName);
  //else if (document.getElementById('gCustCnt').value.length <= 0)
  //    alert(missContact);
  //else if (document.getElementById('UserName').value.length <= 0)
  //    alert(missUserName);
  else if (document.getElementById('LoginId').value.length <= 0)
      alert(missLoginId);
  else if (document.getElementById('LoginPass').value.length <= 0)
      alert(missPassword);
  else if (document.getElementById('LoginPass').value != document.getElementById('rePass').value) {
      alert(missReType);
      document.getElementById('LoginPass').value = "";
      document.getElementById('rePass').value = "";
  }
  else {
    if (confirm(txt)) 
      callServer('ReqAccount', document.getElementById('code').value + 
      '&gCustName=' + encodeURIComponent(document.getElementById('gCustName').value).replace(/'/g, "\\'").replace(/&/g, "%26") +
      '&gCustCnt=' + encodeURIComponent(document.getElementById('gCustCnt').value).replace(/'/g, "\\'").replace(/&/g, "%26") +
      '&gCustCntTel=' + document.getElementById('gCustCntTel').value +
      '&aAddr1=' + encodeURIComponent(document.getElementById('aAddr1').value).replace(/'/g, "\\'").replace(/&/g, "%26") +
      '&aAddr2=' + encodeURIComponent(document.getElementById('aAddr2').value).replace(/'/g, "\\'").replace(/&/g, "%26") +
      '&aCity=' + encodeURIComponent(document.getElementById('aCity').value).replace(/'/g, "\\'").replace(/&/g, "%26") +
      '&aState=' + encodeURIComponent(document.getElementById('aState').value).replace(/'/g, "\\'").replace(/&/g, "%26") + 
      '&aZip=' + document.getElementById('aZip').value +
      '&aTel=' + document.getElementById('aTel').value + '&aFax=' + document.getElementById('aFax').value +
      '&aEmail=' + encodeURIComponent(document.getElementById('aEmail').value).replace(/'/g, "\\'").replace(/&/g, "%26") +
      '&aNote=' + encodeURIComponent(document.getElementById('aNote').value).replace(/'/g, "\\'").replace(/&/g, "%26") +
      '&UserName=' + document.getElementById('LoginId').value + '&LoginId=' + document.getElementById('LoginId').value +
      '&LoginPass=' + document.getElementById('LoginPass').value, callbackCreateReg, callbackURL);
  }
}
function callbackCreateReg(result, callbackURL) {
    if (result.length > 4 && result.substr(0, 4) != "SSLX") {
        document.getElementById("code").focus;
        alert(result);
        document.getElementById('secrImg').src = 'securimage/securimage_show.php?sid=' + Math.random();
        document.getElementById('code').value = "";
    }
    else {
        if (callbackURL != null) {
            document.getElementById("code").value = result;  // started by SSLX
            document.FORM1.action = callbackURL;
        }
        else if (document.getElementById("func") != null)
            document.getElementById("func").value = 'RegOk';
        document.FORM1.submit();
    }
}
function callbackLogin(result) {
    document.getElementById("func").value = 'loginFail';
    document.FORM1.submit();
}
//************* function ImageCarousel () {
    var v = {
        id: 'images', // id attribute where images lie
        speed: 5, // speed of carousel, 1-50
        imgCnt: 5,
        offset: 0,
        timer: null
    };
    function carousel () {
        v['imgs'] = document.getElementById(v['id']).getElementsByTagName('img');
        // Check if there's at least 2 images
        if (v['imgs'].length < 2) return;
        // Grab width/height of first image
        v['width'] = v['imgs'][0].width + 10;
        v['height'] = v['imgs'][0].height + 6;
        // Use width/height to create image window
        document.getElementById(v['id']).style.width = v['width'] * v['imgCnt'] + 'px';
        document.getElementById(v['id']).style.height = v['height'] + 'px';
        document.getElementById(v['id']).style.overflow = "hidden";
        // Center marquee
        document.getElementById('carousel').style.width = v['width'] * v['imgCnt'] + 60 + 'px';

        // Style left and right buttons accordingly
        document.getElementById('btn-left').getElementsByTagName('span')[0].style.height = v['height'] + 'px';
        document.getElementById('btn-left').style.display = 'block';
        document.getElementById('btn-right').getElementsByTagName('span')[0].style.height = v['height'] + 'px';
        document.getElementById('btn-right').style.display = 'block';

        // Style each image and position it
        for (var x = 0, y = v['imgs'].length; x < y; x++) {
            v['imgs'][x].style.position = 'absolute';
            v['imgs'][x].style.top = 0 + 'px';
            v['imgs'][x].style.left = x * v['width'] + 'px';
        }
        // Attach events to buttons
        document.getElementById('btn-left').onmouseover = Left;
        document.getElementById('btn-left').onmouseout = Stop;
        document.getElementById('btn-right').onmouseover = Right;
        document.getElementById('btn-right').onmouseout = Stop;
    };
    Start = function () { v['offset'] = 0; Redraw(); };
    Stop = function () { clearTimeout(v['timer']); };
    Left = function () {
        if (v['offset'] <= -v['speed']) {
            v['offset'] += v['speed']; Redraw();
            v['timer'] = setTimeout(function () { Left() }, 70);
        }
    };
    Right = function () {
        if (v['offset'] > 1 - (v['width'] * (v['imgs'].length - v['imgCnt']))) {
            v['offset'] -= v['speed']; Redraw();
            v['timer'] = setTimeout(function () { Right() }, 70);
        }
    };
    Redraw = function () {
        // Check if first image is beyond, if so bring in back
        //if (v['offset'] > (v['width'] * (v['imgs'].length-1))
        //|| v['offset'] < 1 - (v['width'] * (v['imgs'].length-1))) {
        //  v['offset'] = (v['offset'] < 0) ? v['width']-v['speed'] : 0-(v['width']);
        //}
        // Set position for each image
        for (var x = 0, y = v['imgs'].length; x < y; x++) {
            v['imgs'][x].style.left = (v['offset'] <= 0) ? (v['offset'] + (x * v['width'])) + 'px' : (0 - ((y - x) * v['width']) + v['offset']) + 'px';
        }
    };

