﻿function viewFlash(url, id, width, height) {

    var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
    var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
    var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
    var isFF = (navigator.userAgent.indexOf("Firefox") != -1) ? true : false;
    var str = "";

    if (isIE && isWin && !isOpera) {

        var obj = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="' + width + '" height="' + height + '" id="' + id + '" align="middle">';
        obj += '<param name="allowScriptAccess" value="always">';  // "always"; "always";
        obj += '<param name="quality" value="high">';
        obj += '<param name="src" value="' + url + '">';
        obj += '<param name="wmode" value="transparent">';
        //obj += '<param name="flashvars" value="' + str + '">';
        //obj += '<param name="allowFullScreen" value="' + allowfullscreen + '">';
        obj += '</object>';
    } else {
        obj = '<embed src="' + url + '" quality="high"  width="' + width + '" height="' + height + '" name="' + id + '" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent">';
    }
    document.write(obj);
}

function printScreenInfo() {
    var screeninfo = document.getElementById('screeninfo');
    screeninfo.innerHTML = "screen.width : " + screen.width;
    screeninfo.innerHTML += "<br />screen.height : " + screen.height;
    screeninfo.innerHTML += "<br />screen.availWidth : " + screen.availWidth;
    screeninfo.innerHTML += "<br />screen.availHeight : " + screen.availHeight;
    screeninfo.innerHTML += "<br />document.body.scrollWidth : " + document.body.scrollWidth;
    screeninfo.innerHTML += "<br />document.body.scrollHeight : " + document.body.scrollHeight;
    screeninfo.innerHTML += "<br />document.body.offsetWidth : " + document.body.offsetWidth;
    screeninfo.innerHTML += "<br />document.body.offsetHeight : " + document.body.offsetHeight;
    screeninfo.innerHTML += "<br />document.body.clientWidth : " + document.body.clientWidth;
    screeninfo.innerHTML += "<br />document.body.clientHeight : " + document.body.clientHeight;
}

function moveBanner(target, position, topLimit, btmLimit) {
    if (!target)
        return false;

    var obj = target;
    obj.initTop = position;
    obj.topLimit = topLimit;
    obj.bottomLimit = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight) - btmLimit - obj.offsetHeight;

    obj.style.position = "absolute";
    obj.top = obj.initTop;
    obj.left = (document.body.scrollLeft + (document.body.clientWidth / 2) - obj.offsetWidth / 2) + 500;
    
    if (typeof (window.pageYOffset) == "number") {	
        obj.getTop = function() {
            return window.pageYOffset;
        }
    } else if (typeof (document.documentElement.scrollTop) == "number") {
        obj.getTop = function() {
            return Math.max(document.documentElement.scrollTop, document.body.scrollTop);
        }
    } else {
        obj.getTop = function() {
            return 0;
        }
    }

    if (self.innerHeight) {
        obj.getHeight = function() {
            return self.innerHeight;
        }
    } else if (document.documentElement.clientHeight) {
        obj.getHeight = function() {
            return document.documentElement.clientHeight;
        }
    } else {
        obj.getHeight = function() {
            return 500;
        }
    }

    obj.move = setInterval(function() {
        if (obj.initTop > 0) {
            pos = obj.getTop() + obj.initTop;
        } else {
            pos = obj.getTop() + obj.getHeight() + obj.initTop;
            //pos = obj.getTop() + obj.getHeight() / 2 - 15;
        }

        if (pos > obj.bottomLimit)
            pos = obj.bottomLimit;
        if (pos < obj.topLimit)
            pos = obj.topLimit;

        interval = obj.top - pos;
        obj.top = obj.top - interval / 3;
        obj.left = (document.body.scrollLeft + (document.body.clientWidth / 2) - obj.offsetWidth / 2) + 500;
        //obj.style.top = document.body.scrollTop + (document.body.clientHeight / 2) - obj.offsetHeight / 2;
        obj.style.top = obj.top + "px";
        obj.style.left = obj.left + "px";
    }, 30)
}

function viewAgreement() {
    var agmtWidth = 698;
    var pop = document.getElementById('useragmt');
    var scrl = document.getElementById('agmtCt');
    var clientHeight = document.body.clientHeight;
    var clientWidth = document.body.clientWidth;
    if (pop.style.display == 'none') {
        scrollTo(0, 0);
        pop.style.left = ((clientWidth / 2) - (agmtWidth / 2)) + 'px';
        pop.style.top = 100 + 'px';
        pop.style.width = agmtWidth + 'px';
        pop.style.height = clientHeight - 364 + 'px';
        scrl.style.height = clientHeight - 431 + 'px';
        pop.style.display = 'block';
    }
    else {
        pop.style.display = 'none';
        //scrollTo(0, document.body.clientHeight);
    }
}

function marketNotice() {
    alert('Cydle Market for M7 (with Android™ OS) is under construction.  ');
}

function plzLogin() {
    alert('Please, Log in. ');
}

function notice() {
    var objPop = window.open('popNotice.htm', 'Notice', 'width=400, height=350, menubar=no, toolbar=no, location=no, status=no, scrollbars=no')

}

function notice2() {
    var objPop = window.open('popNotice2.htm', 'Notice', 'width=420, height=500, menubar=no, toolbar=no, location=no, status=no, scrollbars=no')

}

function popNoticeClose(val) {
    var layer = document.getElementById("popLayer" + val);
    layer.style.display = 'none';
}
