// ****************** Start Macromedia Functions ******************** //
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


// ******************* End Macromedia Functions ********************* //

function encURI(str) {
  str = str.toString();
  str = str.replace(/%/g, "%25");
  str = str.replace(/ /g, "%20");
  str = str.replace(/#/g, "%23");
  str = str.replace(/\+/g, "%2B");
  str = str.replace(/\?/g, "%3F");
  str = str.replace(/=/g, "%3D");
  str = str.replace(/&/g, "%26");
  str = str.replace(/\t/g, "%09");
  return str;
}

// ****************** Start Eddy Functions ******************** //

function globalHandleLink(e) {
  if (!e) e = window.event;
  var source = e.srcElement?e.srcElement:e.target;
  while (source.nodeName != 'A' && source.parentNode) {
    source = source.parentNode;
  }
  if (source.nodeName == 'A' && source.href.indexOf("javascript:") != 0) {
    //  alert(source.href);
    handleLink(source.href);
  }
}

// document.onclick=globalHandleLink

function handleLink(url) {
  if (url.indexOf("http://") != 0 && url.indexOf("/") != 0) return;
  if (getEddyFrame() == null)
    return;

  if (url.indexOf('?') >= 0)
    url = url.substring(0, url.indexOf('?'));

  var fullUrl = url;
  if (fullUrl.charAt(fullUrl.length-1) == '/')
    fullUrl = fullUrl.substring(0,fullUrl.length-1);
  var behave = fullUrl.substring(fullUrl.lastIndexOf('/')+1);
  var base = fullUrl.substring(0,fullUrl.lastIndexOf('/'));
  if (behave.lastIndexOf('.') >= 0)
    behave = behave.substring(0,behave.lastIndexOf('.'));
//  alert(base+'/'+behave+'.swf');
  getEddyFrame().playMovie(base+'/'+behave+'.swf');
}

function getBaseUrl(url) {
  var loc = new String(url);
  if (loc.substring(0,1) == "/")
    return '/'
  if (loc.substring(0,4) != 'http')
    return '';
  return (loc.substring(0,loc.substring(7).indexOf('/')+7));
}

function getEddyFrame() {
  return top.eddyFrame;
}

// ******************* End Eddy Functions ********************* //

function MachakFull(Ie,other){
  x=screen.availWidth;
  y=screen.availHeight;
  target = parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf('.')-1,navigator.appVersion.length));
  if((navigator.appVersion.indexOf("Mac")!=-1) &&(navigator.userAgent.indexOf("MSIE")!=-1) &&(parseInt(navigator.appVersion)==4))
  window.open(other,"sub",'scrollbars=yes');
  if (target >= 4) {
    if (navigator.appName=="Netscape") {
      var MachakFull=window.open(other,"MachakFull",'scrollbars=yes','width='+x+',height='+y+',top=0,left=0');
      MachakFull.moveTo(0,0);
      MachakFull.resizeTo(x,y);
    }
    if (navigator.appName=="Microsoft Internet Explorer")
      window.open(Ie,"MachakFull","fullscreen=yes");
  } 
  else window.open(other,"sub",'scrollbars=yes');
}


function showHideLayers(arg) { //v6.0
  if ((obj=MM_findObj(arg))!=null) { 
    if (obj.style) {
      obj.style.visibility=obj.style.visibility=='hidden'?'visible':'hidden';
    }
  }
}

function checkForm() {
	
}




//*** JAVASCRIPT TO FLASH COMMAND *** //

function getFlashMovieObject(movieName) {
  if (window.document[movieName]) {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1) {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  } else {
    return document.getElementById(movieName);
  }
}

function stopaudio() {
	//var items = stopaudio.arguments.length;
	
	var flashMovie = getFlashMovieObject("myAudio");
	flashMovie.TGotoFrame("_root/soundCueTarget",18);
	flashMovie.TGotoFrame("_root/pauseButton",2);

	//if (items > 0) {
	//	if (stopaudio.arguments[0] == "alert") {
	//		alert("so: "+flashMovie.TCurrentFrame("_root/soundCueTarget"));	
	//	}
	//}
}

//*** FLASH TO FANCYBOX COMMAND *** //

function flashFancybox(w,h,u) {
	$.fancybox({
		href:				u,
		width:				w || 780,
		height:				h || 525,
		padding:			0,
		autoScale:			false,
		transitionIn:		'elastic',
		easingIn:			'swing',
		transitionOut:		'elastic',
		type:				'iframe',
		orig:				'',
		hideOnOverlayClick:	false
	});
}


