// Random homepage image script now in body of index
//var interval = 2.5; // delay between rotating images (in seconds)
//var random_display = 1; // 0 = no, 1 = yes
//interval *= 1000;

/*var image_index = 0;
image_list = new Array();
image_list[image_index++] = new imageItem("support/media/index/images/main_01.jpg");
image_list[image_index++] = new imageItem("support/media/index/images/main_02.jpg");
image_list[image_index++] = new imageItem("support/media/index/images/main_03.jpg");
image_list[image_index++] = new imageItem("support/media/index/images/main_04.jpg");
image_list[image_index++] = new imageItem("support/media/index/images/main_05.jpg");
image_list[image_index++] = new imageItem("support/media/index/images/main_06.jpg");
var number_of_image = image_list.length;
function imageItem(image_location) {
	this.image_item = new Image();
	this.image_item.src = image_location;
}
function get_ImageItemLocation(imageObj) {
	return(imageObj.image_item.src)
}
function generate(x, y) {
	var range = y - x + 1;
	return Math.floor(Math.random() * range) + x;
}
function getNextImage() {
	if (random_display) {
		image_index = generate(0, number_of_image-1);
	}
	else {
		image_index = (image_index+1) % number_of_image;
	}
	var new_image = get_ImageItemLocation(image_list[image_index]);
	return(new_image);
}
function rotateImage(place) {
	var new_image = getNextImage();
	document[place].src = new_image;
}*/

function DoPopup(URL, Width, Height, Resizable, Scrollbars, Toolbar, Location, Status, Menubar)
{
    /*
    Width=Use this to define the width of the new window.
    Height=Use this to define the height of the new window.
    Resizable=yes or no; Use this to control whether or not you want the user to be able to resize the window.
    Scrollbars=yes or no; This lets you decide whether or not to have scrollbars on the window.
    Toolbar=yes or no; Whether or not the new window should have the browser navigation bar at the top (The back, foward, stop buttons..etc.).
    Location=yes or no; Whether or not you wish to show the location box with the current url (The place to type http://address).
    Status=yes or no; Whether or not to show the window status bar at the bottom of the window.
    Menubar=yes or no; Whether or not to show the menus at the top of the window (File, Edit, etc...).
    */

    var windowprops='width=' + Width + ',height=' + Height + ',resizable=' + Resizable + ',scrollbars=' + Scrollbars + ',toolbar=' + Toolbar + ',location=' + Location + ',status=' + Status + ',menubar=' + Menubar;
    var new_window = window.open(URL,'NewWindow',windowprops);

    var xPos = (screen.availWidth-parseInt(Width)) * 0.50;
    var yPos = (screen.availHeight-parseInt(Height)) * 0.25;
    new_window.moveTo(xPos,yPos);
    new_window.focus();
}

// Embed SWF
function closeWindow() {
	window.opener.focus();
	window.close();
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}