
// script : movment gellary 29/6/2009
// author: Hussen Refaa(hus244@hotmail.com) 
// Copyright (c) 2009 Hussen refaa (onyxar team ©)



/////////////////////////////////////////////////
////////////// gallery moving
////////////////////////////////////////////////

function swapBigImage(imgSrc){
		
		
			var obj = document.getElementById('bigImg');	
	
			if (document.all){
				// IE
				applayBlendTransFilter(imgSrc,obj);
			}
			else{
				// (fire fox, opera, safari .. )
				obj.style.filter = 'alpha(opacity=0)'
                FadeInImage('bigImg',imgSrc,'bigImg');					
			}	
			
			
		
					
}


function applayBlendTransFilter(iamgepath,obj)
{
	
	obj.style.filter="blendTrans(duration=2)";
	obj.style.filter="blendTrans(duration=crossFadeDuration)";
	obj.filters.blendTrans.apply() ;
	obj.src=iamgepath ;
	obj.filters.blendTrans.play(); 
}



/// use the for IE only
function fadeOut() {
    oDiv.style.filter="blendTrans(duration=2)";
    // Make sure the filter is not playing.
    if (oDiv.filters.blendTrans.status != 2) {
        oDiv.filters.blendTrans.apply();
        oDiv.style.visibility="hidden";
        oDiv.filters.blendTrans.play();
    }
}

/// use the for IE only
function fadeIn() {
    oDiv.style.filter="blendTrans(duration=2)";
    // Make sure the filter is not playing.
    if (oDiv.filters.blendTrans.status != 2) {
        oDiv.filters.blendTrans.apply();
        oDiv.style.visibility="visible";
        oDiv.filters.blendTrans.play();
    }
}



function shiftOpacity(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
    if(document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 100, millisec);
    } else {
        opacity(id, 40, 100, millisec);
    }
} 

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
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 + ")";
} 

//page by page for photos

function nextArc(url, ownerDivId,title){
   // pleaseWait ('wait1', true) ;
	new Ajax.Request('./imagePBPServelet?'+url, {
		onSuccess: function(response){
			completeNavigation(response, 'Archive',title);
           // pleaseWait ('wait1', false) ;			
		}
	});
	pageNum--;
}
//page by page for photos
function previousArc(url, ownerDivId,title){
   // pleaseWait ('wait1', true) ;
	new Ajax.Request('./imagePBPServelet?'+url, {
		onSuccess: function(response){
			completeNavigation(response, 'Archive',title);
           // pleaseWait ('wait1', false) ;			
		}
	});
	pageNum++;
} 

//page by page for photos
function pleaseWait(divName, show){
	if(show == true){
		$(divName).update(new Element('img', {src:'jQuery/files/loader.gif'}).setStyle({Left:'373px', Top:'157px'}));
	}
	else{
		$(divName).update(null);
	}
}

function completeNavigation(response, ownerDivId,title){
 var objSum = document.getElementById('butonTitle');
	var newContent = response.responseText;
	$(ownerDivId).innerHTML = newContent;
	objSum.innerHTML=title;
	
	
}






////////////////////
// Opacity and Fade in script.
// Script copyright (C) 2008 http://www.cryer.co.uk/.
// Script is free to use provided this copyright header is included.
function SetOpacity(object,opacityPct)
{
	// IE.
	object.style.filter = 'alpha(opacity=' + opacityPct + ')';
	// Old mozilla and firefox
	object.style.MozOpacity = opacityPct/100;
	// Everything else.
	object.style.opacity = opacityPct/100;
}
function ChangeOpacity(id,msDuration,msStart,fromO,toO)
{
	var element=document.getElementById(id);
	var opacity = element.style.opacity * 100;
	var msNow = (new Date()).getTime();
	opacity = fromO + (toO - fromO) * (msNow - msStart) / msDuration;
	if (opacity<0) 
		SetOpacity(element,0)
	else if (opacity>100)
		SetOpacity(element,100)
	else
	{
		SetOpacity(element,opacity);
		element.timer = window.setTimeout("ChangeOpacity('" + id + "'," + msDuration + "," + msStart + "," + fromO + "," + toO + ")",10);
	}
}

/// this for fire fox
function FadeInF(id)
{
	var element=document.getElementById(id);
	if (element.timer) window.clearTimeout(element.timer);	
	var startMS = (new Date()).getTime();
	element.timer = window.setTimeout("ChangeOpacity('" + id + "',100," + startMS + ",0,100)",1);
}
/// this for fire fox
function FadeOutF(id)
{
	var element=document.getElementById(id);
	if (element.timer) window.clearTimeout(element.timer);	
	var startMS = (new Date()).getTime();
	element.timer = window.setTimeout("ChangeOpacity('" + id + "',100," + startMS + ",100,0)",1);
}
function FadeInImage(foregroundID,newImage,backgroundID)
{
	var foreground=document.getElementById(foregroundID);
	if (backgroundID)
	{
		var background=document.getElementById(backgroundID);
		if (background)
		{
			background.style.backgroundImage = 'url(' + foreground.src + ')';
			background.style.backgroundRepeat = 'no-repeat';
		}
	}
	SetOpacity(foreground,0);
	foreground.src = newImage;
	if (foreground.timer) window.clearTimeout(foreground.timer);	
	var startMS = (new Date()).getTime();
	foreground.timer = window.setTimeout("ChangeOpacity('" + foregroundID + "',1000," + startMS + ",0,100)",1);
}
