/**
 * Pages present in this site:
 * Every page must set its own ID to pageID variable
 */
var pageID = 0;
var PAGE_ID_HOME = 0;
var PAGE_ID_ABOUT = 1;
var PAGE_ID_MUSIC = 2;
var PAGE_ID_MUSIC_MUSICIANS = 21;
var PAGE_ID_MUSIC_PHOTO = 22;
var PAGE_ID_MUSIC_PHOTO_NEW = 3;
var PAGE_ID_FRIENDS = 4;
var PAGE_ID_PRESS = 5;
var PAGE_ID_LINK = 6;
var PAGE_ID_COMM = 7;


/**
 * Index of photo currently displayed
 */
var indexDisplayedPhoto = 0;

/**
 * Glossary for internationalized labels.
 * Column 0: key, Column 1: Turkish, Column 2: English
 */ 
var glossary = new Array();
var LANG_TR = 1;
var LANG_EN = 2;
var lang = LANG_EN;
glossary[0] = ['home','Ana Sayfa','Home Page'];
glossary[1] = ['about','Hakkında','About'];
glossary[2] = ['music','duru Zamanlar','Times Untainted'];
glossary[3] = ['press','Basından','Press'];
glossary[4] = ['link','Bağlantılar','&nbsp;&nbsp;&nbsp;Links'];
glossary[5] = ['comm','İletişim','Contact'];
glossary[6] = ['musicians','Müzisyenler','Musicians'];
glossary[7] = ['photo','Fotoğraflar','Photographs'];
glossary[8] = ['download','Müzik İndir','Download Music'];
glossary[9] = ['siteDesc','',''];
glossary[10] = ['photoBy','Fotoğraflar: ','Photographs by '];
glossary[11] = ['prev','önceki','previous'];
glossary[12] = ['next','sonraki','next'];
glossary[13] = ['friends','diğer Zamanlar','Times Elsewhere'];



/**
 * Gets correspondent word (by key) in the language selected by user. See glossary above.
 */
function getFromGlossary(key) {
	for (i = 0; i < glossary.length; i++) {
		if (glossary[i][0] == key) {
			return glossary[i][lang];
		}
	}
}

/**
 * Returns language postfix to find the correct page. If lang is turkish nothing, if english "_en"
 */
function getLangPostfix() {
	if (lang == LANG_EN) {
		return '_en';
	} else {
		return '';
	}
}

/**
 * 
 */
function getLabelOfOtherLanguage() {
	if (lang == LANG_EN) {
		return 'Türkçe';
	} else {
		return 'English';
	}
}

/**
 * Returns page name which contains material in other language
 */
function getPageInOtherLanguage() {
	var adr = window.location.href;
	var newAdr = '';
	var dotIndex = adr.lastIndexOf('.');
	if (lang == LANG_EN) {
		// Change to Turkish
	 	newAdr = adr.substring(0, dotIndex - 3) + adr.substring(dotIndex);
	} else {
		// Change to English
		newAdr = adr.substring(0, dotIndex) + '_en' + adr.substring(dotIndex);
	}
	return newAdr;
}

/**
 * Constructs submenu (horizontal menu), if current page has a submenu
 */
function getSubmenu() {
	var menu = '';
	switch(pageID)
	{
	case PAGE_ID_MUSIC:
	//case PAGE_ID_MUSIC_DOWNLOAD:
	case PAGE_ID_MUSIC_MUSICIANS:
	case PAGE_ID_MUSIC_PHOTO:
		menu += '						<table border="0" width="300">';
		menu += '							<tr>';
		menu += '								<td width="150" align="center">	';
		menu += '									<a class="linkSmall" href="page'+PAGE_ID_MUSIC_MUSICIANS+getLangPostfix()+'.html">'+getFromGlossary('musicians')+'</a>';
		menu += '								</td>';
		//menu += '								<td width="100" align="center">';
		//menu += '									<a class="linkSmall" href="page'+PAGE_ID_MUSIC_DOWNLOAD+getLangPostfix()+'.html">'+getFromGlossary('download')+'</a>';
		//menu += '								</td>';
		menu += '								<td width="150" align="center">';
		menu += '									<a class="linkSmall" href="page'+PAGE_ID_MUSIC_PHOTO+getLangPostfix()+'.html">'+getFromGlossary('photo')+'</a>';
		menu += '								</td>';
		menu += '							</tr>';
		menu += '						</table>';
		break;
	default:
		break;
	}
	return menu;
}







/*
--- BEGIN ---
Cross browser Marquee script- © Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and Terms Of Use, visit http://www.dynamicdrive.com
Credit MUST stay intact
*/

//Specify the marquee's width (in pixels)
var marqueewidth="400px"
//Specify the marquee's height
var marqueeheight="22px"
//Specify the marquee's marquee speed (larger is faster 1-10)
var marqueespeed=1
//configure background color:
var marqueebgcolor="#000000"
//Pause marquee onMousever (0=no. 1=yes)?
var pauseit=1

//Specify the marquee's content (don't delete <nobr> tag)
//Keep all content on ONE line, and backslash any single quotations (ie: that\'s great):

var marqueecontent='<nobr><font face="Arial">Thank you for visiting <a href="http://www.dynamicdrive.com">Dynamic Drive.</a> If you find this script useful, please consider linking to us by <a href="../link.htm">click here.</a> Enjoy your stay!</font></nobr>'

////NO NEED TO EDIT BELOW THIS LINE////////////
marqueespeed=(document.all)? marqueespeed : Math.max(1, marqueespeed-1) //slow speed down by 1 for NS
var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var iedom=document.all||document.getElementById

var actualwidth=''
var cross_marquee, ns_marquee

/**
 * Ticker method
 */
function populate(){
	if (iedom){
		cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
		cross_marquee.style.left=parseInt(marqueewidth)+8+"px"
		cross_marquee.innerHTML=marqueecontent
		actualwidth=document.all? temp.offsetWidth : document.getElementById("temp").offsetWidth
	} else if (document.layers){
		ns_marquee=document.ns_marquee.document.ns_marquee2
		ns_marquee.left=parseInt(marqueewidth)+8
		ns_marquee.document.write(marqueecontent)
		ns_marquee.document.close()
		actualwidth=ns_marquee.document.width
	}
	lefttime=setInterval("scrollmarquee()",20)
}

/**
 * Ticker method
 */
function scrollmarquee(){
	if (iedom){
		if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
			cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+"px"
		else
			cross_marquee.style.left=parseInt(marqueewidth)+8+"px"
		} else if (document.layers){
			if (ns_marquee.left>(actualwidth*(-1)+8))
				ns_marquee.left-=copyspeed
			else
				ns_marquee.left=parseInt(marqueewidth)+8
		}
}

/*
--- END ---
Cross browser Marquee script- © Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and Terms Of Use, visit http://www.dynamicdrive.com
Credit MUST stay intact
*/






/**
 * Sets page header: top borders, clock menu, submenu (horizontal menu)
 */ 
 function setPageTopTemplate(_isTickerEnabled) {
	// Ticker
	var isTickerEnabled = false;
	if (arguments.length > 0) {
		isTickerEnabled = _isTickerEnabled;
	}
	
 	// Get page language
 	var adr = window.location.href;
 	var dotIndex = adr.lastIndexOf('.');
 	var strLang = adr.substring(dotIndex - 3, dotIndex);
 	if (strLang == "_en") {
 		lang = LANG_EN;
 	} else {
	 	lang = LANG_TR;
 	}
 
 	// See which page
 	var page;
 	
 	if (pageID >= 20) {
 		// Submenu page
 		page = PAGE_ID_MUSIC;
 	} else {
 		// Normal page
 		page = pageID;
 	}
 	
 	 	
 	// Write header
 	document.open();
 	
 	// Main table setting site page width
 	document.writeln('<table border="0" width="950" align="center">');
 	// Main table header row
	document.writeln('<tr>');
	document.writeln('	<td>');
		
 	document.writeln('<table border="0" style="width:100%;height:100%;">');
	document.writeln('<tr height="120">');
	document.writeln('	<td valign="center" width="220"><img src="image/borderShort.png"/></td>');
	document.writeln('	<td valign="top" align="left" width="220">');
	document.writeln('		<div style="position:relative;left:0px;top:0px;">');
	document.writeln('			<img id="menuImage" style="position:absolute;left:0px;top:10px;" src="image/kapakDaireselKesitSaat'+page+'.png"/>');
	document.writeln('			<a class="linkSmall" style="position:absolute;left:25px;top:0px;" href="page'+PAGE_ID_HOME+getLangPostfix()+'.html">'+getFromGlossary('home')+'</a>');
	document.writeln('			<a class="linkSmall" style="position:absolute;left:95px;top:15px;" href="page'+PAGE_ID_ABOUT+getLangPostfix()+'.html">'+getFromGlossary('about')+'</a>');
	document.writeln('			<a class="linkSmall" style="position:absolute;left:110px;top:37px;" href="page'+PAGE_ID_MUSIC+getLangPostfix()+'.html">'+getFromGlossary('music')+'</a>');
	document.writeln('			<a class="linkSmall" style="position:absolute;left:115px;top:62px;" href="page'+PAGE_ID_MUSIC_PHOTO_NEW+getLangPostfix()+'.html">'+getFromGlossary('photo')+'</a>');	
	document.writeln('			<a class="linkSmall" style="position:absolute;left:110px;top:89px;" href="page'+PAGE_ID_FRIENDS+getLangPostfix()+'.html">'+getFromGlossary('friends')+'</a>');
	document.writeln('			<a class="linkSmall" style="position:absolute;left:92px;top:111px;" href="page'+PAGE_ID_PRESS+getLangPostfix()+'.html">'+getFromGlossary('press')+'</a>');
	document.writeln('			<a class="linkSmall" style="position:absolute;left:30px;top:128px;" href="page'+PAGE_ID_LINK+getLangPostfix()+'.html">'+getFromGlossary('link')+'</a>');
	document.writeln('			<a class="linkSmall" style="position:absolute;left:-18px;top:111px;" href="page'+PAGE_ID_COMM+getLangPostfix()+'.html">'+getFromGlossary('comm')+'</a>');
	
	document.writeln('		</div>');
	document.writeln('		<table width="220"><tr><td></td></tr></table>');
	document.writeln('	</td>');
	document.writeln('	<td style="padding-top:0px;" valign="top" align="right" width="100%">');
				
	document.writeln('			<table border="0" align="center">');
	document.writeln('				<tr><td colspan="3" align="right"><a href="'+getPageInOtherLanguage()+'" class="linkVerySmall">'+getLabelOfOtherLanguage()+'&nbsp;&nbsp;</a></td></tr>');
	document.writeln('				<tr><td colspan="3"><img src="image/border.gif"/></td></tr>');
	document.writeln('				<tr>');
	document.writeln('					<td style="padding-top:0px;" align="center" height="23"> ');
	//document.writeln(getSubmenu());
	
	
	
	/************ TICKER BEGIN ************/

	if (isTickerEnabled == true) {
		if (iedom)
			document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+marqueecontent+'</span>')
	
		window.onload=populate
		
		if (iedom||document.layers){
			with (document){
				document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
				if (iedom){
					write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
					write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
					write('<div id="iemarquee" style="position:absolute;left:0px;top:0px"></div>')
					write('</div></div>')
				} else if (document.layers){
					write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
					write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
					write('</ilayer>')
				}
				document.write('</td></table>')
			}
		}
	}
	
	/************ TICKER END ************/
	
	document.writeln('					</td>');
	document.writeln('				</tr>');
	document.writeln('				<tr>');
	document.writeln('					<td colspan="3"><img src="image/bant.png" width="465" height="2"/></td>');
	document.writeln('				</tr>');
	document.writeln('				<tr>');
	document.writeln('					<td colspan="3" align="center" class="siteDesc">' + getFromGlossary('siteDesc') + '</td>');
	document.writeln('				</tr>');
	document.writeln('			</table>');
	document.writeln('	</td>');

	document.writeln('</tr>');
	document.writeln('</table>');
	
	// Main table header row closure
	document.writeln('		</td>');
	document.writeln('</tr>');
	
	// Main table content row
	document.writeln('<tr>');
	document.writeln('<td>');
	
	// Content division and table
	document.writeln('<div style="background-position:center center;background-repeat:no-repeat;background-attachment:fixed;background-image:url(\'image/icerikArkaplan.jpg\');">');
	document.writeln('<table border="0" style="width:100%;height:100%;">');
	document.writeln('<tr>');
		
	document.writeln('	<td style="padding-top:0px;" height="100%" width="100" valign="top" align="center">');
	document.writeln('		<img src="image/borderLeft'+page+'.jpg" />');
	document.writeln('	</td>');
		
	// Beginning of content cell
	document.writeln('	<td style="padding-top: 20px;padding-left: 50px;padding-right: 50px;" height="440" valign="top" align="center">');
 	
 	document.close();
 }
 
 /**
 * Sets page footer and closure stuff
 */ 
 function setPageBottomTemplate() {
 	// Get page language
 	var adr = window.location.href;
 	var dotIndex = adr.lastIndexOf('.');
 	var strLang = adr.substring(dotIndex - 3, dotIndex);
 	if (strLang == "_en") {
 		lang = LANG_EN;
 	} else {
	 	lang = LANG_TR;
 	}
 
 	// See which page
 	var page;
 	if (pageID >= 20) {
 		// Submenu page
 		page = PAGE_ID_MUSIC;
 	} else {
 		// Normal page
 		page = pageID;
 	}
 	 	
 	// Write header
 	document.open();
 	
 	// End of content cell
 	document.writeln('</td>');

	// Empty right column		
	document.writeln('	<td style="padding-top:35px;" width="100" height="100%" valign="bottom" align="center">');
	//document.writeln('		<img src="image/gitarD.gif" />');
	document.writeln('	</td>');
	
	// Content division and table closure
	document.writeln('</tr>');
	document.writeln('</table>');
	document.writeln('</div>');

	// Main table content row closure
	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td width="50%" align="center" class="small" style="padding-top: 30px">tanju duru  Web Sitesi  © 2007-2009&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + getFromGlossary('photoBy') + ' Burcu Yolgeçti' + '</td>');
	document.writeln('</tr>');
	document.writeln('</table>');
 	
 	 	
 	document.close();
 }
 
 
/**
 * Creates photo set where user can click thumbs to view a photo in large size.
 * Caller page must have a photoXXX.js where photo set is defined.
 */
 function showPhotoSet() {
	document.open();
	 
	document.writeln('<table border="0">');
	document.writeln('<tr>');
	document.writeln('<td >');
	document.writeln('</td>');
	document.writeln('<td align="center">');
	document.writeln('<a style="cursor:pointer;" class="small" onclick="decrementPhotoIndex();displayPhoto(indexDisplayedPhoto);">'+getFromGlossary('prev')+'</a>');
	document.writeln('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
	document.writeln('<a style="cursor:pointer;" class="small" onclick="incrementPhotoIndex();displayPhoto(indexDisplayedPhoto);">'+getFromGlossary('next')+'</a>');
	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td valign="top" width="300">');
	
	var style = "";
	for (i = 0; i < photoArray.length; i++) {
		if (i == 0) {
			style='style="cursor:pointer;border:thin solid #98dcff;"';
		} else {
			style='style="cursor:pointer;"';
		}
		document.writeln('<img id="thumb' + i + '" src="' + PHOTO_SET_URL + 'thumbs/' + photoArray[i][COLUMN_PHOTO_FILE] + 
		'" onclick="displayPhoto(' + i + ')"' + style + '/>');
	}
				
	document.writeln('</td>');
	document.writeln('<td align="center" width="420">');
	document.writeln('<img src="' + getPhotoURL(0) + '" id="imgShown"/>');
	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td>');
	document.writeln('</td>');
	document.writeln('<td align="center">');
	document.writeln('<form><input class="photoDesc" id="photoDesc" type="text" value="' + getPhotoDesc(0) + '"/></form>');
	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('</table>');
	 
	document.close();
 }
 
  /**
  * Display photo
  */
 function displayPhoto(index) {
	document.getElementById('imgShown').src=  getPhotoURL(index)
	document.getElementById('photoDesc').value= getPhotoDesc(index);
	showPhotoThumbSelected('thumb' + index);
	indexDisplayedPhoto=index;
 }
 
 /**
  * Get photo file url
  */
 function getPhotoURL (index) {
	return PHOTO_SET_URL + photoArray[index][COLUMN_PHOTO_FILE];
 }
 
 /**
  * Get photo file description
  */
 function getPhotoDesc (index) {
	return photoArray[index][COLUMN_PHOTO_DESC];
 }
 
 /**
  * Increment photo index
  */
 function incrementPhotoIndex () {
	indexDisplayedPhoto++;
	if (indexDisplayedPhoto >= photoArray.length) {
		indexDisplayedPhoto = photoArray.length-1;
	}
 }
 
  /**
  * Decrement photo index
  */
 function decrementPhotoIndex () {
	indexDisplayedPhoto--;
	if (indexDisplayedPhoto < 0) {
		indexDisplayedPhoto = 0;
	}
 }
 
 /**
  * Draws border to the thumb image clicked for displaying
  */
 function showPhotoThumbSelected (id) {
	for (i = 0; i < photoArray.length; i++) {
		document.getElementById('thumb' + i).style.border="";
	}
	document.getElementById(id).style.border="thin solid #98dcff";
 }
 
 /**
 * Gets the requested(name) parameter from url and returns it
 */
function getParameter (name) {
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp(regexS);
  var tmpURL = window.location.href;
  var results = regex.exec(tmpURL);
  if( results == null )
    return "";
  else
    return results[1];
}