var windows_handlers = new Array();
var windows_name = new Array();
var windows_count=0;
			   

function popup_base(x,y,name,add_name)
    {
    var rnd = Math.random()+"_";
    var v_date = new Date();
    var s_date = v_date.getYear();
    s_date = s_date + "_" + v_date.getMonth();
    s_date = s_date + "_" + v_date.getDate();
    s_date = s_date + "_" + v_date.getHours();
    s_date = s_date + "_" + v_date.getMinutes();
    s_date = s_date + "_" + v_date.getSeconds();
    s_date = s_date + "_" + rnd.substring(2,8);
    var popupURL=name;
    if (add_name != "")
    {
	s_date = add_name;
	popupURL = "";
    };
    var popup = window.open(popupURL,s_date,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=' + x + ',height=' + y);
    windows_handlers[windows_count]=popup;
    windows_name[windows_count]=s_date;
    windows_count++;
//    alert(popupURL);
    };


function popup(x,y,name)
{
    popup_base(x,y,name,"");
};    

function video_hi(name)
{
    var popupURL='http://flv.m1.tv/player/dimA/'+name;
    window.open(popupURL, 'video', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=640,height=500');
//    popup_base(x,y,name,"");
 
}; 
function ask(url,question)
    {
    if (confirm(question)) 
	{
        popup(10,10,url)
	}
    };

function popups(x,y,name)
{
    popupscroll(x,y,name,"");
};  

function popupscroll(x,y,name,add_name)
    {
    var rnd = Math.random()+"_";
    var v_date = new Date();
    var s_date = v_date.getYear();
    s_date = s_date + "_" + v_date.getMonth();
    s_date = s_date + "_" + v_date.getDate();
    s_date = s_date + "_" + v_date.getHours();
    s_date = s_date + "_" + v_date.getMinutes();
    s_date = s_date + "_" + v_date.getSeconds();
    s_date = s_date + "_" + rnd.substring(2,8);
    var popupURL=name;
    if (add_name != "")
    {
	s_date = add_name;
	popupURL = "";
    };
    var popup = window.open(popupURL,s_date,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=' + x + ',height=' + y);
    windows_handlers[windows_count]=popup;
    windows_name[windows_count]=s_date;
    windows_count++;
//    alert(popupURL);
    };




function close_n_reload (winname,loc) 
    {
    for(var i=0;i<windows_count;i++)
        if (winname == windows_name[i]){
            windows_name[i] = "";
            windows_handlers[i].close();
            };
    if (loc != "") {
//        alert("loc="+window.location.href+loc);
        window.location.replace(loc);
	} else {
        window.location.reload();
	};    
    };

function close_n_nothing (winname) 
    {
//    alert("in the close&nothing");
    for(var i=0;i<windows_count;i++)
        if (winname == windows_name[i]){
            windows_name[i] = "";
            windows_handlers[i].close();
            };
    };

function close_all() 
    {
    for(var i=0;i<windows_count;i++)
        if (windows_name[i] != ""){
            windows_name[i] = "";
            windows_handlers[i].close();
            };
    };
    
function change_showcomputers(s)
    {
    document.cookie = "showcomputers ="+s;
    window.location.reload();
    };
    
function change_showcomponents(s)
    {
    document.cookie = "showcomponents ="+s;
    window.location.reload();
    };
    
function change_to_loc(id,action)
    {
    if (id==-1) return;
    var url="index.php?action="+action+"&forum_item_id="+id;
//    alert(url);
    window.location.href=url;
    };    
