//--------------------------------------------------------------------------------
//------------------------ Standard Javafunctions V0.1 ---------------------------
//------------------------           29/08/08          ---------------------------
//--------------------------------------------------------------------------------

//--------------------------- Prototype function ---------------------------------
//----------- Note: Please remove this function if using prototype.js ------------

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;
		  }
//-------------------------------------------------------------------------------	
//--------------- MM Swap --------------------------
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_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;
}

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]; 
		 }
	 
}
//--------------------------------------------------------
//---------- FP Swap ------------------------------------

function FP_preloadImgs() {//v1.0
 var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
 for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}

function FP_swapImg() {//v1.0
 var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
 n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
 elm.$src=elm.src; elm.src=args[n+1]; blendimage(args[n],args[n+1],400); } }
}

function FP_getObjectByID(id,o) {//v1.0
 var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
 else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
 if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
 for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
 f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
 for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
 return null;
}

function FP_swapImgRestore() {//v1.0
 var doc=document,i; if(doc.$imgSwaps) { for(i=0;i<doc.$imgSwaps.length;i++) {
  var elm=doc.$imgSwaps[i]; if(elm) { elm.src=elm.$src; elm.$src=null; } } 
  doc.$imgSwaps=null; }
}
//---------------------------------------------------------
//----- Image Effects ----------
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function blendimage(imageid, imagefile, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;    
 
    document.getElementById(imageid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";  
    changeOpac(0, imageid);
		document.getElementById(imageid).src = imagefile;
    //fade in image
    for(i = 50; i <= 100; i++) {
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
        timer++;
    }
} 
//------------------------------
function popupwindow(url,popupname,parameters)
{
	window.open(url,popupname,parameters);
}

function FP_openNewWindow(w,h,nav,loc,sts,menu,scroll,resize,name,url) {//v1.0
 var windowProperties=''; if(nav==false) windowProperties+='toolbar=no,'; else
  windowProperties+='toolbar=yes,'; if(loc==false) windowProperties+='location=no,'; 
 else windowProperties+='location=yes,'; if(sts==false) windowProperties+='status=no,';
 else windowProperties+='status=yes,'; if(menu==false) windowProperties+='menubar=no,';
 else windowProperties+='menubar=yes,'; if(scroll==false) windowProperties+='scrollbars=no,';
 else windowProperties+='scrollbars=yes,'; if(resize==false) windowProperties+='resizable=no,';
 else windowProperties+='resizable=yes,'; if(w!="") windowProperties+='width='+w+',';
 if(h!="") windowProperties+='height='+h; if(windowProperties!="") { 
  if( windowProperties.charAt(windowProperties.length-1)==',') 
   windowProperties=windowProperties.substring(0,windowProperties.length-1); } 
 window.open(url,name,windowProperties);
}

function PopupPic(sPicURL) { 
	var windowLeft = (screen.width / 2) - 318;
	var windowTop = (screen.height / 2) - 295;
     window.open('popup.php?'+sPicURL,'','resizable=1,width=558,height=451,left='+windowLeft+',top='+windowTop+''); 
} 
      