//--------------------------------------------------------------------------------
//------------------------ 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 --------------------------------------------------

var showswapeffect = true;
var speedwapeffect = 2000;

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;  //blendimage(a[i],x.oSrc,1000);
}

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];
		 if(showswapeffect) blendimage(a[i],a[i+2],speedwapeffect); //x.src=a[i+2]; blendimage(a[i],a[i+2],400);
		 }
	 
}
//-------------------------------------------------------------------------------	
//------------------ Image Effects ----------------------------------------------

function changeOpac(opacity, id) {
    var object = $(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function makeMe(id,xsrc){
	var objImage = document.createElement("img");
		objImage.setAttribute('id','swpimage');			
		objImage.setAttribute('src',xsrc);		
		$(id).appendChild(objImage);		
}

	
function blendimage(imageid, imagefile, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;
	//makeMe('navigation',imagefile);
	//imageid = 'swpimage';	
    $(imageid).style.backgroundImage = "url(" + $(imageid).src + ")";  
    changeOpac(50, imageid);
		$(imageid).src = imagefile;
    //fade in image	
	for(i = 50; i <= 100; i++) {
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
        timer++;
    }
	
} 
//-------------------------------------------------------------------------------	
//------------------ Popup window  ----------------------------------------------

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);
}
//-------------------------------------------------------------------------------	
//--------------------- Popup pic  ----------------------------------------------

function PopupPic(sPicURL) { 
	var windowLeft 	= (screen.width / 2) - 558;
	var windowTop 	= (screen.height / 2) - 451;
     window.open('popup.php?'+sPicURL,'','resizable=1,width=558,height=451,left='+windowLeft+',top='+windowTop+''); 
}
//-------------------------------------------------------------------------------	
//--------------------- Protact email  ------------------------------------------

function ProtactEmail() {	
	a=ProtactEmail.arguments;
	if(a[3] == ""){
		var domain = ".com";
	}
	var domain 	= a[3];
	var emailid = a[0] + "&#64;"+ a[1] + domain;
  	document.write("<a href=mailto:" + emailid + "?subject=" + a[2] + ">" + emailid + "<\/a>");
}
//-------------------------------------------------------------------------------	
//--------------------- Copyright Year ------------------------------------------

function Copyright(){
	var today = new Date();	
	document.write("&copy; " + today.getFullYear());
	//$('copyright').innerHTML = "&copy; " + today.getFullYear();
}
//-------------------------------------------------------------------------------	
//--------------------- Webmasters Credit ---------------------------------------

function Credit(){
	document.write("<a href=http://www.odweb.com>Web design and hosting by Online Design<\/a>");	
}