
/* 
	Iieo?aiea eoee 
*/
function getCookie(variable) 
{
	if(variable == null)
	{
		variable = 'report';
	}
	
	var prefix = variable +"=";
	var cookieStartIndex = document.cookie.indexOf(prefix);
	if (cookieStartIndex == -1)
               return "";
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
	if (cookieEndIndex == -1)
               cookieEndIndex = document.cookie.length;
	return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}


/* 
	Caienu iiaie eoee 
*/
function saveCookie(variable, value, expires)
{
	var newCookie = variable +"=" + escape(value) + "; path=/; expires=" + expires;
	document.cookie = newCookie;
}


/* Niaia ecia?a?aiey i?e iaaaaaiee */
function over(img, ref)
{
	document.images[img].src = ref;
}	 


/* Niaia ecia?a?aiey i?e oae?aiee */
function out(img, ref)
{
	document.images[img].src = ref;
}


/* Ioe?uoea iiaiai ieia */
function w_open()
{
	var url = w_open.arguments[0];
	
	var w;
	var h;
	var settings;
	
	if(w_open.arguments[1]) 
	{
		w = w_open.arguments[1];
	} 
	else
	{
		w = screen.width - 100;
	} 
	
	if(w_open.arguments[2]) 
	{
		var h = w_open.arguments[2];
	} 
	else
	{
		h = screen.height - 200;
	}
	
	var wn = 'wname' + Math.round(Math.random() * 10000);
	
	if(w_open.arguments[3] == 'all_enable')
	{
		settings = 'toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=yes, resizable=yes, fullscreen=yes, target=_blank';	
	}
	else if(w_open.arguments[3])
	{
		settings = w_open.arguments[3];	
	}
	else
	{
		settings = 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, status=no, fullscreen=no, left=40, top=40, width='+w+',height='+h+', target=_blank';	
	}

	var openedWindow = window.open(url, wn, settings);

	if(openedWindow.opener == null) openedWindow.opener = self;
	openedWindow.focus();
}


/* Ooieoey caa?ocee ooieoee ii ieii?aiee caa?ocee no?aieou (i?eia? auciaa: addLoadEvent(onloadSelect);) */
function addLoadEvent(func) 
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function') 
	{
		window.onload = func;
	}
	else
	{
		window.onload = function() 
		{
			oldonload();
			func();
		}
	}
}

/* Ii?aaaeaiea iaee?ey ooieoee */
function defined(constant_name)
{
	return (typeof window[constant_name] !== 'undefined');  
}

/* Aiaeia PHPoiie ooieoee var_dump */
function var_dump(obj) 
{     
	var out = "";     
	if(obj && typeof(obj) == "object")
	{         
		for(var i in obj) 
		{             
			out += i + ": " + obj[i] + "\n";         
		}     
	} 
	else
	{
		out = obj;
	}
			
	alert(out); 
}

/* Confirm */
function confirm_alert(text)
{
	if(confirm(text))
	{
		return true;
	}
	else
	{
		return false;
	}
}


/* Clone */
function clone(o) 
{
	if(!o || 'object' !== typeof o)  
	{
		return o;
	}

	var c = 'function' === typeof o.pop ? [] : {};

	var p, v;

	for(p in o) 
	{
		if(o.hasOwnProperty(p)) 
		{
			v = o[p];
			if(v && 'object' === typeof v) 
			{
				c[p] = clone(v);
			}
			else
			{
				c[p] = v;
			}
		}
	}

	return c;
}


/*
ioe?uoea nnueee ?a?ac onclick n iaee?eai http_refrer a IE
*/
function open_link(url, target, timeout)
{
	target = target || '';
	timeout = timeout || 1;
	
	setTimeout("open_link_func('"+ url +"', '"+ target +"')", timeout);	
}

function open_link_func(url, _target)
{ 
	_target = _target || '_self';
    	
	var fakeLink = document.createElement('a');

	if(typeof(fakeLink.click) == 'undefined')
	{
		if(_target == '_blank')
		{
			w_open(url, '', '', 'all_enable');	
		}
		else
		{
			window.location.href = url;
		}
	}
	else
	{
		fakeLink.target = _target;
		fakeLink.href = url;
		document.body.appendChild(fakeLink);
		fakeLink.click();
	}
} 


/*
aiaeia alert() e confirm()
aey eniieuciaaiey o?aaoaony iiaee??eou iiaoeu jquery-ui naienoai dialog
*/
function alert_window(id, text_id, title, text, function_load_on_true, buttons, options)
{
	buttons = buttons || '';
		
	$('#'+ text_id).html(text);
	
	$('#'+ id).attr('class', '');
	
	if(title != '')
	{
		$('#'+ id).attr('title', title);
		$('#ui-dialog-title-'+ id).html(title);
	}	
	
	if(buttons == '')
	{    	
    	$('#'+ id).dialog({buttons: [
        	{
        		text: 'Ok',
        		click: function() {
        			$(this).dialog('close'); 
					
					if(function_load_on_true != '')
					{
						eval(function_load_on_true);
					}
       			}
       		}	
    	]}, {modal: true}, options);	
	}
	else
	{
		$('#'+ id).dialog({buttons: [
			{
        	 	text: buttons['0']['name'],
        		click: function() {
        			$(this).dialog('close'); 
					
					if(buttons['0']['action'] != '')
					{
						eval(buttons['0']['action']);
					}
       			}
    		},
    		{
        		text: buttons['1']['name'],
        		click: function() {
        			$(this).dialog('close'); 
					
					if(buttons['1']['action'] != '')
					{
						eval(buttons['1']['action']);
					}
       			}
    		}
   		]}, {modal: true}, options);	
	}
	
	return false;
}


function confirm_window(id, text_id, title, text, function_load_on_true)
{
	$('#'+ text_id).html(text);
	
	$('#'+ id).attr('class', '');
	
	if(title != '')
	{
		$('#'+ id).attr('title', title);
		$('#ui-dialog-title-'+ id).html(title);
	}
	
	$('#'+ id).dialog({buttons: [
			{
        	 	text: 'Aa',
        		click: function() {
        			$(this).dialog('close'); 
					
					if(function_load_on_true != '')
					{
						eval(function_load_on_true);
					}
       			}
    		},
    		{
        		text: 'Iao',
        		click: function() {
        			$(this).dialog('close'); 
       			}
    		}
   	]}, {modal: true});
	
	return false;
}


