var popUp =
{
	o_window: null,
	old_location: 'index.php',
	
	resize: function()
	{
		var container = getById('container');
		if(window.contentHeight)getById('content').style.height = window.contentHeight + 'px';
		var ie = (navigator.appName == 'Microsoft Internet Explorer' ? true : false);
		var nfo = getInfo(container);
		var width = nfo.width + 14 + (ie ? 3 : 0);
		var height = nfo.height + 62 + (ie ? 4 : 0);
		var left = (screen.availWidth / 2) - (width / 2);
		var top = (screen.availHeight / 2) - (height / 2);
		
		window.resizeTo(width, height);
		window.moveBy(left-window.opener['sc_y'], top-window.opener['sc_x']);
		this.old_location = window.opener.location;
		window.opener['sc_x'] = top;
		window.opener['sc_y'] = left;
		window.focus();
	},
	
	open: function(page, other)
	{
		other = (typeof other == 'undefined' ? '' : other);
		var url = basedir+page+other;
		var title = 'HELLODESIGN';
		var height = 1;
		var width = 1;
		var left = 0;
		var top = 0;
		//this.o_window = window.open(url, title, 'height='+height+', width='+width+', left='+left+', top='+top+', channelmode=0, directories=0, fullscreen=0, location=0, menubar=0, resizable=0, scrollbars=0, status=0, titlebar=0, toolbar=0');
		window['sc_x'] = 0;
		window['sc_y'] = 0;
		setCookie('hellodesign_login_manager_back_url', window.location, 1);
		window.location = url;
	},
	
	refreshParent: function()
	{
		window.opener.location = window.opener.location;
	},
	
	close: function()
	{
		var url = (getCookie('hellodesign_login_manager_back_url') ? getCookie('hellodesign_login_manager_back_url') : 'index.php');
		delCookie('hellodesign_login_manager_back_url');
		window.location = url;
	},
	
	sendToOpener: function(data)
	{
		window.opener['popUp_recievedData'] = data;
	},
	
	getRecievedData: function()
	{
		return window['popUp_recievedData'];
	},
	
	sendForm: function(cmd)
	{
		var form = document.forms['popUpForm'];
		var e = null;
		var attr = '';
		
		for(var i=0 ; i<form.length ; i++)
		{
			e = form[i];
			if(typeof e == 'object' && (attr = e.getAttribute('required')) )
			{
				if(attr == '1')
				{
					if(e.value.length == 0)
					{
						alert(ml_lang[2]);
						e.focus();
						return false;
					}
				}
				else if(typeof form[attr] != 'undefined')
				{
					if(e.value != form[attr].value)
					{
						alert(ml_lang[3]);
						e.focus();
						return false;
					}
				}
			}
		}
		
		form.submit();
		return true;
	},
	
	exchangeButton: function(obj, id_1, id_2)
	{
		var obj_1 = getById(id_1);
		var obj_2 = getById(id_2);
		
		if(obj.value.length > 0)
		{
			obj_1.style.display = 'none';
			obj_2.style.display = 'block';
		}
		else
		{
			obj_1.style.display = 'block';
			obj_2.style.display = 'none';
		}
	},
	
	goTo: function(page, other)
	{
		other = (typeof other == 'undefined' ? '' : other);
		var url = basedir + 'index.php?page='+page+other;
		window.location = url;
	},
	
	focus: function()
	{
		/*var input = document.getElementsByTagName('input');
		
		for(var i=0 ; i<input.length ; i++)
		{
			if(parseInt(input[i].getAttribute('focus')) == 1)
			{
				if(isElement(input[i]))
				if(isFunction(input[i].focus))input[i].focus();
				break;
			}
		}*/
	},
	
	listenRadio: function(url)
	{
		/*var height = 1;
		var width = 1;
		var left = 0;
		var top = 0;
		var radioPopUp = window.open('index.php?page=listen_radio', '', 'height='+height+', width='+width+', left='+left+', top='+top+', channelmode=0, directories=0, fullscreen=0, location=0, menubar=0, resizable=0, scrollbars=0, status=0, titlebar=0, toolbar=0');
		window['sc_x'] = 0;
		window['sc_y'] = 0;
		radioPopUp.contentHeight = getInfo('content').height;
		radioPopUp.radioURL = url;*/
		window.location = url;
	},
	
	startRadio: function()
	{
		if(window.radioURL)
		{
			window.opener.popUp.close();
			getById('iRadio').src = window.radioURL;
		}
		else
		{
			alert('No radio URL!');
		}
	}
}

/*******************************************************************************
	OTHER
*******************************************************************************/
function ctrlCheckStateChange(formName,name,value,color,display)
{
    var imgName = 'img_'+name;
    display = (display != '' ? display.split(':') : false);
    
    color = (typeof color != 'undefined' ? color : '')
    if( (imgNode = document.getElementById(imgName)) )
    {
        if( document.forms[formName].elements[name].value == value )
        {
            imgNode.src = './images/'+color+'chk_box.gif';
            document.forms[formName].elements[name].value = "";
            
            if(display[1] == 'cheked')
            {
                tmp = display[0].split(',');
                for(var i=0 ; i<tmp.length ; i++)
                {
                    getById(formName+'-'+tmp[i]).style.display = 'inline';
                }
            }
            else if(display)
            {
                tmp = display[0].split(',');
                for(var i=0 ; i<tmp.length ; i++)
                {
                    getById(formName+'-'+tmp[i]).style.display = 'none';
                }
            }
        }
        else
        {
            imgNode.src = './images/'+color+'chk_box_checked.gif';
            document.forms[formName].elements[name].value = value;
            
            if(display[1] == 'cheked')
            {
                tmp = display[0].split(',');
                for(var i=0 ; i<tmp.length ; i++)
                {
                    getById(formName+'-'+tmp[i]).style.display = 'none';
                }
            }
            else if(display)
            {
                tmp = display[0].split(',');
                for(var i=0 ; i<tmp.length ; i++)
                {
                    getById(formName+'-'+tmp[i]).style.display = 'inline';
                }
            }
        }
    }
}