/* Flash Script */

//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
	if (src.indexOf(ext) == -1)
	{
		if (src.indexOf('?') != -1)
		  return src.replace(/\?/, ext+'?'); 
		else
		  return src + ext;
	}
	else
		return src;
}

function AC_Generateobj(objAttrs, params, embedAttrs, nowrite) 
{ 
  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>';

	if(nowrite)
		return(str);

  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_FL_ReturnContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  return AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs, true);
}

function AC_FL_GenerateContentIn(objid, args){
  var ret = 
    AC_GetArgs
    (  args, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );

	if(objid.innerHTML !== undefined )
 		objid.innerHTML = AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs, true);
}

function AC_FL_GenerateVBS(objid){
	var res = '<SCR'+'IPT event=FSCommand(command,args) for='+objid+'>';
	res += objid+'_DoFSCommand(command, args);';
	res += '</SCR'+'IPT>';
  return res;
}


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":
      case "swliveconnect":
      case "name":
        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":
      case "id":
        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 "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;
}


/* Commons */

// Validate Email
function isValidEmail(email) 
{
  var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/   
  return re.test(email);
} 


/*Show hide Layer*/

function hideBox(id)
{
	document.getElementById(id).style.visibility = "hidden";
}
function showBox(id)
{
	document.getElementById(id).style.visibility = "visible";
}

/*Swap image*/
function swapImage(source, name)
{
	 var obj = document.images[name];
	 var newImg = new Image();
	 newImg.src = source;
	 obj.src = newImg.src;	  
}

function DropDownController() {};

DropDownController.LAYERPREFIX = "drp";
DropDownController.timerHide = document.getElementById("___");

DropDownController.showMenu = function (id)
{
	clearTimeout(DropDownController.timerHide);
	DropDownController.executeHideMenus();
	DropDownController.setMenuLayerVisibility(id, true);
}

DropDownController.hideMenus = function()
{
	DropDownController.timerHide = setTimeout("DropDownController.executeHideMenus()", 500);
}

DropDownController.executeHideMenus = function()
{
	divlist = document.getElementsByTagName("div");
		
	for (var i=0; i<divlist.length; i++)
	{		
		if (divlist[i].id!=null)
		{	
			if ( divlist[i].id.length>=DropDownController.LAYERPREFIX.length &&
				divlist[i].id.substring( 0, DropDownController.LAYERPREFIX.length )== DropDownController.LAYERPREFIX )
					DropDownController.setMenuLayerVisibility(divlist[i].id, false);
		}

	}
}

DropDownController.setMenuLayerVisibility = function(menuID, isVisible)
{
	if (isVisible)
		document.getElementById(menuID).style.display = "block";
	else
		document.getElementById(menuID).style.display = "none";
}

function languageChange(frm)
{
	var URL = frm.language.options[frm.language.selectedIndex].value;
	window.location.href = URL;
}

// flash detect
function FlashUtil() {};

FlashUtil.REQUIREDVERSION = 8;
FlashUtil.DOWNLOADHTML = "<a href='http://www.macromedia.com/go/getflash/' target='_blank'>Download flash plugin</a>";

FlashUtil.getFlashInfo = function()
{
	if ( !FlashUtil.flashinfo )
	{
		var PlayerVersion = -1;
		if(navigator.plugins && navigator.mimeTypes.length)
		{
			var x = navigator.plugins["Shockwave Flash"];
			if(x && x.description)
			{
				PlayerVersion = x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".");
			}
		}
		else if (window.ActiveXObject)
		{
			// "try" is reserved word in NS4, use eval to hide
			eval ( 'try { ' +
					'	var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); ' +
					'	PlayerVersion = axo.GetVariable("$version").split(" ")[1].split(","); ' +
					'} ' +
					'catch (e) {}'
				 );
		}
		FlashUtil.flashinfo = new Object();
		FlashUtil.flashinfo.installed = PlayerVersion[0]!=-1;
		FlashUtil.flashinfo.version = PlayerVersion[0];
	}
	return FlashUtil.flashinfo;
}

FlashUtil.checkPlugin = function()
{
	return ( FlashUtil.getFlashInfo().installed && FlashUtil.getFlashInfo().version >= FlashUtil.REQUIREDVERSION );
}

// player functions

function FlashObject( swf, width, height, id )
{
	this.parameters = new Object();
	this.attributes = new Object();
	this.flashvars = new Object();
	this.althtml = FlashUtil.DOWNLOADHTML;
	
	this.attributes["swf"] = swf;
	this.attributes["width"] = width ? width : "100%";	
	this.attributes["height"] = height ? height : "100%";	
	this.attributes["id"] = id ? id : "flashobject";
	this.parameters["play"] = "true";
	this.parameters["loop"] = "true";
	this.parameters["quality"] = "high";
	this.parameters["allowScriptAccess"] = "sameDomain";
	
	this.setAttribute = function ( name,value )
	{
		this.attributes[name] = value;
	}
	
	this.setParameter = function ( name,value )
	{
		this.parameters[name] = value;
	}
	
	this.setFlashvar = function ( name,value )
	{
		this.flashvars[name] = value;
	}
	
	this.setAlthtml = function ( html )
	{
		this.althtml = html;
	}
	
	this.draw = function()
	{
		var h = "";
		if ( FlashUtil.checkPlugin() )
		{
			var flashvarsarr = new Array();
			for(var key in this.flashvars)
				flashvarsarr[flashvarsarr.length]= (key + "=" + escape(this.flashvars[key]));
		
			if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length)
			{
				h = '<embed type="application/x-shockwave-flash" src="'+ this.attributes['swf'] +'" width="'+ this.attributes['width'] +'" height="'+ this.attributes['height'] +'"';
				h += ' id="'+ this.attributes['id'] +'" name="'+ this.attributes['id'] +'" ';
				for (var key in this.parameters)
					h += ( [key] + '="' + this.parameters[key] + '" ' );
				if (flashvarsarr.length > 0)
					h += ( 'flashvars="' + flashvarsarr.join("&") + '"' );
				h += '/>';
			}
			else
			{
				h = '<object id="'+ this.attributes['id'] +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.attributes['width'] +'" height="'+ this.attributes['height'] +'">';
				h += '<param name="movie" value="'+ this.attributes['swf'] +'" />';
				for (var key in this.parameters)
					h += '<param name="'+ key +'" value="'+ this.parameters[key] +'" />';
				if (flashvarsarr.length > 0)
					h += '<param name="flashvars" value="' + flashvarsarr.join("&") + '" />'
				h += "</object>";
			}
		}
		else
		{
			h = this.althtml;
		}
		document.write(h);
	}
}

/* added on 2008.11.26 by d.favia */
function open_window(s1,s2,s3) {
	qwerty=window.open(s1,s2,s3);
	return false;
}
