// JavaScript Document
var flashId="claim";

function flashobj(flashId)
{
  if (navigator.appName.indexOf("Microsoft") !=-1)
  {
    return window[flashId]
  }
  else
  {
    return document[flashId]
  }
}

function setFlashVar(flash_variable, flash_value)
{
  flashobj(flashId).SetVariable(flash_variable, flash_value);
}



function showFrontEditor(status,url)
{
	if(url)document.getElementById("frontadmin-iframe").src=url;
	document.getElementById("frontadmin-editor").style.display=status;
	
}
function showFrontadmin(status)
{
	document.getElementById("frontadmin-content").style.display=status;
}

var popUpWin=1;

function popUpWindow(URLStr, left, top, width, height)

{

  if(popUpWin)

  {

  //  if(!popUpWin.closed) popUpWin.close();

  }

  popUpWin = window.open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}
function winopen(url,fenstername,breite,hoehe) {
      window.open(
				  url,
				  fenstername,
				  "width = "+breite+",height ="+hoehe+"status = no,toolbar = no,menubar = no,location = no,resizable = no,titlebar = no ,scrollbars = auto,fullscreen =no");
} 

function showContent(nav_id,activate)
{
	if(act)document.getElementById(act).className="link";
	document.getElementById(activate).className="active";
	document.getElementById("content").innerHTML=contents[nav_id];
	
	act=activate;
	//return activate;
}

function showClaim(nav_id)
{
/*	claim=mainClaims[nav_id];
	subclaim=subClaims[nav_id];
*/
	flashobj("claim");
	setFlashVar('claim', mainClaims[nav_id]);
	setFlashVar('subclaim',subClaims[nav_id] );
	
	//document.write("HAAAAAAAAAAAAAAAAAAAAAAAA");
	  //movieObj
	
	//movieObj.src="file_manager/flash/claims.swf?claim="+claim+"&subclaim="+subclaim;
	
}
function updateBackBtn(nav_id, prev_nr, filename)
{
	if(prev_nr >= 0)
	{
		back_url="javascript:showContent("+subnav_ids[prev_nr]+",'sub_"+subnav_ids[prev_nr]+"');";
		back_url += "showClaim("+subnav_ids[prev_nr]+");";
		back_url += "updateWeiterBtn("+subnav_ids[prev_nr+1]+","+(prev_nr+1)+" , "+0+");";
		back_url += "updateBackBtn("+subnav_ids[prev_nr]+","+(prev_nr-1)+" , "+0+");";
	}
	else back_url= "projekte.1.106.php";
//	if(next_nr>=subnav_ids.length+1 || (!nav_id && !next_nr))
	if(filename)back_url= filename;
	
	//weiter_url="javascript:showContent("+nav_id+",'sub_"+nav_id+"');showClaim("+nav_id+");updateWeiterBtn(0,0,'"+filename+"')";
	//if(filename) weiter_url=filename;
	//else weiter_url=;
//	document.getElementById("weiterBtn").innerHTML=next_nr;
	document.getElementById("backBtn").href=back_url;
	subnavActive=prev_nr;
	//document.write()
}

function updateWeiterBtn(nav_id, next_nr, filename)
{
	if(nav_id)
	{
		weiter_url="javascript:";
		weiter_url += "showContent("+nav_id+",'sub_"+nav_id+"');";
		weiter_url += "showClaim("+nav_id+");";
		weiter_url += "updateWeiterBtn("+subnav_ids[next_nr]+","+(next_nr+1)+" , "+0+");";
		weiter_url += "updateBackBtn("+subnav_ids[next_nr-2]+","+(next_nr-2)+" , "+0+");";
	}
	else weiter_url= "awards.1.108.php";
//	if(next_nr>=subnav_ids.length+1 || (!nav_id && !next_nr))
	if(filename)weiter_url= filename;
	
	//weiter_url="javascript:showContent("+nav_id+",'sub_"+nav_id+"');showClaim("+nav_id+");updateWeiterBtn(0,0,'"+filename+"')";
	//if(filename) weiter_url=filename;
	//else weiter_url=;
//	document.getElementById("weiterBtn").innerHTML=next_nr;
	document.getElementById("weiterBtn").href=weiter_url;
	subnavActive=next_nr;
	//document.write()
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


function getScreensize()
{
	//var breite=	window.width;
	//var hoehe=screen.height;
	//return hoehe;
}

function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
/*    if (currentColor.indexOf("rgb") >= 0)
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }
*/
    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // Garvin: deactivated onclick marking of the checkbox because it's also executed
            // when an action (like edit/delete) on a single item is performed. Then the checkbox
            // would get deactived, even though we need it activated. Maybe there is a way
            // to detect if the row was clicked, and not an item therein...
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function

