/* Description:
 *   This javacript is for photo function.
 */

function none(){}

var x = 0;
var switcher = 0;
var timerid, timerid1=0;
var timeouts = 30;
var p=0;
function ShowIndicator(numfiles1, numthumbs1)
{	
	if (!(document.getElementById('numfiles'))) {
		timerid1 = setTimeout("ShowIndicator("+numfiles1+","+numthumbs1+")", 5000);
		return;
	} else if (timerid1!=0) {
		clearTimeout(timerid1);
		startTimer();
		switchTimer(1);
	}
	
	if (document.getElementById('numfiles')!=null) 
		document.getElementById('numfiles').innerHTML = numfiles1;
	if (document.getElementById('numthumbs')!=null)
		document.getElementById('numthumbs').innerHTML = numthumbs1;
	 switchTimer(1);
}

function switchTimer(switchs) {
	if (switchs==1){
		switcher=1;
	}
	else{
		switcher=0;
	}
}

function startTimer() {
	x++;
	window.status = x;

	if ((switcher==1) && x>timeout){
		x = 0;
		document.forms[0].submit();
		
		window.status = "Refreshing...";
		switchTimer(0);
	}
	
	timerid = setTimeout("startTimer()", 1000);
}

function stopTimer() {
	window.status = "";	
	if (timerid!=0) clearTimeout(timerid);
	return;
}

//function getScreenRatio(){
	//var widths = eval(window.screen.width/1024);
	//var heights = eval(window.screen.height/768);
	
	//return (widths>heights)?heights:widths;
//}

function getScreenWidth(){
	return window.screen.width;
}

function reloadTimerFrame(dirname){
	document.location.href="index1.php?currdir="+dirname+"&skipconv=true&indicator=true";
	document.location.href="blank.php?currdir="+dirname;
}

//function getScreenWidthRatio(){
//	var widths = eval(window.screen.width/1024);
		
//	return widths;
//}
function IsUserName(str) {
  var i, c;
  var len, cnt;
  len = cnt = str.length;
  if (len == 0 || len > 15)  return false;
  if ((str.charCodeAt(0) == 32) || (str.charCodeAt(0) == 45)) 
        return false;
  if (str.charCodeAt(len-1) == 32) 
        return false;
  for (i=0; i<str.length; i++) {
    c = str.charCodeAt(i);
    if (!((c >= 128) || ((c>=97)&&(c<=122)) || ((c>=65)&&(c<=90)) ||
          ((c>=48)&&(c<=57)) || (c==45) || (c==46) || (c==95) || (c==32)))
        return false;
  }
  return true;
}


function OnCancel(gotolink) {
	window.location.replace(gotolink);
}

function Move(FromList, ToList)
{
	var NewItem;
	var i,j;

	for (i=j=0; i<FromList.length; i++) {
		if (FromList.options[i].selected) {
			NewItem = new Option();
			NewItem.text = FromList.options[i].text;
			NewItem.value = FromList.options[i].value;
			ToList.length++;
			ToList.options[ToList.length-1] = NewItem;
		} else {
			NewItem = new Option();
			NewItem.text = FromList.options[i].text;
			NewItem.value = FromList.options[i].value;
			FromList.options[j] = NewItem;
			j++;
		}
	}
	FromList.length = j;

}