var dCm = document; function SubmitFantasy() {
    var d = getById("frmQA"); var MA = new Array(); if (trimString(d.subject.value) == "") { MA[MA.length] = "subject"; d.subject.focus(); } if (trimString(d.question.value) == "") { MA[MA.length] = "fantasy"; d.question.focus(); }
    if (MA.length == 2) { alert("Please fill in the " + MA[0] + " and the " + MA[1] + "."); return false; } else if (MA.length == 1) { alert("Please fill in the " + MA[0] + "."); return false; } d.submit();
}
function trimString(str) { return str.replace(/^\s+/g, '').replace(/\s+getById/g, ''); } function getById(id) { return dCm.getElementById(id); }
function readMessage(e, HewID, NickName) { HideSrcImg(e); showWaitMsg(getById("PopUpBox")); SetInnerHTMLFromAjaxResponse("/readMessageJX.asp?hewid=" + HewID + "&nickname=" + NickName, "PopUpBox"); ShowPopUp(e); }
function blockUser(HewID, NickName, Type) { showWaitMsg(getById("PopUpBox")); SetInnerHTMLFromAjaxResponse("/readMessageJX.asp?hewid=" + HewID + "&nickname=" + NickName + "&type=" + Type, "PopUpBox"); }
function ShowPopUp(e) { var obj = getById("PopUpBox"); var pos = getPosition(e); obj.style.left = pos.x - 160 + 'px'; obj.style.top = pos.y - 220 + 'px'; obj.style.display = "block"; }
function HidePopUp() { getById("PopUpBox").style.display = "none"; getById("PopUpBox").innerHTML = ""; } function ScrollDiv() { try { getById("PopUpBox").style.top = dCm.body.scrollTop + 190 + 'px'; } catch (e) { } }
function CheckMessage() { if (!confirm('You will no longer receive online messages from ' + oObj.NickName.value + '.\n You can unblock ' + oObj.NickName.value + '�s online messages from your Account Preferences.')) { return false; } }
function HideSrcImg(evt) {
    var srcEl = evt.srcElement ? evt.srcElement : evt.target;
    if (srcEl != null) srcEl.style.display = "none";
}
function showWaitMsg(obj) {
    obj.innerHTML = "<div style='height:45%;width:100%;'>&nbsp;</div><div style='text-align:center;width:100%;'><img src='http://i6.imlive.com/images/indicator.gif' /><p style='margin-top:5px;font-family:Verdana;font-size:10px;'>Loading...</p></div>";
}
function getPosition(evt) {
    var left, top;
    left = screen.width / 2;
    top = screen.height / 2 + document.body.scrollTop + document.documentElement.scrollTop;
    return { x: left, y: top };
}
/*
gtype - guest type, groups are same as in mobile
wr - url to host waiting room (profile)
on - host is online or offline, values: 0|1
cm - video chat mode - free mode = 1, private chat mode: 0
rid - room id (int)
nick - host nickname
*/
var isOver = 0;

var timer_flash = false;
var currentFlashID = "";
function loadSwf(id, file, gt, wr, on, cm, rid, nick) {
    isOver = 1;
    var params = 'flv=' + file + '&gtype=' + gt + '&wr=' + wr + '&on=' + on + '&cm=' + cm + '&rid=' + rid + '&nick=' + nick;
    if (timer_flash) {
        clearTimeout(timer_flash);
    }
    timer_flash = setTimeout("doSingleFlash('" + id + "','" + params + "','" + PreviewerSWF + "');", 500);
}
function loadFLC(id, nick, cdn, rid, hid, ws) {  
    isOver = 1;
    var params='H='+nick+'&S='+nick+'&cdnserver='+escape(cdn)+'&rid='+rid+'&ws='+escape(ws)+'&hid='+hid+'&vtype=' + vType+ '&ptime=90&fs=1'+(auth!=undefined?'&auth='+auth:"");
    if (timer_flash) {
        clearTimeout(timer_flash);
    }
    timer_flash = setTimeout("doSingleFlash('" + id + "','" + params + "','" + FLCPlayer  + "');", 500);
}

function doSingleFlash(id, params, player) {
    if (currentFlashID != "" && currentFlashID != id) {
        clearSwf(currentFlashID);
    }
    currentFlashID = id;
    if (isOver == 0) { return; };

    document.getElementById("d" + id).style.display = 'none';
    if (document.getElementById("n" + id)) {
        document.getElementById("n" + id).style.display = 'none';
    }
    if (document.getElementById("pvalue" + id)) {
        document.getElementById("pvalue" + id).style.display = 'none';
    }    
    
    var height = "118";
    var width = "142";
        
    if (document.getElementById(id).className.indexOf("movdiv3") > -1) {
        height = "183";
        width = "255";
    }

    if (document.getElementById(id).className.indexOf("movdiv4") > -1) {
        height = "132";
        width = "180";
    }    

    var fo = new SWFObject(player, "f" + id, width, height, "10.0.22.87", "");
    fo.addParam("flashvars", params + "&width=" + width + "&height=" + height);
    fo.addParam("wmode", "transparent");
    fo.addParam("allowFullScreen", "true");

    fo.write(id);    
    var obj = getById(id);
    obj.onmouseout = function() {clearSwf(id);}
    if (obj.captureEvents) obj.captureEvents(Event.MOUSEOUT);
    
}
function gotoOut(id,rid) {
    clearSwf(id); 
}
function clearSwf(id) {

    var tp = thisMovie("f" + id);
    if (tp) {try {if (tp.isFS() == 1) {return false;}} catch (e) { }}

    document.getElementById("d" + id).style.display = 'block';
    if (document.getElementById("n" + id)) {
        document.getElementById("n" + id).style.display = 'block';
    }
    if (document.getElementById("pvalue" + id)) {
        document.getElementById("pvalue" + id).style.display = 'block';
    }

    if (document.getElementById("vidlink" + id)) {
        document.getElementById("vidlink" + id).style.display = 'block';
    }  
    
    document.getElementById(id).innerHTML = '';  
}
function thisMovie(movieName) {if (window.document[movieName]) { return window.document[movieName] }if (navigator.appName.indexOf("Microsoft Internet") == -1) {if (document.embeds && document.embeds[movieName]) { return document.embeds[movieName] }}else { return document.getElementById(movieName) }}
function goFree(nick, room) {
    location.href = '/flash_sdk/freevideochatguest.aspx?hostnick=' + nick + '&roomid=' + room;
}
function goPrivate(nick) {
    location.href = '/chat.aspx?hostnick=' + nick;
}
function goProfile(wrUrl) {
    location.href = wrUrl;
}
function gotoFreeChat(H, rid) {
    document.location.href = "/flash_sdk/FreeVideoChatGuest.aspx?hostnick=" + H + '&roomid=' + rid;
}
function gotoPrivateChat(H) {
    location.href = '/chat.aspx?hostnick=' + H;
}
function gotoSignup() {
    document.location.href = "/webcam-sign-up/";
}

