// Special image maintenance definitions
// (C) Netwise-Praksis 2001
// Version: 1.02
//  1.01 --> 1.02: Added support for refresh on pages other than "content.htm"

// Category page titles
var cat_titles = new Array("İç Mimari | Interior Design",		// 1
                           "Mimari | Architecture",				// 2
                           "Kapaklar | Covers",					// 3
                           "Masa Üstü | Still Life",			// 4
                           "Reklamlar | Ads",					// 5
                           "Portreler | Portraits",				// 6
                           "Siyah-Beyaz | Black & White",		// 7
                           "Çeşitli | Miscellaneous"			// 8
                          );

// Category folder names
var cat_folders = new Array("interiors",
                            "architecture",
                            "covers",
                            "still_life",
                            "ads",
                            "portraits",
                            "bwportraits",
                            "misc"
                           );

// Category last picture#
var cat_maxfiles = new Array(16,	// interiors
                             12,	// architecture
                             13,	// covers
                             9,		// still_life
                             8,		// ads
                             11,	// portraits
                             8,		// bwportraits
                             6		// misc
                            );

var current_category = 0;
var current_image = 0;

function NP_ShowImage(i, cc) {
 var o, istr, s1, s2;

 if( cc > 10 ) cc -= 10;	// Handle English
 o = window.top.mainFrame.document;
 istr = new String("") + i;
 if( istr.length < 2 ) istr = "0" + istr;
 s1 = "/images/" + window.top.cat_folders[cc - 1] + "/" + istr + ".jpg";
 if( o.getElementById ) {
  // Due to an IE bug, defer execution
  window.top.mainFrame.setTimeout("window.top.mainFrame.document.getElementById('imgCurrent').src = '" + s1 + "'", 50, "JavaScript")
 }
 else {
  // Due to an IE bug, defer execution
  window.top.mainFrame.setTimeout("window.top.mainFrame.document.all('imgCurrent').src = '" + s1 + "'", 50, "JavaScript")
 }
 o = window.top.mainFrame.document;
 s1 = window.top.cat_titles[cc - 1];
 s2 = window.top.cat_maxfiles[cc - 1];
 if( o.getElementById ) {
  o.getElementById("spnCatTitle").innerHTML = s1;
  o.getElementById("spnImgPos").innerHTML = i + "/" + s2
 }
 else {
  o.all("spnCatTitle").innerHTML = s1;
  o.all("spnImgPos").innerHTML = i + "/" + s2
 }
}	// NP_ShowImage()

function NP_NextImage() {
 var i, cc;

 i = window.top.current_image;
 cc = window.top.current_category;
 i = i + 1;
 if( i > window.top.cat_maxfiles[cc - 1] ) return;

 window.top.current_image = i;
 NP_ShowImage(i, cc)
}	// NP_NextImage()

function NP_FindObj(d, nm) {
 var o;

 o = null;
 if( d.getElementById )
  o = d.getElementById(nm);
 else
  o = d.all(nm);
 return( o )
}	// NP_FindObj()

function NP_HiliteOn(rw) {
 var s2, s1, o;

 rw.className = "cellon";
 s2 = "";
 s1 = rw.id;
 if( "row" == s1.substr(0, 3) ) s2 = s1.substr(3);
 if( s2.length > 0 ) {
  o = NP_FindObj(window.top.leftFrame.document, "imgArrow" + s2);
  o.src = "/images/arrow.gif"
 }
 return
}	// NP_HiliteOn()

function NP_HiliteOff(rw) {
 var s2, s1, o;

 rw.className = "cell";
 s2 = "";
 s1 = rw.id;
 if( "row" == s1.substr(0, 3) ) s2 = s1.substr(3);
 if( s2.length > 0 ) {
  o = NP_FindObj(window.top.leftFrame.document, "imgArrow" + s2);
  o.src = "/images/spacer.gif"
 }
 return
}	// NP_HiliteOff()

function NP_PrevImage() {
 var i, cc;

 i = window.top.current_image;
 cc = window.top.current_category;
 i = i - 1;
 if( i < 1 ) return;

 window.top.current_image = i;
 NP_ShowImage(i, cc)
}	// NP_PrevImage()

function NP_SelectContent(new_category) {
 var o, old_cat, s1, s2;

 old_cat = window.top.current_category;
 // Turn old selection off in any case
 o = window.top.leftFrame.document;
 if( old_cat != new_category && old_cat > 0 ) {
  s1 = "row" + old_cat;
  // Due to an IE bug, defer execution
  if( o.getElementById )
   s2 = "NP_HiliteOff(window.top.leftFrame.document.getElementById('" + s1 + "'))";
  else
   s2 = "NP_HiliteOff(window.top.leftFrame.document.all('" + s1 + "'))";
  window.top.setTimeout(s2, 10, "JavaScript")
 }
 // If new category is a new HTML page, just set and return
 if( new_category < 1 || new_category > 20 ) {
  window.top.current_category = new_category;
  // Turn new selection on
  o = window.top.leftFrame.document;
  s1 = "row" + new_category;
  // Due to an IE bug, defer execution
  if( o.getElementById )
   s2 = "NP_HiliteOn(window.top.leftFrame.document.getElementById('" + s1 + "'))";
  else
   s2 = "NP_HiliteOn(window.top.leftFrame.document.all('" + s1 + "'))";
  window.top.setTimeout(s2, 20, "JavaScript")
  return(true)
 }

 // If "mainFrame" not loaded, load it
 if( old_cat > 20 ) {
  window.top.current_category = new_category;
  window.top.open("/content.htm", "mainFrame");
  return(false)
 }

 window.top.current_image = 1;
 window.top.current_category = new_category;
 NP_ShowImage(1, new_category);
 // Turn new selection on
 o = window.top.leftFrame.document;
 s1 = "row" + new_category;
 // Due to an IE bug, defer execution
 if( o.getElementById )
  s2 = "NP_HiliteOn(window.top.leftFrame.document.getElementById('" + s1 + "'))";
 else
  s2 = "NP_HiliteOn(window.top.leftFrame.document.all('" + s1 + "'))";
 window.top.setTimeout(s2, 20, "JavaScript")
 return(false)
}	// NP_SelectContent()

function NP_OverCat(rw) {
 NP_HiliteOn(rw)
}	// NP_OverCat()

function NP_OutCat(rw) {
 var s1, i1;
 
 i1 = -1;
 s1 = rw.id;
 if( "row" == s1.substr(0, 3) ) i1 = s1.substr(3);
 if( i1 == window.top.current_category )
  NP_HiliteOn(rw);
 else
  NP_HiliteOff(rw)
}	// NP_OutCat()

