var web_req;
var search_in = new Array();
search_in[1] = Array(["Title",1],["Genre",2]); //Movie
search_in[2] = Array(["Name",1]); //Actor & Director
search_in[3] = Array(["Title",1]); //Poster
search_in[4] = Array(["Subject",1]); //News
search_in[5] = Array(["Subject",1]); //Article
search_in[6] = Array(["Title",1]); //Galery
search_in[7] = Array(["Title",1]); //Link

function Inint_AJAX()
{
    try { return new ActiveXObject("Msxml2.XMLHTTP");} catch(e) {} //IE
    try { return new ActiveXObject("Microsoft.XMLHTTP");} catch(e) {} //IE
    try { return new XMLHttpRequest();} catch(e) {} //Native Javascript
    alert("XMLHttpRequest not supported");
    return null;
}

function setfocus(object,combo)
{
    document.getElementById(object).focus();
    if(combo == false)
        document.getElementById(object).select()
}

function trim(obj_value)
{
    if(obj_value.length > 0)
    {
        i = 0;
	for(;;)
	{	
            ch = obj_value.substring(i,i+1);
            if((i == obj_value.length) || (ch != " "))
                break;
            else
                i++;
	}
	if((i != 0) && (i != obj_value.length))
	{
            obj_value = obj_value.substring(i,obj_value.length);
	}
        else
            {
                if(i == obj_value.length)
                    obj_value = "";
            }
		
	if(obj_value.length > 0)		
	{
            i = obj_value.length;
            for(;;)
            {
                ch = obj_value.substring(i-1,i);
		if((i == 0) || (ch != " "))
                    break;
		else
                    i--;
            }
            if(i != obj_value.length)
            {
                obj_value = obj_value.substring(0,i);
            }
	}					
    }
    return obj_value;
}

function textToEntities(text)
{
    var entities = "";
    for (var i = 0; i < text.length; i++)
    {
        if (text.charAt(i) == "&"){	entities += "%26"; }
        else
            {
                if (text.charAt(i) == "+"){	entities += "%2b"; }
		else
                    entities += text.charAt(i);
            }
    }

    return entities;
}

function iif(condition,result_true,result_false)
{
    if(condition){result = result_true}else{result = result_false};
    return result;
}

function IsNumeric(strString)
//check for valid numeric strings	
{
    var strValidChars = "0123456789.-";
    var strChar;
    var blnResult = true;
	
    if (strString.length == 0) return false;

    //  test strString consists of valid characters listed above
    for (i = 0; i < strString.length && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
      	if (strValidChars.indexOf(strChar) == -1)
	{
            blnResult = false;
    	}
    }
    return blnResult;
}

function emailCheck (emailStr) 
{
/*  The following pattern is used to check if the entered e-mail address
    fits the user@domain format.  It also is used to separate the username
    from the domain. */
    var emailPat = /^(.+)@(.+)$/;
/*  The following string represents the pattern for matching all special
    characters.  We don't want to allow special characters in the address.
    These characters include ( ) < > @ , ; : \ " . [ ]    */
    var specialChars = "\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
/*  The following string represents the range of characters allowed in a
    username or domainname.  It really states which chars aren't allowed. */
    var validChars = "\[^\\s" + specialChars + "\]";
/*  The following pattern applies if the "user" is a quoted string (in
    which case, there are no rules about which characters are allowed
    and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
    is a legal e-mail address. */
    var quotedUser = "(\"[^\"]*\")";
/*  The following pattern applies for domains that are IP addresses,
    rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
    e-mail address. NOTE: The square brackets are required. */
    var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
/*  The following string represents an atom (basically a series of
    non-special characters.) */
    var atom = validChars + '+';
/*  The following string represents one word in the typical username.
    For example, in john.doe@somewhere.com, john and doe are words.
    Basically, a word is either an atom or quoted string. */
    var word = "(" + atom + "|" + quotedUser + ")";
//  The following pattern describes the structure of the user
    var userPat = new RegExp("^" + word + "(\\." + word + ")*$");
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
    var domainPat = new RegExp("^" + atom + "(\\." + atom +")*$");


/*  Finally, let's start trying to figure out if the supplied address is
    valid. */

/*  Begin with the coarse pattern to simply break up user@domain into
    different pieces that are easy to analyze. */
    var matchArray = emailStr.match(emailPat);
    if (matchArray == null)
    {
/*  Too many/few @'s or something; basically, this address doesn't
    even fit the general mould of a valid e-mail address. */
//  alert("Email address seems incorrect (check @ and .'s)");
        return false;
    }

    var user = matchArray[1];
    var domain = matchArray[2];

//  See if "user" is valid
    if (user.match(userPat) == null)
    {
//  user is not valid
//  alert("The username doesn't seem to be valid.");
        return false;
    }

/*  if the e-mail address is at an IP address (as opposed to a symbolic
    host name) make sure the IP address is valid. */
    var IPArray = domain.match(ipDomainPat);
    if (IPArray!=null)
    {
//  this is an IP address
        for (var i=1;i<=4;i++)
        {
            if (IPArray[i]>255)
            {
//  alert("Destination IP address is invalid!");
                return false;
            }
        }
        return true;
    }

//  Domain is symbolic name
    var domainArray = domain.match(domainPat);
    if (domainArray == null)
    {
//  alert("The domain name doesn't seem to be valid.");
      return false;
    }

/*  domain name seems valid, but now make sure that it ends in a
    three-letter word (like com, edu, gov) or a two-letter word,
    representing country (uk, nl), and that there's a hostname preceding
    the domain or country. */

/*  Now we need to break up the domain to get a count of how many atoms
    it consists of. */
    var atomPat = new RegExp(atom,"g");
    var domArr = domain.match(atomPat);
    var len = domArr.length;
    if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3)
    {
//  the address must end in a two letter or three letter word.
//  alert("The address must end in a three-letter domain, or two letter country.");
        return false;
    }

//  Make sure there's a host name preceding the domain.
    if (len < 2)
    {
//  var errStr="This address is missing a hostname!";
//  alert(errStr);
        return false
    }

// If we've gotten this far, everything's valid!
    return true;
}

function daysInFebruary (year)
{
    //February has 29 days in any year evenly divisible by four,
    //EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n) 
{
    for (var i = 1;i <= n;i++)
    {
        this[i] = 31;
	if (i == 4 || i == 6 || i == 9 || i == 11) { this[i] = 30; }
	if (i == 2) { this[i] = 29; }
    }
   return this;
}

function isDate(day,month,year)
{
    var daysInMonth = DaysArray(12);
    var date = day + "-" + month + "-" + year;

    if (date != "00-00-0000")
    {
        if (day == "00") return false;
    	if (month == "00") return false;
	if (year == "0000") return false;
	if (((parseInt(month) == 2) && (day > daysInFebruary(year))) || (day > daysInMonth[parseInt(month)]))
	{
            return false;
	}
    }
    return true;
}

function key_numeric(obj,keycode) 
{
    if (keycode > 31 && (keycode < 48 || keycode > 57)) { return false; }
    return;
}

function frm_reset(frm,msg,display,obj)
{
    if (msg == true)
    {
        if (display == false) { if (document.getElementById(obj).style.display  != "none") document.getElementById(obj).style.display  = "none"; }
	if (display == true) { document.getElementById(obj).innerHTML = ""; }
    }
    document.all[frm].reset();
}

function show_content()
{
    document.getElementById("loading").style.display = "none";
    document.getElementById("content").style.display = "";
}

function bbc_highlight(img,mode)
{
    document.all[img].style.backgroundImage = "url(Image/Bbc/" + (mode ? "/Bbc_Hoverbg.gif" : "/Bbc_Bg.gif") + ")";
}

function storeCaret(text)
{
    //Only bother if it will be useful.
    if (typeof(text.createTextRange) != "undefined")
        text.caretPos = document.selection.createRange().duplicate();
} 

function replace_text(text,textarea)
{
    //Attempt to create a text range (IE).
    if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange)
    {
        var caretPos = textarea.caretPos;

	caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
	caretPos.select();
    }
    //Mozilla text range replace.
    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;
            }
            //Just put it on the end.
            else
		{
                    textarea.value += text;
                    textarea.focus(textarea.value.length - 1);
		}
        }
}

function surround_text(text1,text2,textarea)
{
    //Can a text range be created?
    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);
    }
    //Mozilla text range wrap.
    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;
            }
            //Just put them on the end, then.
            else
                {
                    textarea.value += text1 + text2;
                    textarea.focus(textarea.value.length - 1);
		}
        }
}

function load_logo()
{
    var num;
	
    for(;;)
    {
        num = Math.floor(Math.random()*10);
	if(num != 0) break;
    }
    document.getElementById("logo").src = "Image/Logo" + num + ".gif";
}

function load_banner()
{
    var num;

    for(;;)
    {
        num = Math.floor(Math.random()*7);
	if(num != 0) break;
    }
    document.getElementById("banner").src = "Image/Banner" + num + ".gif";
}

function load_stats()
{
    var url = "Stats.php";
	
    if (web_req == null){web_req = Inint_AJAX();}
    web_req.abort();

    web_req.open("GET", url, true);
    web_req.onreadystatechange = function(){
        if (web_req.readyState == 4)
	{
            if (web_req.status == 200)
            {
                var data = web_req.responseText;

		document.getElementById("stats").innerHTML = data;
            }
	}
    };
    web_req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
    web_req.send(null);
}

function load_avatar()
{
    var avatar = document.all["avatar"].value

    document.getElementById("view_avatar").src = "Image/Avatar/" + avatar;
}

function login()
{
    document.all["signin_username"].value = trim(document.all["signin_username"].value);
    document.all["signin_password"].value = trim(document.all["signin_password"].value);

    var username = textToEntities(document.all["signin_username"].value);
    var password = textToEntities(document.all["signin_password"].value);
    var signin = document.all["signin"].value;
    var url = "Signin.php";
	
    if (web_req == null){web_req = Inint_AJAX();}
    web_req.abort();

    web_req.open("POST", url, true);
    web_req.onreadystatechange = function(){
        if (web_req.readyState == 4)
	{
            if (web_req.status == 200)
            {
                var data = web_req.responseText.split("#");

		switch (data[1])
		{
                    case "1"    : {
                                    document.getElementById("msg_signin").innerHTML= "Username or password incorrect";break;
                                  }
                    default     : { top.location.reload();break; }
		}
            }
	}
    };
    web_req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
    web_req.send("username=" + username + "&password=" + password + "&signin=" + signin);
}

function logout()
{
    var url = "Signout.php";
	
    if (web_req == null){web_req = Inint_AJAX();}
    web_req.abort();

    web_req.open("GET", url, true);
    web_req.onreadystatechange = function(){
        if (web_req.readyState == 4)
        {
            if (web_req.status == 200)
            {
                top.location.reload()
            }
	}
    };
    web_req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
    web_req.send(null);
}

function load_poster()
{
    var url = "Poster/Poster.php";
	
    if (web_req == null){web_req = Inint_AJAX();}
    web_req.abort();

    web_req.open("GET", url, true);
    web_req.onreadystatechange = function(){
        if (web_req.readyState == 4)
	{
            document.getElementById("poster").innerHTML= "<table width='100%' height='100%' border='0' cellpadding='0' cellspacing='0'><tr><td nowrap align='center'><img src='Image/Loading.gif' border='0'></td></tr></table>";
            if (web_req.status == 200)
            {
                var data = web_req.responseText;
				
		document.getElementById("poster").innerHTML= data;
            }
	}
    };
    web_req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
    web_req.send(null);
}

function load_advertise()
{
    var randomnumber = Math.floor(Math.random()*4);
	
    switch (randomnumber)
    {
        case 0  : {
                    if (typeof(gnm_ord)=='undefined') gnm_ord=Math.random()*10000000000000000; if (typeof(gnm_tile) == 'undefined') gnm_tile=1;
                    document.write('<scr'+'ipt language="JavaScript" src="http://n4403ad.doubleclick.net/adj/gn.horror-movies.ca/home;sect=home;sz=160x600;tile='+(gnm_tile++)+';ord=' + gnm_ord + '?" type="text/javascript"></scr' + 'ipt>');
                    break;
		  }
	case 1  : {
                    if (typeof(gnm_ord)=='undefined') gnm_ord=Math.random()*10000000000000000; if (typeof(gnm_tile) == 'undefined') gnm_tile=1;
                    document.write('<scr'+'ipt language="JavaScript" src="http://n4403ad.doubleclick.net/adj/gn.houseofhorrors.com/home;sect=home;sz=160x600,120x600;tile='+(gnm_tile++)+';ord=' + gnm_ord + '?" type="text/javascript"></scr' + 'ipt>');
                    break;
                  }
	case 2  : {
                    if (typeof(gnm_ord)=='undefined') gnm_ord=Math.random()*10000000000000000; if (typeof(gnm_tile) == 'undefined') gnm_tile=1;
                    document.write('<scr'+'ipt language="JavaScript" src="http://n4403ad.doubleclick.net/adj/gn.cr.satanspace.com/home;sect=home;sz=160x600,120x600;tile='+(gnm_tile++)+';ord=' + gnm_ord + '?" type="text/javascript"></scr' + 'ipt>');
                    break;
                  }
	case 3  : {
                    if (typeof(gnm_ord)=='undefined') gnm_ord=Math.random()*10000000000000000; if (typeof(gnm_tile) == 'undefined') gnm_tile=1;
                    document.write('<scr'+'ipt language="JavaScript" src="http://n4403ad.doubleclick.net/adj/gn.24framespersecond.net/home;sect=home;sz=160x600,120x600;tile='+(gnm_tile++)+';ord=' + gnm_ord + '?" type="text/javascript"></scr' + 'ipt>');
                    break;
		  }
    }
}

function load_advertise1()
{
    /*if (typeof(gnm_ord)=='undefined') gnm_ord=Math.random()*10000000000000000; if (typeof(gnm_tile) == 'undefined') gnm_tile=1;
    document.write('<scr'+'ipt language="JavaScript" src="http://n4403ad.doubleclick.net/adj/gn.fangoria.com/ros;sect=ros;sz=300x250,250x250;tile='+(gnm_tile++)+';ord=' + gnm_ord + '?" type="text/javascript"></scr' + 'ipt>');*/

    var randomnumber = Math.floor(Math.random()*3);
	
    switch (randomnumber)
    {
        case 0  : {
                    if (typeof(gnm_ord)=='undefined') gnm_ord=Math.random()*10000000000000000; if (typeof(gnm_tile) == 'undefined') gnm_tile=1;
                    document.write('<scr'+'ipt language="JavaScript" src="http://n4403ad.doubleclick.net/adj/gn.cr.dreadcentral.com/home;sect=home;sz=300x250;tile='+(gnm_tile++)+';ord=' + gnm_ord + '?" type="text/javascript"></scr' + 'ipt>');
                    break;
                  }
        case 1  : {
                    if (typeof(gnm_ord)=='undefined') gnm_ord=Math.random()*10000000000000000; if (typeof(gnm_tile) == 'undefined') gnm_tile=1;
                    document.write('<scr'+'ipt language="JavaScript" src="http://n4403ad.doubleclick.net/adj/gn.horror-movies.ca/ros;sect=ros;sz=300x250,250x250;tile='+(gnm_tile++)+';ord=' + gnm_ord + '?" type="text/javascript"></scr' + 'ipt>');
                    break;
                  }
	case 2  : {
                    if (typeof(gnm_ord)=='undefined') gnm_ord=Math.random()*10000000000000000; if (typeof(gnm_tile) == 'undefined') gnm_tile=1;
                    document.write('<scr'+'ipt language="JavaScript" src="http://n4403ad.doubleclick.net/adj/gn.cr.shocktillyoudrop.com/home;sect=home;sz=300x250,250x250,300x600;tile='+(gnm_tile++)+';ord=' + gnm_ord + '?" type="text/javascript"><\/scr' + 'ipt>');
                    break;
		  }
    }
}

function select_to_list(obj_choose,obj_list)
{
    var choose = document.all[obj_choose].value;

    if (choose.length > 0)
    {
        var obj = document.all[obj_list];
	var i;

	if (obj.length > 0)
	{
            for(i = 0;i < obj.length;i++)
            {
		if (choose == obj.options[i].value) return;
            }
	}

        var opt = document.createElement("OPTION");
	obj.options.add(opt);
	opt.innerHTML = choose;
	opt.value = choose;
    }
}

function clear_list(obj,mode)
{
    var obj_combo = document.all[obj];
	
    if (mode == 1)
    {
        if (obj_combo.options.selectedIndex >= 0) obj_combo.options[obj_combo.options.selectedIndex] = null;
    }
	
    if (mode == 2)
    {
        for(i = obj_combo.length - 1;i >= 0;i--)
	{
            obj_combo.options[i] = null;
	}
    }
}

function delete_list(obj)
{
    var obj_combo = document.all[obj];

    if (obj_combo.options.selectedIndex >= 0) obj_combo.options[obj_combo.options.selectedIndex] = null;
}

function groupvalue_list(obj)
{
    var result = "";

    for (var i = 0;i < obj.length;i++)
    {
        if (result.length > 0) { result = result + ";" + obj.options[i].value; } else { result = obj.options[i].value; }
    }

    return result;
}

function copy_list(obj_source,obj_destination)
{
    clear_list(obj_destination,2);
	
    obj_combo = document.all[obj_source];
    for(i = 0;i < obj_combo.length;i++)
    {
        var tmp = obj_combo.options[i].value;
	var data = tmp.split(";")
	var obj = document.all[obj_destination];
	var opt = document.createElement("OPTION");
	obj.options.add(opt);
	opt.innerHTML = data[1];
	opt.value = data[0];
    }
}

function load_security_code()
{
    var url = "Securitycode.php";
	
    if (web_req == null){web_req = Inint_AJAX();}
    web_req.abort();

    web_req.open("GET", url, true);
    web_req.onreadystatechange = function(){
        if (web_req.readyState == 4)
	{
            if (web_req.status == 200)
            {
                var data = web_req.responseText;
				
		document.getElementById("capcha").innerHTML= data;
            }
	}
    };
    web_req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
    web_req.send(null);
}

function submit_search()
{
    var keyword = trim(document.all["keyword_search"].value);
    var choose_in = document.getElementById("choose_in").value;
    //var choose_by = document.all["choose_by"].value;
    var pid,args_search,by;
	
    switch (choose_in)
    {
        case "1" : { pid = "018";by = 1;break; } //Movies
	case "2" : { pid = "018";by = 2;break; } //Movies
	case "3" : { pid = "999";by = 1;break; } //Actors & Directors
	case "4" : { pid = "037";by = 1;break; } //Posters
	case "5" : { pid = "038";by = 1;break; } //Videos
	case "6" : { pid = "024";by = 1;break; } //News
	case "7" : { pid = "999";by = 1;break; } //Articles
	case "8" : { pid = "034";by = 1;break; } //Gallery
	case "9" : { pid = "016";by = 1;break; } //Links
    }
	
    if(keyword.length > 0) { args_search = "&keyword=" + keyword + "&by=" + by; }else{ args_search = ""; };
    top.location.href = "index.php?pid="+ pid + args_search;
}

function change_search_by()
{
    var i;
    var order = document.getElementById("choose_in").value;

    clear_list("choose_by",2);
    for(i = 0;i < search_in[order].length;i++)
    {
        document.getElementById("choose_by").options[i] = new Option(search_in[order][i][0]);
	document.getElementById("choose_by").options[i].value = search_in[order][i][1];
    }
}

function load_latest(order)
{
    var send_value = new Array();
    send_value[0] = "order=" + order;
    var url = "Load_Latest.php";

    if (web_req == null){web_req = Inint_AJAX();}
    web_req.abort();

    web_req.onreadystatechange = function(){
        if (web_req.readyState == 4)
	{
            document.all['load_process'].style.display = '';
            if (web_req.status == 200)
            {
                var data = web_req.responseText;
			
		document.getElementById("tab" + order + "_content").innerHTML= data;
		document.all['load_process'].style.display = 'none';
		document.all["tab" + order + "_content"].style.display = '';
            }
	}
    };
    web_req.open("POST", url, true);
    web_req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
    web_req.send(send_value.join("&"));
}

function load_content(order)
{
    switch (order)
    {
        case 1  : {
                    document.getElementById("tab1_active").style.display = '';document.getElementById("tab1_noactive").style.display = 'none';
                    document.getElementById("tab2_active").style.display = 'none';document.getElementById("tab2_noactive").style.display = '';
                    document.getElementById("tab3_active").style.display = 'none';document.getElementById("tab3_noactive").style.display = '';
                    document.getElementById("tab4_active").style.display = 'none';document.getElementById("tab4_noactive").style.display = '';
                    document.all['tab1_content'].style.display = 'none';
                    document.all['tab2_content'].style.display = 'none';
                    document.all['tab3_content'].style.display = 'none';
                    document.all['tab4_content'].style.display = 'none';
                    load_latest(1);
                    break;
                  }
	case 2  : {
                    document.getElementById("tab1_active").style.display = 'none';document.getElementById("tab1_noactive").style.display = '';
                    document.getElementById("tab2_active").style.display = '';document.getElementById("tab2_noactive").style.display = 'none';
                    document.getElementById("tab3_active").style.display = 'none';document.getElementById("tab3_noactive").style.display = '';
                    document.getElementById("tab4_active").style.display = 'none';document.getElementById("tab4_noactive").style.display = '';
                    document.all['tab1_content'].style.display = 'none';
                    document.all['tab2_content'].style.display = 'none';
                    document.all['tab3_content'].style.display = 'none';
                    document.all['tab4_content'].style.display = 'none';
                    load_latest(2);
                    break;
		  }
        case 3  : {
                    document.getElementById("tab1_active").style.display = 'none';document.getElementById("tab1_noactive").style.display = '';
                    document.getElementById("tab2_active").style.display = 'none';document.getElementById("tab2_noactive").style.display = '';
                    document.getElementById("tab3_active").style.display = '';document.getElementById("tab3_noactive").style.display = 'none';
                    document.getElementById("tab4_active").style.display = 'none';document.getElementById("tab4_noactive").style.display = '';
                    document.all['tab1_content'].style.display = 'none';
                    document.all['tab2_content'].style.display = 'none';
                    document.all['tab3_content'].style.display = 'none';
                    document.all['tab4_content'].style.display = 'none';
                    load_latest(3);
                    break;
		  }
        case 4  : {
                    document.getElementById("tab1_active").style.display = 'none';document.getElementById("tab1_noactive").style.display = '';
                    document.getElementById("tab2_active").style.display = 'none';document.getElementById("tab2_noactive").style.display = '';
                    document.getElementById("tab3_active").style.display = 'none';document.getElementById("tab3_noactive").style.display = '';
                    document.getElementById("tab4_active").style.display = '';document.getElementById("tab4_noactive").style.display = 'none';
                    document.all['tab1_content'].style.display = 'none';
                    document.all['tab2_content'].style.display = 'none';
                    document.all['tab3_content'].style.display = 'none';
                    document.all['tab4_content'].style.display = 'none';
                    load_latest(4);
                    break;
		  }
    }
}

function load_video(file,image,width,height,start,controlbar)
{
    var s1 = new SWFObject("Mediaplayer/player.swf","mpl",width,height,"9","#000000");
    s1.addParam("allowfullscreen","true");
    s1.addParam("allowscriptaccess","always");
    s1.addParam("flashvars","&file=" + file + "&image=" + image + "&autostart=" + start + "&controlbar=" + controlbar + "&stretching=exactfit&skin=http://www.mankind666.com/Mediaplayer/Skin/Modieus/modieus.swf");
    s1.write("mediaspace");    
}

function load_random(order)
{
    var send_value = new Array();
    send_value[0] = "order=" + order;
    var url = "Load_Random.php";

    if (web_req == null){web_req = Inint_AJAX();}
    web_req.abort();

    web_req.onreadystatechange = function(){
        if (web_req.readyState == 4)
	{
            if (web_req.status == 200)
            {
                var data = web_req.responseText;

		document.getElementById("random_" + order).innerHTML= data;
            }
	}
    };
    web_req.open("POST", url, true);
    web_req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
    web_req.send(send_value.join("&"));
}

function getPageSize()
{
    var xPage,yPage;

    if (self.innerHeight )
    {
        xPage = self.innerWidth;
    	yPage = self.innerHeight;
    }
    else
        {
            if (document.documentElement && document.documentElement.clientHeight )
            {
                xPage = document.documentElement.clientWidth;
		yPage = document.documentElement.clientHeight;
            }
            else
		{
                    if (document.body )
                    {
                        xPage = document.body.clientWidth;
    			yPage = document.body.clientHeight;
                    }
		}
	}

    return new Array(xPage,yPage);
}

function getPageScroll()
{
    var yScroll;

    if (self.pageYOffset)
    {
        yScroll = self.pageYOffset;
    }
    else
        {
            if (document.documentElement && document.documentElement.scrollTop)
            {
                // Explorer 6 Strict
                yScroll = document.documentElement.scrollTop;
            }
            else
                {
                    if (document.body)
                    {
                        // all other Explorers
                        yScroll = document.body.scrollTop;
                    }
                }
        }

	return new Array('',yScroll);
}

function show_popup(mode,order)
{
    var xyPage = getPageSize();
    var xyScroll = getPageScroll();
    document.getElementById("popup_" + mode).style.display = "";
    
    switch (mode)
    {
        case "image" : {
                        img = new Image();
                        img.src = order;
                        document.getElementById("show_image").style.left = ((xyPage[0] - 20 - img.width) / 2) + "px";
                        document.getElementById("show_image").style.top = xyScroll[1] + ((xyPage[1] - img.height) / 2) + "px";
                        document.getElementById("image").src = order;break;
                       }
    }
}

function close_popup(mode)
{
    document.getElementById("popup_" + mode).style.display = "none";
}