function showTool(obj, no) {
    if (!document.getElementById('tool_tip')) {
        var text = new Array();
        text[1] = "Supports MPEG-4 standard container files that contain video and audio H.264 / AAC encoded: MP4, M4V, M4A, MOV, Mp4v, F4V.";
        text[2] = "You don't need to worry about repositioning the controls, all you need to embed a VideoPlayer instance and the components will reposition automatically.";
        text[3] = "Automatically generates code lines that your visitors can use to embed your player version on other sites.";
        text[4] = "Your visitors will be able to send an email to their friends recommending your player; the email can contain html code and you can also edit the email's template.";
        text[5] = "Brand your videos: you can set the path to your own logo that will appear above of your videos.";
        text[6] = "Space key and mouse click both toggle play/pause. Double click toggles fullscreen on and off.";
        text[7] = "For those with AS knowledge, the code behind the player is fully object oriented: clean, easy to understand, maintain and modify.";
        text[8] = "The settings file contains more than 120 options and color settings which make it easy for you to perfectly adapt the player to your needs.";
        text[9] = "You can set the title and the description for each video from the settings file.";
        text[10] = "You can add your own subtitle to your videos using one of the four supported file formats: sub, srt, custom xml or TimedText.";
        text[11] = "You can set a playlist with unlimited number of videos.";
        text[12] = "Each video in your playlist is associated to a thumb image, for quick finding.";
        text[15] = "Keep the playlist organized: group your videos into an unlimited number of categories.";
        text[16] = "Users can see the title and the description of your videos from within the playlist.";
        text[17] = 'The Free Version not include: Watermark removed, All features and Source files';
        text[18] = "<b>PERSONAL LICENSE</b><br/><br/>By purchasing and downloading this Flash file, you are entitled, as buyer, to use it in an unlimited number of websites and other multimedia and personal projects. You may not redistribute / resell the functionality provided with the purchased product without the author's, FlashXpert, written permission, but you may modify its content. In case you want to use the product for a commercial project, then you will have to buy one of the 'Commercial Licenses'.";
        text[19] = "<b>SINGLE COMMERCIAL LICENSE</b><br/><br/>By purchasing this license, you are entitled to use the product in one commercial project (website, CD-ROM, offline presentation etc). You may not redistribute the product but you may modify its content. In case you want to use the product in multiple commercial websites, then you will have to buy the 'Multiple Commercial License'.";
        text[20] = "<b>MULTIPLE COMMERCIAL LICENSE</b><br/><br/>By purchasing this license you are entitled to use the product in multiple commercial projects (websites, CD-ROMS, offline presentations etc). You may not redistribute it but you may modify its content. You may not redistribute the functionality provided with the purchased product without the author's, FlashXpert, written permission.'.";
        var inner = obj.innerHTML;
        var tool = "<div class='absolute' id='tool_tip'><div class='tool_tip'><div class='bl'><div class='b'><div class='br'><div class='r'><div class='tool'><div class='thing'><img src='/Themes/flashxpert/images/tool_tip_thing.png' width='17' height='9' alt='asd' /></div><div class='text'>" + text[no] + "</div></div></div></div></div></div></div></div>";
        var finalHtml = tool + inner;
        obj.innerHTML = finalHtml;
    }
}

function hideTool() {
    var parent = document.getElementById('tool_tip').parentNode;
    parent.removeChild(parent.firstChild);
}

function checkbox(el, input) {
    if (el.className == "checkboxon") {
        el.className = "checkbox";
        try {
            input.removeAttribute("checked");
        } catch (e) {}
    }
    else {
        el.className = "checkboxon";
        input.setAttribute("checked", "checked");
    }
    if (input.name == "cookieneverexp") document.getElementById("cookielength").disabled = input.checked;
}

function checkall(parent_id) {
    var parent = document.getElementById(parent_id);
    var children = parent.childNodes;
    var childChids;
    for (i = 0; i < children.length; i++) {
        if (children[i].className == "left") {
            try {
                if (children[i].firstChild.className == "checkbox" && children[i].firstChild != document.getElementById('all')) children[i].firstChild.className = "checkboxon";
                else if (children[i].firstChild.className == "checkboxon" && children[i].firstChild != document.getElementById('all')) children[i].firstChild.className = "checkbox";
            } catch (e) {}
        }
    }
}

function insertValue(val, id) {
    document.getElementById('pseudo' + id).value = val;
    document.getElementById('pseudo' + id).innerHTML = val;
}

function hideElementsByClass(theClass) {
    var allHTMLTags = document.getElementsByTagName("*");
    for (i = 0; i < allHTMLTags.length; i++) {
        if (allHTMLTags[i].className.indexOf(theClass) >= 0) {
            allHTMLTags[i].style.display = "none";
        }
    }
}

function showBlock(a, tab_id) {
    hideElementsByClass('showhide');
    document.getElementById(tab_id).style.display = "block";
    var curli = a.parentNode;
    var parent = curli.parentNode;
    var children = parent.childNodes;
    for (i = 0; i < children.length; i++) {
        if (children[i] == curli) children[i].className += " selected";
        else {
            try {
                children[i].className = children[i].className.replace(" selected", "");
            } catch (e) {}
        }
    }
}

function showTab(a, tab_id) {
	console.log(a);
    hideElementsByClass('showhidetab');
    document.getElementById(tab_id).style.display = "block";
    var curtab = a.parentNode.parentNode.parentNode;
    var parent = curtab.parentNode;
    var children = parent.childNodes;
    for (i = 0; i < children.length; i++) {
        if (children[i] == curtab) children[i].className = "white_tab";
        else {
            try {
                children[i].className = "grey_tab";
            } catch (e) {}
        }
    }
}

function changeClass(radio, custom, prod_id) {
    var licType = '';
	var ppBtn_id = new Array(6);
	ppBtn_id[1] = new Array('ZJGT5PAVB2GW8', '89Z4L7BQZ9XYY', 'DRBPT5ULQNFDN');
	ppBtn_id[2] = new Array('MV4Y8W377V3QQ', 'A9T6L8GSDPW4Q', 'H6Z6AJRPGT9CN');
	ppBtn_id[3] = new Array('39PY5AF8AV6VA', 'WQ6FTZZYEMZ6A', '34YX32NZ7JG6A');
	ppBtn_id[4] = new Array('9262B6VYAECNG', 'FTQVBEX73G6BY', 'G2JQ82WBB4WHG');
	ppBtn_id[5] = new Array('UCQHWE8THJHC8', '44BNTAN9LFC5N', 'WYK6QHT54RX7J');

    if (radio.id == "standard")
	{
		licType = ppBtn_id[prod_id][0];
	}else if (radio.id == "comercial")
	{
		licType = ppBtn_id[prod_id][1];
	}else if (radio.id == "multiple")
	{
		licType = ppBtn_id[prod_id][2];
	}
    var cur = radio.parentNode.parentNode.parentNode.parentNode.parentNode;
    var parent = cur.parentNode;
    var children = parent.childNodes;
    for (i = 0; i < children.length; i++) {
        if (children[i] == cur) {
            children[i].className = children[i].className.replace("unsel", "sel");
            if (custom != 0) {
                document.getElementById('license_id').value = licType;
                document.getElementById('custom_id').value = custom;
            }
        }
        else {
            try {
                children[i].className = children[i].className.replace(" sel", " unsel");
            } catch (e) {}
        }
    }
}

function change_licence(is_logged, prod_id) {
    var licence = new Array(4);
    licence[0] = new Array(10, 20, 50);
    licence[1] = new Array(18, 36, 90);
    licence[2] = new Array(26, 52, 130);
    licence[3] = new Array(37, 74, 185);
    var i = document.getElementById('licence_select').value;
    var licence_text = document.getElementById('licence_text');
    var price1 = document.getElementById('price1');
    var price2 = document.getElementById('price2');
    var price3 = document.getElementById('price3');
    var price4 = document.getElementById('price4');
    licence_text.innerHTML = "See " + document.getElementById('licence_select').options[i].text + " license";
    licence_text.setAttribute('href', "javascript: void(0)");
    switch (i) {
    case "0":
        licence_text.setAttribute('onclick', "javascript:open(\'PersonalLicense.html\', \'\', \'height=180,width=560, toolbar=no, status=no, scrollbars=yes, menubar=no\');");
        break;
    case "1":
        licence_text.setAttribute('onclick', "javascript:open(\'SingleCommercialLicense.html\', \'\', \'height=160,width=560, toolbar=no, status=no, scrollbars=yes, menubar=no\');");
        break;
    case "2":
        licence_text.setAttribute('onclick', "javascript:open(\'MultipleCommercialLicense.html\', \'\', \'height=160,width=560, toolbar=no, status=no, scrollbars=yes, menubar=no\');");
        break;
    }
    price1.innerHTML = "$" + licence[0][i];
    price2.innerHTML = "$" + licence[1][i];
    price3.innerHTML = "$" + licence[2][i];
    price4.innerHTML = "Buy pack for $" + licence[3][i] + " and save 30%";
    if (is_logged) {
        var ppBtn_id = new Array(4);
        ppBtn_id[0] = new Array('ZJGT5PAVB2GW8', '89Z4L7BQZ9XYY', 'DRBPT5ULQNFDN');
        ppBtn_id[1] = new Array('MV4Y8W377V3QQ', 'A9T6L8GSDPW4Q', 'H6Z6AJRPGT9CN');
        ppBtn_id[2] = new Array('39PY5AF8AV6VA', 'WQ6FTZZYEMZ6A', '34YX32NZ7JG6A');
        ppBtn_id[3] = new Array('9262B6VYAECNG', 'FTQVBEX73G6BY', 'G2JQ82WBB4WHG');
        document.getElementById('ppBtn1').value = ppBtn_id[0][i];
        document.getElementById('ppBtn2').value = ppBtn_id[1][i];
        document.getElementById('ppBtn3').value = ppBtn_id[2][i];
        document.getElementById('ppBtn4').value = ppBtn_id[3][i];
        document.getElementById('custom1').value = prod_id[0][i];
        document.getElementById('custom2').value = prod_id[1][i];
        document.getElementById('custom3').value = prod_id[2][i];
        document.getElementById('custom4').value = prod_id[3][i];
    }
}

function changeVersion() {
	var sel = document.getElementById("selLic");
	var id = "v" + sel.options[sel.selectedIndex].value;
	hideElementsByClass('licVer');
	document.getElementById(id).style.display = "block";	
}
var smf_formSubmitted = false;
if (typeof(document.getElementById) == "undefined") document.getElementById = function (id) {
    return document.all[id];
}
else if (!window.XMLHttpRequest && window.ActiveXObject) window.XMLHttpRequest = function () {
    return new ActiveXObject(navigator.userAgent.indexOf("MSIE 5") != -1 ? "Microsoft.XMLHTTP" : "MSXML2.XMLHTTP");
};
if (typeof(document.forms) == "undefined") document.forms = document.getElementsByTagName("form");

function getXMLDocument(url, callback) {
    if (!window.XMLHttpRequest) return false;
    var myDoc = new XMLHttpRequest();
    if (typeof(callback) != "undefined") {
        myDoc.onreadystatechange = function () {
            if (myDoc.readyState != 4) return;
            if (myDoc.responseXML != null && myDoc.status == 200) callback(myDoc.responseXML);
        };
    }
    myDoc.open('GET', url, true);
    myDoc.send(null);
    return true;
}

function sendXMLDocument(url, content, callback) {
    if (!window.XMLHttpRequest) return false;
    var sendDoc = new window.XMLHttpRequest();
    if (typeof(callback) != "undefined") {
        sendDoc.onreadystatechange = function () {
            if (sendDoc.readyState != 4) return;
            if (sendDoc.responseXML != null && sendDoc.status == 200) callback(sendDoc.responseXML);
            else callback(false);
        };
    }
    sendDoc.open('POST', url, true);
    if (typeof(sendDoc.setRequestHeader) != "undefined") sendDoc.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    sendDoc.send(content);
    return true;
}

function textToEntities(text) {
    var entities = "";
    for (var i = 0; i < text.length; i++) {
        if (text.charCodeAt(i) > 127) entities += "&#" + text.charCodeAt(i) + ";";
        else entities += text.charAt(i);
    }
    return entities;
}

function reqWin(desktopURL, alternateWidth, alternateHeight, noScrollbars) {
    if ((alternateWidth && self.screen.availWidth * 0.8 < alternateWidth) || (alternateHeight && self.screen.availHeight * 0.8 < alternateHeight)) {
        noScrollbars = false;
        alternateWidth = Math.min(alternateWidth, self.screen.availWidth * 0.8);
        alternateHeight = Math.min(alternateHeight, self.screen.availHeight * 0.8);
    }
    else noScrollbars = typeof(noScrollbars) != "undefined" && noScrollbars == true;
    window.open(desktopURL, 'requested_popup', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=' + (noScrollbars ? 'no' : 'yes') + ',width=' + (alternateWidth ? alternateWidth : 480) + ',height=' + (alternateHeight ? alternateHeight : 220) + ',resizable=no');
    return false;
}

function storeCaret(text) {
    if (typeof(text.createTextRange) != "undefined") text.caretPos = document.selection.createRange().duplicate();
}

function replaceText(text, textarea) {
    if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange) {
        var caretPos = textarea.caretPos;
        caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
        caretPos.select();
    }
    else if (typeof(textarea.selectionStart) != "undefined") {
        var begin = textarea.value.substr(0, textarea.selectionStart);
        var end = textarea.value.substr(textarea.selectionEnd);
        var scrollPos = textarea.scrollTop;
        textarea.value = begin + text + end;
        if (textarea.setSelectionRange) {
            textarea.focus();
            textarea.setSelectionRange(begin.length + text.length, begin.length + text.length);
        }
        textarea.scrollTop = scrollPos;
    }
    else {
        textarea.value += text;
        textarea.focus(textarea.value.length - 1);
    }
}

function surroundText(text1, text2, textarea) {
    if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange) {
        var caretPos = textarea.caretPos,
            temp_length = caretPos.text.length;
        caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text1 + caretPos.text + text2 + ' ' : text1 + caretPos.text + text2;
        if (temp_length == 0) {
            caretPos.moveStart("character", -text2.length);
            caretPos.moveEnd("character", -text2.length);
            caretPos.select();
        }
        else textarea.focus(caretPos);
    }
    else if (typeof(textarea.selectionStart) != "undefined") {
        var begin = textarea.value.substr(0, textarea.selectionStart);
        var selection = textarea.value.substr(textarea.selectionStart, textarea.selectionEnd - textarea.selectionStart);
        var end = textarea.value.substr(textarea.selectionEnd);
        var newCursorPos = textarea.selectionStart;
        var scrollPos = textarea.scrollTop;
        textarea.value = begin + text1 + selection + text2 + end;
        if (textarea.setSelectionRange) {
            if (selection.length == 0) textarea.setSelectionRange(newCursorPos + text1.length, newCursorPos + text1.length);
            else textarea.setSelectionRange(newCursorPos, newCursorPos + text1.length + selection.length + text2.length);
            textarea.focus();
        }
        textarea.scrollTop = scrollPos;
    }
    else {
        textarea.value += text1 + text2;
        textarea.focus(textarea.value.length - 1);
    }
}

function isEmptyText(theField) {
    var theValue = theField.value;
    while (theValue.length > 0 && (theValue.charAt(0) == ' ' || theValue.charAt(0) == '\t'))
    theValue = theValue.substring(1, theValue.length);
    while (theValue.length > 0 && (theValue.charAt(theValue.length - 1) == ' ' || theValue.charAt(theValue.length - 1) == '\t'))
    theValue = theValue.substring(0, theValue.length - 1);
    if (theValue == '') return true;
    else return false;
}

function submitonce(theform) {
    smf_formSubmitted = true;
}

function submitThisOnce(form) {
    if (navigator.userAgent.indexOf('AppleWebKit') != -1) return !smf_formSubmitted;
    if (typeof(form.form) != "undefined") form = form.form;
    for (var i = 0; i < form.length; i++)
    if (typeof(form[i]) != "undefined" && form[i].tagName.toLowerCase() == "textarea") form[i].readOnly = true;
    return !smf_formSubmitted;
}

function setInnerHTML(element, toValue) {
    if (typeof(element.innerHTML) != 'undefined') element.innerHTML = toValue;
    else {
        var range = document.createRange();
        range.selectNodeContents(element);
        range.deleteContents();
        element.appendChild(range.createContextualFragment(toValue));
    }
}

function setOuterHTML(element, toValue) {
    if (typeof(element.outerHTML) != 'undefined') element.outerHTML = toValue;
    else {
        var range = document.createRange();
        range.setStartBefore(element);
        element.parentNode.replaceChild(range.createContextualFragment(toValue), element);
    }
}

function getInnerHTML(element) {
    if (typeof(element.innerHTML) != 'undefined') return element.innerHTML;
    else {
        var returnStr = '';
        for (var i = 0; i < element.childNodes.length; i++)
        returnStr += getOuterHTML(element.childNodes[i]);
        return returnStr;
    }
}

function getOuterHTML(node) {
    if (typeof(node.outerHTML) != 'undefined') return node.outerHTML;
    var str = '';
    switch (node.nodeType) {
    case 1:
        str += '<' + node.nodeName;
        for (var i = 0; i < node.attributes.length; i++) {
            if (node.attributes[i].nodeValue != null) str += ' ' + node.attributes[i].nodeName + '="' + node.attributes[i].nodeValue + '"';
        }
        if (node.childNodes.length == 0 && in_array(node.nodeName.toLowerCase(), ['hr', 'input', 'img', 'link', 'meta', 'br'])) str += ' />';
        else str += '>' + getInnerHTML(node) + '</' + node.nodeName + '>';
        break;
    case 3:
        str += node.nodeValue;
        break;
    case 4:
        str += '<![CDATA' + '[' + node.nodeValue + ']' + ']>';
        break;
    case 5:
        str += '&' + node.nodeName + ';';
        break;
    case 8:
        str += '<!--' + node.nodeValue + '-->';
        break;
    }
    return str;
}

function in_array(variable, theArray) {
    for (var i = 0; i < theArray.length; i++) {
        if (theArray[i] == variable) return true;
    }
    return false;
}

function selectRadioByName(radioGroup, name) {
    if (typeof(radioGroup.length) == "undefined") return radioGroup.checked = true;
    for (var i = 0; i < radioGroup.length; i++) {
        if (radioGroup[i].value == name) return radioGroup[i].checked = true;
    }
    return false;
}

function invertAll(headerfield, checkform, mask) {
    for (var i = 0; i < checkform.length; i++) {
        if (typeof(checkform[i].name) == "undefined" || (typeof(mask) != "undefined" && checkform[i].name.substr(0, mask.length) != mask)) continue;
        if (!checkform[i].disabled) checkform[i].checked = headerfield.checked;
    }
}
var lastKeepAliveCheck = new Date().getTime();

function smf_sessionKeepAlive() {
    var curTime = new Date().getTime();
    if (smf_scripturl && curTime - lastKeepAliveCheck > 900000) {
        var tempImage = new Image();
        tempImage.src = smf_scripturl + (smf_scripturl.indexOf("?") == -1 ? "?" : "&") + "action=keepalive;" + curTime;
        lastKeepAliveCheck = curTime;
    }
    window.setTimeout("smf_sessionKeepAlive();", 1200000);
}
window.setTimeout("smf_sessionKeepAlive();", 1200000);

function smf_setThemeOption(option, value, theme, cur_session_id) {
    if (cur_session_id == null) cur_session_id = smf_session_id;
    var tempImage = new Image();
    tempImage.src = smf_scripturl + (smf_scripturl.indexOf("?") == -1 ? "?" : "&") + "action=jsoption;var=" + option + ";val=" + value + ";sesc=" + cur_session_id + (theme == null ? "" : "&id=" + theme) + ";" + (new Date().getTime());
}

function smf_avatarResize() {
    var possibleAvatars = document.getElementsByTagName ? document.getElementsByTagName("img") : document.all.tags("img");
    for (var i = 0; i < possibleAvatars.length; i++) {
        if (possibleAvatars[i].className != "avatar") continue;
        var tempAvatar = new Image();
        tempAvatar.src = possibleAvatars[i].src;
        if (smf_avatarMaxWidth != 0 && tempAvatar.width > smf_avatarMaxWidth) {
            possibleAvatars[i].height = (smf_avatarMaxWidth * tempAvatar.height) / tempAvatar.width;
            possibleAvatars[i].width = smf_avatarMaxWidth;
        }
        else if (smf_avatarMaxHeight != 0 && tempAvatar.height > smf_avatarMaxHeight) {
            possibleAvatars[i].width = (smf_avatarMaxHeight * tempAvatar.width) / tempAvatar.height;
            possibleAvatars[i].height = smf_avatarMaxHeight;
        }
        else {
            possibleAvatars[i].width = tempAvatar.width;
            possibleAvatars[i].height = tempAvatar.height;
        }
    }
    if (typeof(window_oldAvatarOnload) != "undefined" && window_oldAvatarOnload) {
        window_oldAvatarOnload();
        window_oldAvatarOnload = null;
    }
}

function hashLoginPassword(doForm, cur_session_id) {
    if (cur_session_id == null) cur_session_id = smf_session_id;
    if (typeof(hex_sha1) == "undefined") return;
    if (doForm.user.value.indexOf("@") != -1) return;
    if (typeof(window.opera) == "undefined") doForm.passwrd.autocomplete = "off";
    doForm.hash_passwrd.value = hex_sha1(hex_sha1(doForm.user.value.php_to8bit().php_strtolower() + doForm.passwrd.value.php_to8bit()) + cur_session_id);
    if (navigator.userAgent.indexOf("Firefox/") != -1) doForm.passwrd.value = "";
    else doForm.passwrd.value = doForm.passwrd.value.replace(/./g, "*");
}

function hashAdminPassword(doForm, username, cur_session_id) {
    if (cur_session_id == null) cur_session_id = smf_session_id;
    if (typeof(hex_sha1) == "undefined") return;
    doForm.admin_hash_pass.value = hex_sha1(hex_sha1(username.toLowerCase() + doForm.admin_pass.value) + cur_session_id);
    doForm.admin_pass.value = doForm.admin_pass.value.replace(/./g, "*");
}

function ajax_indicator(turn_on) {
    var indicator = document.getElementById("ajax_in_progress");
    if (indicator != null) {
        if (navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf("MSIE 7") == -1) {
            indicator.style.top = document.documentElement.scrollTop;
        }
        indicator.style.display = turn_on ? "block" : "none";
    }
}

function buyPlayerDownloadPage(code, id, id1) {
	var ppBtn_id = new Array(6);
	ppBtn_id[1] = new Array('ZJGT5PAVB2GW8', '89Z4L7BQZ9XYY', 'DRBPT5ULQNFDN');
	ppBtn_id[2] = new Array('MV4Y8W377V3QQ', 'A9T6L8GSDPW4Q', 'H6Z6AJRPGT9CN');
	ppBtn_id[3] = new Array('39PY5AF8AV6VA', 'WQ6FTZZYEMZ6A', '34YX32NZ7JG6A');
	ppBtn_id[4] = new Array('9262B6VYAECNG', 'FTQVBEX73G6BY', 'G2JQ82WBB4WHG');
	ppBtn_id[5] = new Array('UCQHWE8THJHC8', '44BNTAN9LFC5N', 'WYK6QHT54RX7J');
	document.getElementById('license_id').value = ppBtn_id[id][id1];
	document.getElementById('custom_id').value = code;
	document.getElementById('paypalForum').submit();
}
