
function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1)
      return element;

    elements.push(element);
  }

  return elements;
}

var $A = function(iterable) {
  if (!iterable) return [];

    var results = [];
    for (var i = 0; i < iterable.length; i++)
      results.push(iterable[i]);
    return results;
}


function $F(id){
	return document.getElementById(id).value;
}

function deletethis (e) {
	
	if (!e) var e = window.event;
	var tg = (e.target) ? e.target : e.srcElement
	var where_to= confirm("Do you really want to delete the slide?");

	if(where_to==true)
	{
	   //removeObj(tg.parentNode);
	   removeObj(tg.parentNode.parentNode.parentNode.parentNode.parentNode); // from div with image throung table tr's & td's to li element
	}
}
function removeObj(tr){
    tr.parentNode.removeChild(tr);
    executeInASecond();
}

function confirmURL(text,url){
	if(window.confirm(text)){
		location.href=url;
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function SetEvent(objReciver, objCaller, eventName, callBackFunName)
{
	var handler = objCaller[eventName];
	if (typeof (handler) != 'function')
		objCaller[eventName] = function() { return objReciver[callBackFunName].apply(objReciver, arguments);}
	else
		objCaller[eventName] = function()
			{
				handler.apply(objReciver, arguments);
				// important for DOM elements
				return objReciver[callBackFunName].apply(objReciver, arguments);
			}
}

formSubmitOnce = 0;
function formSubmitOnlyOnce(){
	var i,args = formSubmitOnlyOnce.arguments;
	formobj = args[0];
	formSubmitOnce += 1;
	if (formSubmitOnce > 1) {
		alert('Do not press submit button twice.');
		return false;
	} else {
		for(i=1;i<args.length;i++){
//			args[i].disabled = true;
		}
		return true;
	}
}

function resizeImg(id, newValue){
	if (!newValue)
		newValue = 100;
	var img = document.getElementById(id);
    var width = img.width;
    var height = img.height;
	if (img.width > newValue){
		ratio = width/newValue;
		img.width = newValue;
		img.height = parseInt(height/ratio);
        return;
	}
    if (img.height > newValue){
		ratio = iheight/newValue;
		img.height = newValue;
		img.width = parseInt(width/ratio);
        return;
	}
}

function go(url){
	if (url) document.location.href=url;
}

function Set_Cookie( name, value, expires)
{
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) + ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + ";domain=/";
}


function Get_Cookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function Delete_Cookie( name, path) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" + ";domain=/" + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}


function callFlashFunction(param,value)
{
	var swf = thisMovie("main_loader");
	swf.changeParam('slide', 'renew');
	swf.changeParam(param, value);
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1)
	{
        return window[movieName];
    }
    else {
        return document[movieName]
    }
}

