// JavaScript Document
var where = false;

var C     = false;
var placed = '';

function loadData(url, areaid, name,noteLoad) {

	if(name == null)
		name = "";
	if(url == null)
		return;
	if(noteLoad == null)
		C = areaid;
	else
		C = noteLoad

        url.replace("&amp;","&")
		if(areaid != null){
				
                document.getElementById(C).innerHTML = "<span >Loading "+name+"...</span>";
		}
		
	     if (window.XMLHttpRequest) { // Mozilla, Safari,...

			xmlDoc = new XMLHttpRequest();

			if (xmlDoc.overrideMimeType) {
                xmlDoc.overrideMimeType('text/xml');
			}

        } else if (window.ActiveXObject) { // IE
            try {
                xmlDoc = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

	 if (!xmlDoc) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

	url =url + (url.indexOf("?")==-1?"?":"&")+"time="+(new Date()).getTime();
	where = areaid;
        xmlDoc.onreadystatechange = alertContents;
		xmlDoc.open( 'GET', url, true );
		xmlDoc.send(null);
		document.getElementById(C).innerHTML = "";


}

    function alertContents() {

        if (xmlDoc.readyState == 4) {
            if (xmlDoc.status == 200) {
                document.getElementById(where).innerHTML = xmlDoc.responseText;
            } else {
                alert('There was a problem with the request.');
            }
        }

    }


function reply(who){
  if (document.addComment.comment.value.length == 0)
        document.addComment.comment.value=who+': ';
  else
        document.addComment.comment.value = document.addComment.comment.value+'\n'+who+': ';
  document.addComment.comment.focus();
  return;
}


function loadRecModule(photo_id,rec_type){

	loadData(placed+'rec.php?photo_id='+photo_id+'&rec_type='+rec_type+'','RecModule','Loading'); 
	
}


function jump(SelObj){ //v3.0
  eval("parent.location='bygenre.php?index="+SelObj.options[SelObj.selectedIndex].value+"'");

}

function submit() {
	var form = document.getElementById("upload");

	if(form != null) {
		form.submit();
	}
}

function showPic(pic_name)
{ 
   	  unescape(pic_name);
      var  pic_wnd  = open("template/full_screen.htm?" + pic_name ,"","left=0,top=0,width='+winwidth+',height='+winheight+',scrollbars=auto,fullscreen=yes","titlebar=no, toolbar=no");
}

function select_menu(targ,selObj,restore){ 
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function changeBG(bg)
{

  document.body.style.background = bg;
}

 function init()
{
 var loc = location.href;
 unescape(loc);
 var pic_name = loc.substring(loc.lastIndexOf("?")+1,loc.length);
 var HTML = 
 "<table  valign='center' cellspacing='2' cellpadding='2' border='0'>"+
"<tr>"+
    "<td><IMG align='middle' src='"+pic_name+"' id='pic'></td>"+
"</tr>"+

"<table align='center' height='3' cellspacing='0' cellpadding='0' border='0' bordercolor='#000000' frame='box' rules='cols' >"+
"<tr>"+
    "<td rowspan='2' style='background:#000000;' width='16'  onmouseover='changeBG(style.background)'>&nbsp;</td>"+
	"<td rowspan='2' style='background:#121212;' width='16'  onmouseover='changeBG(style.background)'>&nbsp;</td>"+
    "<td rowspan='2' style='background:#242424;' width='16' onmouseover='changeBG(style.background)'>&nbsp;</td>"+
    "<td rowspan='2' style='background:#363636;' width='16' onmouseover='changeBG(style.background)'>&nbsp;</td>"+
	"<td rowspan='2' style='background:#484848;' width='16' onmouseover='changeBG(style.background)'>&nbsp;</td>"+
    "<td rowspan='2' style='background:#5a5a5a;' width='16'  onmouseover='changeBG(style.background)'>&nbsp;</td>"+
    "<td rowspan='2' style='background:#7e7e7e;' width='16' onmouseover='changeBG(style.background)'>&nbsp;</td>"+
    "<td rowspan='2' style='background:#909090;' width='16' onmouseover='changeBG(style.background)'>&nbsp;</td>"+
	"<td rowspan='2' style='background:#a2a2a2;' width='16' onmouseover='changeBG(style.background)'>&nbsp;</td>"+
    "<td rowspan='2' style='background:#b4b4b4;' width='16'  onmouseover='changeBG(style.background)'>&nbsp;</td>"+
    "<td rowspan='2' style='background:#c6c6c6;' width='16' onmouseover='changeBG(style.background)'>&nbsp;</td>"+
    "<td rowspan='2' style='background:#d8d8d8;' width='16'  onmouseover='changeBG(style.background)'>&nbsp;</td>"+
	"<td rowspan='2' style='background:#eaeaea;' width='16' onmouseover='changeBG(style.background)'>&nbsp;</td>"+
	"<td rowspan='2' style='background:#fcfcfc;' width='16' onmouseover='changeBG(style.background)'>&nbsp;</td>"+
    "<td rowspan='2' style='background:#ffffff;' width='16'  onmouseover='changeBG(style.background)'>&nbsp;</td>"+
	"<td><img  onmouseover='style.cursor=\"hand\";' src=\"img/close.gif\" alt=\"close\" onclick=\"window.close()\"></td>"+
"</tr>"+
"<tr>"+
"</tr>"+
"</table>"+

"</table>";

document.body.innerHTML=HTML;
}
