/*======================= COMMON.JS =======================
THIS CONTAINS USEFULL SCRIPTS THAT ARE USED IN THIS 
APPLICATION
==========================================================*/





// This script creates a popup and resizes it to the image size
function PopupPic2(sPicURL) { 
 window.open( "/includes/common/ImagePopup.htm?"+sPicURL, "", "resizable=1,HEIGHT=200,WIDTH=200"); 
} 



function changeImage()
{
	var list = document.getElementById('optionlist');
	document.mainimage.src = list.options[list.selectedIndex].value;
}

function prevImage()
{
	var list = document.getElementById('optionlist');
	if(list.selectedIndex == 0)
	{
		list.selectedIndex = list.options.length-1;
	}
	else
	{
		list.selectedIndex--;
	}
	changeImage();
}

function nextImage()
{
	var list = document.getElementById('optionlist');
	if(list.selectedIndex == list.options.length-1)
	{
		list.selectedIndex = 0;
	}
	else
	{
		list.selectedIndex++;
	}
	changeImage();
}



//### USAGE: ?????
function goToUserPage(intUserID){
	alert("GOTO THIS USERS START PAGE "+intUserID);
}



// ### Function to animate layer at the bottom of the screen (Notify message)
function startAlertMessage(id,strMessage,NewHeight){
	var myLayer = document.getElementById(id);
	myLayer.style.visibility="visible";
	myLayer.innerHTML = strMessage;
	AlertMessage(id,NewHeight);
}

function AlertMessage(id,NewHeight){
	var myLayer = document.getElementById(id);
	if(NewHeight < 100){
		NewHeight1 = NewHeight+1;
		myLayer.style.height = NewHeight;
		
		setTimeout('AlertMessage('+"'"+id+"'"+','+NewHeight1+')', 10);
	}
	else{
		setTimeout('closeAlertMessage('+"'"+id+"'"+')', 10000);
	}
}

function closeAlertMessage(id){
var myLayer = document.getElementById(id);
myLayer.style.visibility="";
}

function setbottomframe(strpage){
parent.comstatus.location=strpage;
}


/*### INPUT COUNTER ###*/
function charCount(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
		// otherwise, update 'characters left' counter
	else 
		countfield.value = maxlimit - field.value.length;
}


function openW(mypage,myname,w,h,features) {
	if(screen.width){
		var winl = (screen.width-w)/2;
		var wint = (screen.height-h)/2;
	}else{winl = 0;wint =0;}
	
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;
	// Features Settings
	if (features != "" || features == "basic")
		features = "menu=no,status=no";
	if (features != "" || features == "full")
		features = "";
	if (features == "none")
		features = "menu=no,status=no,scrollbars=no,directories=no,location=no,resizable=no";
	
	var settings = 'height=' + h + ',';
		settings += 'width=' + w + ',';
		settings += 'top=' + wint + ',';
		settings += 'left=' + winl + ',';
		settings += features;
	win = window.open(mypage,myname,settings);
	win.window.focus();
}


/*

Gradual-Highlight Image Script II- 

By J. Mark Birenbaum (birenbau@ugrad.cs.ualberta.ca)

Permission granted to Dynamicdrive.com to feature script in archive

For full source to script, visit http://dynamicdrive.com

*/

 

nereidFadeObjects = new Object();

nereidFadeTimers = new Object();

 

/* object - image to be faded (actual object, not name);

 * destop - destination transparency level (ie 80, for mostly solid)

 * rate   - time in milliseconds between trasparency changes (best under 100)

 * delta  - amount of change each time (ie 5, for 5% change in transparency)

 */

 

function nereidFade(object, destOp, rate, delta){
if (!document.all)
return
    if (object != "[object]"){  //do this so I can take a string too
        setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
        return;
    }

    clearTimeout(nereidFadeTimers[object.sourceIndex]);
    diff = destOp-object.filters.alpha.opacity;
    direction = 1;

    if (object.filters.alpha.opacity > destOp){
        direction = -1;
    }
    delta=Math.min(direction*diff,delta);
    object.filters.alpha.opacity+=direction*delta;

    if (object.filters.alpha.opacity != destOp){
        nereidFadeObjects[object.sourceIndex]=object;
        nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
    }
}


function hidediv(strLayer) { 

if (document.getElementById) { // DOM3 = IE5, NS6 
	objlayer = "document.getElementById('"+strLayer+"')";
	objlayer = eval(objlayer);
	if (objlayer.style.display == ''){
	objlayer.style.display = 'none'; 
	}
	else{
	objlayer.style.display = ''; 
	}
} 
else { 
if (document.layers) { // Netscape 4 
	if (document.hideshow.visibility == 'visible'){
	document.hideshow.visibility = 'hidden';
	}
	else{
	document.hideshow.visibility = 'visible';
	}
} 
else { // IE 4 
document.all.hideshow.style.visibility = 'hidden'; 
} 
} 
} 

function confirmcheck(url,message) {
		Confreturn = confirm(message)
		if (Confreturn == true){
			document.location.href=url;
			}
		else {
			return false;
		}
	}