function genFlash(name, width, height, align)
{
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + width + '" height="' + height + '" id="' + name + '" align="' + align + '">');
    document.write('<param name="allowScriptAccess" value="sameDomain" />');
    document.write('<param name="movie" value="/flash/' + name + '" />');
    document.write('<param name="quality" value="high" />');
    document.write('<param name="bgcolor" value="#000000" />');
    document.write('<param name="salign" value="lt" />');
    document.write('<param name=wmode value="transparent" />');
    document.write('<embed src="/flash/' + name + '" quality="high" wmode=transparent bgcolor="#000000" width="' + width + '" height="' + height + '" name="' + name + '" align="' + align + '" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    document.write('</object>');
}

function flash(name, width, height, vars)
{
//document.location = '/flash/' + name + '.swf'+ vars;
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + width + '" height="' + height + '" id="' + name + '" align="middle">');
    document.write('<param name="allowScriptAccess" value="sameDomain" />');
    document.write('<param name="movie" value="/flash/' + name + '.swf'+ vars +'" />');
    document.write('<param name="quality" value="high" />');
    document.write('<param name="bgcolor" value="#000000" />');
    document.write('<param name="salign" value="lt" />');
    document.write('<param name=wmode value="transparent" />');
    document.write('<embed src="/flash/' + name + '.swf' + vars + '" quality="high" wmode=transparent bgcolor="#000000" width="' + width + '" height="' + height + '" name="' + name + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    document.write('</object>');
    //alert('hi' + name);
}

function popUp(source, width, height)
 {
	window.open(source, "popUp", "height=" + height + ",width=" + width + ",toolbar=no,scrollbars=yes,menubar=no");
}


function display(set_name) {
	hideLayer("top_menu");
	hideLayer("bottom_menu");
	
    
    showLayer("loadingBlock");
    //showLayer("displayBlock");
    
	new_location = "view?set_name=" + set_name;
	changeLocation("display", new_location);
	
	//alert("hi");
	
	
	/*if (confirm("The image pertaining to [" + id + "] would display now.\nClick OK to go back.")) {
		unDisplay();
	}*/
}

function displayChanged() {
    //alert("displayChanged");

    showLayer("displayBlock");
    hideLayer("loadingBlock");
}

function displayPerson(name) {
	hideLayer("aboutMainMenu");
	showLayer("aboutShortMenu");
	
	for (i=0; i<=people; i++) {
		if (name == persons[i]) {
			showLayer(name);
		} else {
			hideLayer(persons[i]);
		}
	}
}

function unDisplay() {
    //alert('unDisplay');

    changeLocation("display", "loading.php");
    
	hideLayer("loadingBlock");
    
	hideLayer("displayBlock");
    
    showLayer("top_menu");
    showLayer("bottom_menu");
    
	//not ready:
	//stopLayer("displayBlock");
}

function showPart(partName) {
    //alert("showPart(\"" + partName + "\");");

	showLayer(partName);
	hideAllBut(partName);
	
	indicate(partName);
	
	return false;
}

function hideAllBut(partName) {
	for (i = 0; i < parts; i++) {
		pName = "p" + i;
		if (pName != partName) {
			hideLayer(pName);
		}
	}
}


function indicate(partName) {
	h = 1;
	for (i = 0; i < parts; i++) {
		pName = "p" + i;
		bName = "b" + i;
		
		//document["b0"].src = "/images/graphics/1r.gif";
		
        if (e=document.getElementById(bName))
		    if (pName != partName) {
			    e.src = "/images/graphics/"+h+".gif";
		    } else {
			    e.src = "/images/graphics/"+h+"r.gif";
		    }
		
		h++;
	}	
}


function showLayer(layerName)
{
    //alert("showLayer('" + layerName + "')");
    
    if (document.getElementById) // Netscape 6 and IE 5+
    {
         var targetElement = document.getElementById(layerName);
         targetElement.style.display = 'block';
    } else if (parent.getElementById) {
         var targetElement = parent.getElementById(layerName);
         targetElement.style.display = 'block';   
    }
}

function hideLayer(layerName)
{
    //alert(layerName);
    if (document.getElementById)
    {
         var targetElement = document.getElementById(layerName);
         targetElement.style.display = 'none';
    } else if (parent.getElementById) {
         var targetElement = parent.getElementById(layerName);
         targetElement.style.display = 'none';   
    }
}

function stopLayer(layerName)
{
    if (document.getElementById)
    {
 var targetElement = document.getElementById(layerName);
 targetElement.location.stop();
    }
}


function changeLocation(iframeName, new_location) {
	if (document.getElementById)
	{
		var targetElement = document.getElementById(iframeName);
        //alert(targetElement.src);
        
		targetElement.src = new_location;
	}
}



//AJAX

function aj(display_id, method, url, params) {
        var xmlHttp;
        try
          {
          // Firefox, Opera 8.0+, Safari
          xmlHttp=new XMLHttpRequest();
          }
        catch (e)
          {
          // Internet Explorer
          try
            {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
            }
          catch (e)
            {
            try
              {
              xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
              }
            catch (e)
              {
              alert("Your browser does not support AJAX!");
              return false;
              }
            }
          }
          xmlHttp.onreadystatechange=function()
            {
            if(xmlHttp.readyState==4)
              {
              //show result:
                  document.getElementById(display_id).innerHTML = xmlHttp.responseText;
              }
          }
          
          if (method == "GET") {
              xmlHttp.open("GET", url +"?"+ params,true);
              xmlHttp.send(null);
          }
          
          if (method == "POST") {
                xmlHttp.open("POST", url, true);

                //Send the proper header information along with the request
                xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                xmlHttp.setRequestHeader("Content-length", params.length);
                xmlHttp.setRequestHeader("Connection", "close");
                xmlHttp.send(params);
          }
}

//END AJAX




/* cookie related */

function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
//expires = expires * 1000 * 60 * 60 * 24;
expires = expires * 1000 * 60;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}



function setScreen() {
	screenRes = screen.width + "x" + screen.height;
	Set_Cookie("CorderoRes", screenRes, 60, "/", '', '');	
}


//for screen res (do not run here)
//screenRes = screen.width + "x" + screen.height;
//Set_Cookie("CorderoRes", screenRes, 60, "/", '', '');
