function init(argstr){
  var args = argstr.split(',');
  for(i in args){
    switch(args[i]){
	    case 'genCode':
	    	document.getElementById('code').value = "tR1Xxie";
	    	break;
      case 'setRes':
        setRes();
        break;
      default:
        break;
    }
  }
  mailReplace();
}

function setRes(){
  var strHref = window.location.href;
  if(strHref.indexOf('?', 0) == -1){
    window.location = strHref + '?res=' + screen.height;
  } else {
    window.location = strHref + '&res=' + screen.height;
  }
}

function mailReplace(){
  var mailElem;
  for(var i = 0; (mailElem = document.getElementById('m'+i)) != null; i++){
    var temp = mailElem.href.split('(a)');
    mailElem.href = temp[0] + '@' + temp[1];
    temp = mailElem.firstChild.nodeValue.split('(a)');
    if(temp.length > 1)
      mailElem.firstChild.nodeValue = temp[0] + '@' + temp[1];      
  }
}

function check_box(box_id){
	var elem = document.getElementById(box_id);
	elem.checked = true;
}

function comment_toggle(id){
	check_box('photo'+id);
	var priv = document.getElementById('private'+id);
	var texta = document.getElementById('description'+id);
	if(priv.checked == true){
		texta.style.backgroundColor = '#CCCCFF';
	} else {
		texta.style.backgroundColor = '#FFFFFF';
	}
}

function popUpPhoto(album, photo){
	var photowin = window.open('photowin.php?album='+album+'&id='+photo,'photowin','resizable=yes, scrollbars=yes');
	photowin.focus();
}
