var alertm = 0
var mainurl = "http://www.hotnot.lt";
function ShowDialog(text) {

    if (alertm == 0) {
        alertm = 1;

        if (text != "Prašome prisijungti prie sistemos su savo prisijungimo vardu ir slaptažodžiu.") {
            // create a new <div>
            div = document.createElement('div');
            div.className = 'maindialog';
            div.name = 'mdid';

            document.body.appendChild(div);

            closediv = document.createElement("input");
            closediv.type = "button";
            closediv.className = "closedialogbtn";
            closediv.value = "";
            closediv.onclick = function () {
                document.body.removeChild(div);
                alertm = 0;
            };

            div.appendChild(closediv);

            subdiv = document.createElement('div');
            subdiv.className = 'subdialog';

            var html = text;
            subdiv.innerHTML = html;

            div.appendChild(subdiv);


        } else {
            // create a new <div>
            div = document.createElement('div');
            div.id = 'mainlogreg';
            div.name = 'mdid';

            document.body.appendChild(div);

            subdiv = document.createElement('div');
            subdiv.id = 'warpersubmainlogreg';

            subsubdiv = document.createElement('div');
            subsubdiv.id = 'submainlogreg';

            subdiv.appendChild(subsubdiv);

            div.appendChild(subdiv);
            closediv = document.createElement("input");
            closediv.type = "button";
            closediv.id = "closelr";
            closediv.value = "";
            closediv.onclick = function () {
                document.body.removeChild(div);
                alertm = 0;
            };

            var ajaxRequest; // The variable that makes Ajax possible!

            try {
                // Opera 8.0+, Firefox, Safari
                ajaxRequest = new XMLHttpRequest();
            } catch(e) {
                // Internet Explorer Browsers
                try {
                    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } catch(e) {
                    try {
                        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch(e) {
                        // Something went wrong
                        alert("Įvyko naršyklės klaida!");
                        return false;
                    }
                }
            }
            // Create a function that will receive data sent from the server
            ajaxRequest.onreadystatechange = function () {
                if (ajaxRequest.readyState == 4) {
                    var ajaxDisplay = subsubdiv;
                    ajaxDisplay.innerHTML = ajaxRequest.responseText;
                    subsubdiv.appendChild(closediv);
                }
            }
            ajaxRequest.open("GET", "http://www.hotnot.lt/reglogin.php", true);
            ajaxRequest.send(null);
            window.scrollBy(0,1);

        }

    }
}


function BlackScreen(page) {

    if (alertm == 0) {
        alertm = 1;


            // create a new <div>
            div = document.createElement('div');
            div.id = 'mainlogreg';
            div.name = 'mdid';

            document.body.appendChild(div);

            subdiv = document.createElement('div');
            subdiv.id = 'warpersubmainlogreg';

            subsubdiv = document.createElement('div');
            subsubdiv.id = 'submainlogscr';

            subdiv.appendChild(subsubdiv);

            div.appendChild(subdiv);
            closediv = document.createElement("input");
            closediv.type = "button";


							closediv.id = "closelrscr";


						closediv.value = "";
            closediv.onclick = function () {
                document.body.removeChild(div);
                alertm = 0;
            };

            var ajaxRequest; // The variable that makes Ajax possible!

            try {
                // Opera 8.0+, Firefox, Safari
                ajaxRequest = new XMLHttpRequest();
            } catch(e) {
                // Internet Explorer Browsers
                try {
                    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } catch(e) {
                    try {
                        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch(e) {
                        // Something went wrong
                        alert("Įvyko naršyklės klaida!");
                        return false;
                    }
                }
            }
            // Create a function that will receive data sent from the server
            ajaxRequest.onreadystatechange = function () {
                if (ajaxRequest.readyState == 4) {
                    var ajaxDisplay = subsubdiv;
                    ajaxDisplay.innerHTML = ajaxRequest.responseText;
                    subsubdiv.appendChild(closediv);
                }
            }
            ajaxRequest.open("GET", mainurl + "/" + page, true);
            ajaxRequest.send(null);



    }
}

function go_down() {
    window.scrollBy(0,1)
}

function HoroLoad(page, id) {

    if (alertm == 0) {
        alertm = 1;


            // create a new <div>
            div = document.createElement('div');
            div.id = 'mainlogreg';
            div.name = 'mdid';

            document.body.appendChild(div);

            subdiv = document.createElement('div');
            subdiv.id = 'warpersubmainlogreg';

            subsubdiv = document.createElement('div');
            subsubdiv.id = 'submainlogscr';

            subdiv.appendChild(subsubdiv);

            div.appendChild(subdiv);
            closediv = document.createElement("input");
            closediv.type = "button";

							closediv.id = "closelr";


						closediv.value = "";
            closediv.onclick = function () {
                document.body.removeChild(div);
                alertm = 0;
            };

            var ajaxRequest; // The variable that makes Ajax possible!

            try {
                // Opera 8.0+, Firefox, Safari
                ajaxRequest = new XMLHttpRequest();
            } catch(e) {
                // Internet Explorer Browsers
                try {
                    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } catch(e) {
                    try {
                        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch(e) {
                        // Something went wrong
                        alert("Įvyko naršyklės klaida!");
                        return false;
                    }
                }
            }
            // Create a function that will receive data sent from the server
            ajaxRequest.onreadystatechange = function () {
                if (ajaxRequest.readyState == 4) {
                    var ajaxDisplay = subsubdiv;
                    ajaxDisplay.innerHTML = ajaxRequest.responseText;
                    subsubdiv.appendChild(closediv);
                }
            }
            ajaxRequest.open("GET", mainurl + "/" + page, true);
            ajaxRequest.send(null);
            setTimeout('go_down()', 500);
            ajax_multi('http://www.hotnot.lt/horoscope_ajax.php?horo='+id, 'horo_body', '6');
             setTimeout('go_down()', 4000);



    }
}

function HoroLoad2(page, id){

	ajax_multi('http://www.hotnot.lt/'+page, 'jquery_div', '5');
	document.getElementById('activate_jquery_id').click();
	BallLoaded(id);

}

function BallLoaded(id){

	function HoroAgain(){
		ajax_multi('http://www.hotnot.lt/horoscope_ajax.php?horo='+id, 'horo_body', '6');
	}
	var img = new Image();
	img.onload = function() {
	  setTimeout(HoroAgain, 1500);
	}
	img.src = 'http://www.hotnot.lt/img/loading_ball.gif';

}

function horo2image(imgSrc){


	var imgId = document.getElementById('horoPhoto');
	//imgId.style.display='none';
	document.getElementById('horoPhotoDiv').style.display='none'
	document.getElementById('horoscope_main').style.display='none';
	document.getElementById('loadBallDiv').style.display='';

	var limHeight = 250;
	var limWidth = 650;
	var curHeight;
	var curWidth;
	var newHeight;
	var newWidth;
	var newImg = new Image();
	newImg.onload = function() {
		curHeight = newImg.height;
		curWidth = newImg.width;
		if(curHeight <= limHeight && curWidth <= limWidth){
			newHeight = curHeight;
			newWidth = curWidth;
		}else if((curWidth / curHeight) >= (limWidth / limHeight)){
			newWidth = limWidth;
			newHeight = Math.round(curHeight * newWidth / curWidth);
		}else{
			newHeight = limHeight;
			newWidth = Math.round(newHeight * curWidth / curHeight);
		}

		imgId.width = newWidth;
		imgId.height = newHeight;
		imgId.src = imgSrc;
		document.getElementById('loadBallDiv').style.display='none';
		document.getElementById('horoPhotoDiv').style.display='';
		//imgId.style.display='';
	}
	newImg.src = imgSrc;
}

function UploadMusic() {

    if (alertm == 0) {
        alertm = 1;


            // create a new <div>
            div = document.createElement('div');
            div.id = 'mainlogreg';
            div.name = 'mdid';

            document.body.appendChild(div);

            subdiv = document.createElement('div');
            subdiv.id = 'warpersubmainlogreg';

            subsubdiv = document.createElement('div');
            subsubdiv.id = 'submainlogscr';

            subdiv.appendChild(subsubdiv);

            div.appendChild(subdiv);
            closediv = document.createElement("input");
            closediv.type = "button";
            closediv.id = "closelr";
            closediv.value = "";
            closediv.onclick = function () {
                document.body.removeChild(div);
                alertm = 0;
            };

            var ajaxRequest; // The variable that makes Ajax possible!

            try {
                // Opera 8.0+, Firefox, Safari
                ajaxRequest = new XMLHttpRequest();
            } catch(e) {
                // Internet Explorer Browsers
                try {
                    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } catch(e) {
                    try {
                        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch(e) {
                        // Something went wrong
                        alert("Įvyko naršyklės klaida!");
                        return false;
                    }
                }
            }
            // Create a function that will receive data sent from the server
            ajaxRequest.onreadystatechange = function () {
                if (ajaxRequest.readyState == 4) {
                    var ajaxDisplay = subsubdiv;
                    ajaxDisplay.innerHTML = ajaxRequest.responseText;
                    subsubdiv.appendChild(closediv);
                }
            }
            ajaxRequest.open("GET", mainurl + "/uploadmusic.php", true);
            ajaxRequest.send(null);



    }
}

function LoginAlert(page) {

    if (alertm == 0) {
        alertm = 1;

            // create a new <div>
            div = document.createElement('div');
            div.id = 'mainlogreg';
            div.name = 'mdid';

            document.body.appendChild(div);

            subdiv = document.createElement('div');
            subdiv.id = 'warpersubmainlogreg';

            subsubdiv = document.createElement('div');
            subsubdiv.id = 'submainlogreg';

            subdiv.appendChild(subsubdiv);

            div.appendChild(subdiv);
            closediv = document.createElement("input");
            closediv.type = "button";
            closediv.id = "closelr";
            closediv.value = "";
            closediv.onclick = function () {
                document.body.removeChild(div);
                alertm = 0;
            };

            var ajaxRequest; // The variable that makes Ajax possible!

            try {
                // Opera 8.0+, Firefox, Safari
                ajaxRequest = new XMLHttpRequest();
            } catch(e) {
                // Internet Explorer Browsers
                try {
                    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } catch(e) {
                    try {
                        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch(e) {
                        // Something went wrong
                        alert("Įvyko naršyklės klaida!");
                        return false;
                    }
                }
            }
            // Create a function that will receive data sent from the server
            ajaxRequest.onreadystatechange = function () {
                if (ajaxRequest.readyState == 4) {
                    var ajaxDisplay = subsubdiv;
                    ajaxDisplay.innerHTML = ajaxRequest.responseText;
                    subsubdiv.appendChild(closediv);
                }
            }
            ajaxRequest.open("GET", "http://www.hotnot.lt/" + page, true);
            ajaxRequest.send(null);
            window.scrollBy(0,1);

    }
}
