function findLinkByHref(href) {
  for (var i=0; i<document.links.length; i++) {
    if (document.links[i].href == href) return i;
  }
  return -1;
}

function changeLinkHref(id,newHref,oldHref) {
   
  if (document.links.length > 0) {
    if (document.getElementById) {
      if(document.getElementById(id)){
        document.getElementById(id).href = newHref;
        }else{//alert("Link Degistirmek icin gonderilen Element Bulunamadi :" + id);
        }
    }
    else if (document.all) {
      document.all[id].href = newHref;
    }
    else {
      var index = findLinkByHref(oldHref);
      if (index > -1)
        document.links[index].href = newHref;
    }
  }
}
//changeLinkHref('myLink','http://www.irt.org','http://www.mozilla.org')





/************************************************************************************************************


************************************************************************************************************/

var camii_hutbe_slideSpeed = 5;	// Higher value = faster
var camii_hutbe_timer = 20;	// Lower value = faster

var objectIdToSlideDown = false;
var camii_hutbe_activeId = false;
var camii_hutbe_slideInProgress = false;
function showHideContent(e,inputId)
{
	if(camii_hutbe_slideInProgress)return;
	camii_hutbe_slideInProgress = true;
	if(!inputId)inputId = this.id;
	inputId = inputId + '';
	var numericId = inputId.replace(/[^0-9]/g,'');
	var answerDiv = document.getElementById('camii_hutbe_a' + numericId);

	objectIdToSlideDown = false;
	
	if(!answerDiv.style.display || answerDiv.style.display=='none'){		
		if(camii_hutbe_activeId &&  camii_hutbe_activeId!=numericId){			
			objectIdToSlideDown = numericId;
			slideContent(camii_hutbe_activeId,(camii_hutbe_slideSpeed*-1));
		}else{
			
			answerDiv.style.display='block';
			answerDiv.style.visibility = 'visible';
			
			slideContent(numericId,camii_hutbe_slideSpeed);
		}
	}else{
		slideContent(numericId,(camii_hutbe_slideSpeed*-1));
		camii_hutbe_activeId = false;
	}	
}

function slideContent(inputId,direction)
{
	
	var obj =document.getElementById('camii_hutbe_a' + inputId);
	var contentObj = document.getElementById('camii_hutbe_ac' + inputId);
	height = obj.clientHeight;
	if(height==0)height = obj.offsetHeight;
	height = height + direction;
	rerunFunction = true;
	if(height>contentObj.offsetHeight){
		height = contentObj.offsetHeight;
		rerunFunction = false;
	}
	if(height<=1){
		height = 1;
		rerunFunction = false;
	}

	obj.style.height = height + 'px';
	var topPos = height - contentObj.offsetHeight;
	if(topPos>0)topPos=0;
	contentObj.style.top = topPos + 'px';
	if(rerunFunction){
		setTimeout('slideContent(' + inputId + ',' + direction + ')',camii_hutbe_timer);
	}else{
		if(height<=1){
			obj.style.display='none'; 
			if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
				document.getElementById('camii_hutbe_a' + objectIdToSlideDown).style.display='block';
				document.getElementById('camii_hutbe_a' + objectIdToSlideDown).style.visibility='visible';
				slideContent(objectIdToSlideDown,camii_hutbe_slideSpeed);				
			}else{
				camii_hutbe_slideInProgress = false;
			}
		}else{
			camii_hutbe_activeId = inputId;
			camii_hutbe_slideInProgress = false;
		}
	}
}



function initShowHideDivs()
{
	var divs = document.getElementsByTagName('DIV');
	var divCounter = 1;
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='camii_hutbe_question'){
			divs[no].onclick = showHideContent;
			divs[no].id = 'camii_hutbe_q'+divCounter;
			var answer = divs[no].nextSibling;
			while(answer && answer.tagName!='DIV'){
				answer = answer.nextSibling;
			}
			answer.id = 'camii_hutbe_a'+divCounter;	
			contentDiv = answer.getElementsByTagName('DIV')[0];
			contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px'; 	
			contentDiv.className='camii_hutbe_answer_content';
			contentDiv.id = 'camii_hutbe_ac' + divCounter;
			answer.style.display='none';
			answer.style.height='1px';
			divCounter++;
		}		
	}	 
}




function hideelementbyid_yukleme_genel()
{
    var division1=document.getElementById('yukleme_genel');
    if(division1!= null){    division1.style.display = 'none';}
    var division2=document.getElementById('imageSlideshowHolderHolder');
    if(division2!= null){  division2.style.visibility='visible';}
    
    var division3=document.getElementById('menubar');
    if(division3!= null){ division3.style.visibility='visible';    }
}

function add1(n) { return n+1 }

function demo(f, p) {
return f(p);
}

//demo(add1, 1) == 2; // true

function hideelementbyid(indiv)
{
    var division=document.getElementById(indiv);
    division.style.display = 'none';
}
function setvisibilitybyid(indiv)
{
    var division=document.getElementById(indiv);
    division.style.visibility='visible';
}
function aa(){
var selection=document.getElementById('MessageInqtype').selectedIndex;
var division=document.getElementById(indiv);
//alert(division.style.display);
if (selection==0){
    division.style.display = 'inline';
}else{
    division.style.display = 'none';
    }
}

function addLoadEvent(func) { 
	  var oldonload = window.onload; 
	  if (typeof window.onload != 'function') { 
	    window.onload = func; 
  } else { 
    window.onload = function() { 
	      if (oldonload) { 
	        oldonload(); 
	      } 
	      func(); 
	    } 
	  } 
	} 
function addLoadEventwarg(func,id) { 
	  var oldonload = window.onload; 
	  if (typeof window.onload != 'function') { 
	    window.onload = func(id); 
  } else { 
    window.onload = function() { 
	      if (oldonload) { 
	        oldonload(); 
	      } 
	      func(id); 
	    } 
	  } 
	}	
function hideshowMessageInqtype(lang)
{
var selection=document.getElementById('MessageInqtype').selectedIndex;
var division=document.getElementById('visit');
var legend=document.getElementById('legend1');
//alert(division.style.display);
if(lang==1 || lang=='1'){
    if (selection==0){
        division.style.display = 'inline';
        legend.innerHTML="東京ジャーミイを見学する為の要約";
    }else{
        division.style.display = 'none';
        legend.innerHTML="情報要請";
        }
  

}
else if(lang==2 || lang=='2'){
  if (selection==0){
      division.style.display = 'inline';
      legend.innerHTML="Ziyaret İçin Randevu Talebi";
  }else{
      division.style.display = 'none';
      legend.innerHTML="Bilgi Edinmek İstiyorum";
      }
  }

else{
  if (selection==0){
      division.style.display = 'inline';
      legend.innerHTML="Appointment Form (Visit Tokyo Camii)";
  }else{
      division.style.display = 'none';
      legend.innerHTML="Information Request";
      }
  }
}



function hide_editpage(cnt,i)
{
    var division=document.getElementById('parag'+i);
    var division2=document.getElementById('parag'+i);
    for (j=1;j<=cnt;j++)
    {
      
        
        division2=document.getElementById('parag'+j);
        division3=document.getElementById('ok'+j);
        if(division2.style.display == 'inline'){
          division2.style.display = 'none';
          division3.src='../img/readmore.gif';
        }else{
          if(j==i){
            division2.style.display = 'inline';
            division3.src='../img/readmorecizgi.gif';
          }
        }
        /*
        
        if(j!=i){
          if(division.style.display == 'inline'){
              alert('X1X ' + i+' | '+j + ' | ' + division.style.display + ' | ' +  division2.style.display);
              division.style.display = 'none';
              
          }else{
            alert('X2X ' + i+' | '+j + ' | ' + division.style.display + ' | ' +  division2.style.display);
            division.style.display = 'inline';
            
          }
          
        }else{
            alert('X3X ' + i+' | '+j + ' | ' + division.style.display + ' | ' +  division2.style.display);
            division2.style.display = 'none';
        }
        
        */
    }
    
}	

function FCKeditor_OnComplete( editorInstance )
{
	editorInstance.Events.AttachEvent( 'OnBlur'	, FCKeditor_OnBlur ) ;
	editorInstance.Events.AttachEvent( 'OnFocus', FCKeditor_OnFocus ) ;
}

function FCKeditor_OnBlur( editorInstance )
{
	//editorInstance.ToolbarSet.Collapse() ;
}

function FCKeditor_OnFocus( editorInstance )
{
	//editorInstance.ToolbarSet.Expand() ;
}






/*--------------------------------*/




	/***********************************************************************************************/
	var menuAlignment = 'left';	// Align menu to the left or right?		
	var topMenuSpacer = 5; // Horizontal space(pixels) between the main menu items	
	var activateSubOnClick = false; // if true-> Show sub menu items on click, if false, show submenu items onmouseover
	var leftAlignSubItems = false; 	// left align sub items t
	
	var activeMenuItem = false;	// Don't change this option. It should initially be false
	var activeTabIndex = 0;	// Index of initial active tab	(0 = first tab) - If the value below is set to true, it will override this one.
	var rememberActiveTabByCookie = false;	// Set it to true if you want to be able to save active tab as cookie
	
	var MSIE = navigator.userAgent.indexOf('MSIE')>=0?true:false;
	var Opera = navigator.userAgent.indexOf('Opera')>=0?true:false;
	var navigatorVersion = navigator.appVersion.replace(/.*?MSIE ([0-9]\.[0-9]).*/g,'$1')/1;
		
	/*
	These cookie functions are downloaded from 
	http://www.mach5.com/support/analyzer/manual/html/General/CookiesJavaScript.htm
	*/	
	function Get_Cookie(name) { 
	   var start = document.cookie.indexOf(name+"="); 
	   var len = start+name.length+1; 
	   if ((!start) && (name != document.cookie.substring(0,name.length))) return null; 
	   if (start == -1) return null; 
	   var end = document.cookie.indexOf(";",len); 
	   if (end == -1) end = document.cookie.length; 
	   return unescape(document.cookie.substring(len,end)); 
	} 
	// This function has been slightly modified
	function Set_Cookie(name,value,expires,path,domain,secure) { 
		expires = expires * 60*60*24*1000;
		var today = new Date();
		var expires_date = new Date( today.getTime() + (expires) );
	    var cookieString = name + "=" +escape(value) + 
	       ( (expires) ? ";expires=" + expires_date.toGMTString() : "") + 
	       ( (path) ? ";path=" + path : "") + 
	       ( (domain) ? ";domain=" + domain : "") + 
	       ( (secure) ? ";secure" : ""); 
	    document.cookie = cookieString; 
	}	
	
	function showHide()
	{
		if(activeMenuItem){
			activeMenuItem.className = 'inactiveMenuItem'; 	
			var theId = activeMenuItem.id.replace(/[^0-9]/g,'');
			document.getElementById('submenu_'+theId).style.display='none';
			var img = activeMenuItem.getElementsByTagName('IMG');
			if(img.length>0)img[0].style.display='none';			
		}

		var img = this.getElementsByTagName('IMG');
		if(img.length>0)img[0].style.display='inline';
				
		activeMenuItem = this;		
		this.className = 'activeMenuItem';
		var theId = this.id.replace(/[^0-9]/g,'');
		document.getElementById('submenu_'+theId).style.display='block';
		

				
		if(rememberActiveTabByCookie){
			Set_Cookie('tokyocamii_tab_menu_tabIndex','index: ' + (theId-1),100);
		}
	}
	
	function initMenu()
	{
		var mainMenuObj = document.getElementById('mainMenu');
		var menuItems = mainMenuObj.getElementsByTagName('A');
		if(document.all){
			mainMenuObj.style.visibility = 'hidden';
			document.getElementById('submenu').style.visibility='hidden';
		}		
		if(rememberActiveTabByCookie){
			var cookieValue = Get_Cookie('tokyocamii_tab_menu_tabIndex') + '';
			cookieValue = cookieValue.replace(/[^0-9]/g,'');
			if(cookieValue.length>0 && cookieValue<menuItems.length){
				activeTabIndex = cookieValue/1;
			}			
		}
		
		var currentLeftPos = 15;
		for(var no=0;no<menuItems.length;no++){			
			if(activateSubOnClick)menuItems[no].onclick = showHide; else menuItems[no].onmouseover = showHide;
			menuItems[no].id = 'mainMenuItem' + (no+1);
			if(menuAlignment=='left')
				menuItems[no].style.left = currentLeftPos + 'px';
			else
				menuItems[no].style.right = currentLeftPos + 'px';
			currentLeftPos = currentLeftPos + menuItems[no].offsetWidth + topMenuSpacer; 
			
			var img = menuItems[no].getElementsByTagName('IMG');
			if(img.length>0){
				img[0].style.display='none';
				if(MSIE && !Opera && navigatorVersion<7){
					img[0].style.bottom = '-1px';
					img[0].style.right = '-1px';
				}
			}
						
			if(no==activeTabIndex){
				menuItems[no].className='activeMenuItem';
				activeMenuItem = menuItems[no];
				var img = activeMenuItem.getElementsByTagName('IMG');
				if(img.length>0)img[0].style.display='inline';	
							
			}else menuItems[no].className='inactiveMenuItem';
			if(!document.all)menuItems[no].style.bottom = '-1px';
			if(MSIE && navigatorVersion < 6)menuItems[no].style.bottom = '-2px';
			

		}		
		
		var mainMenuLinks = mainMenuObj.getElementsByTagName('A');
		
		var subCounter = 1;
		var parentWidth = mainMenuObj.offsetWidth;
		while(document.getElementById('submenu_' + subCounter)){
			var subItem = document.getElementById('submenu_' + subCounter);
			
			if(leftAlignSubItems){
				// No action
			}else{							
				var leftPos = mainMenuLinks[subCounter-1].offsetLeft;
				document.getElementById('submenu_'+subCounter).style.paddingLeft =  leftPos + 'px';
				subItem.style.position ='absolute';
				if(subItem.offsetWidth > parentWidth){
					leftPos = leftPos - Math.max(0,subItem.offsetWidth-parentWidth); 	
				}
				subItem.style.paddingLeft =  leftPos + 'px';
				subItem.style.position ='static';
					
				
			}
			if(subCounter==(activeTabIndex+1)){
				subItem.style.display='block';
			}else{
				subItem.style.display='none';
			}
			
			subCounter++;
		}
		if(document.all){
			mainMenuObj.style.visibility = 'visible';
			document.getElementById('submenu').style.visibility='visible';
		}		
		document.getElementById('submenu').style.display='block';
	}
	
	
	
	/************************************************************************************************************
	(C) www.dhtmlgoodies.com, October 2005
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	
	************************************************************************************************************/	
	// You can modify these three values
	var slideshow2_noFading = false;	// Just normal show/hide without fading ?
	var slideshow2_timeBetweenSlides = 2500;	// Amount of time between each image(1000 = 1 second)
	var slideshow2_fadingSpeed = 80;	// Speed of fading (Higher = slower)
	
	
	/* Don't change any of these values */
	var slideshow2_galleryHeigh;	// Height of galery	
	var slideshow2_galleryContainer;	// Reference to the gallery div
	var slideshow2_galleryWidth;	// Width of gallery	
	var slideshow2_slideIndex = -1;	// Index of current image shown
	var slideshow2_slideIndexNext = false;	// Index of next image shown
	var slideshow2_imageDivs = new Array();	// Array of image divs(Created dynamically)
	var slideshow2_currentOpacity = 100;	// Initial opacity
	var slideshow2_imagesInGallery = false;	// Number of images in gallery
	
	function getGalleryImageSize(imageIndex)
	{
		if(imageIndex==slideshow2_imagesInGallery){			
			showGallery();
		}else{
			var imgObj = document.getElementById('galleryImage' + imageIndex);
			var imgWidth = imgObj.width;
			var imgHeight = imgObj.height;
			if(imgWidth>50){						
				var tmpDiv = document.createElement('DIV');
				tmpDiv.id = 'galleryDiv' + imageIndex;
				tmpDiv.style.visibility = 'hidden';
				tmpDiv.className='imageInGallery';
				slideshow2_galleryContainer.appendChild(tmpDiv);
				tmpDiv.appendChild(imgObj);
				imgObj.style.left = Math.round((slideshow2_galleryWidth - imgWidth)/2)  + "px";
				imgObj.style.top = Math.round((slideshow2_galleryHeight - imgHeight)/2)  + "px";
				tmpDiv.style.visibility = 'hidden';
				slideshow2_imageDivs.push(tmpDiv);
				imageIndex++;
				getGalleryImageSize(imageIndex);
			}else{
				setTimeout('getGalleryImageSize(' + imageIndex + ')',10);
			}
		}		
	}
	
	function showGallery()
	{
		if(slideshow2_slideIndex==-1)slideshow2_slideIndex=0; else slideshow2_slideIndex++;	// Index of next image to show
		if(slideshow2_slideIndex==slideshow2_imageDivs.length)slideshow2_slideIndex=0;
		slideshow2_slideIndexNext = slideshow2_slideIndex+1;	// Index of the next next image
		if(slideshow2_slideIndexNext==slideshow2_imageDivs.length)slideshow2_slideIndexNext = 0;
		
		slideshow2_currentOpacity=100;	// Reset current opacity

		// Displaying image divs
		slideshow2_imageDivs[slideshow2_slideIndex].style.visibility = 'visible';
		if(navigator.userAgent.indexOf('Opera')<0){
			slideshow2_imageDivs[slideshow2_slideIndexNext].style.visibility = 'visible';
		}
		
		
		if(document.all){	// IE rules
			slideshow2_imageDivs[slideshow2_slideIndex].style.filter = 'alpha(opacity=100)';
			slideshow2_imageDivs[slideshow2_slideIndexNext].style.filter = 'alpha(opacity=1)';
		}else{
			slideshow2_imageDivs[slideshow2_slideIndex].style.opacity = 0.99;	// Can't use 1 and 0 because of screen flickering in FF
			slideshow2_imageDivs[slideshow2_slideIndexNext].style.opacity = 0.01;
		}		
		

		setTimeout('revealImage()',slideshow2_timeBetweenSlides);		
	}
	
	function revealImage()
	{
		if(slideshow2_noFading){
			slideshow2_imageDivs[slideshow2_slideIndex].style.visibility = 'hidden';
			showGallery();
			return;
		}
		slideshow2_currentOpacity--;
		if(document.all){
			slideshow2_imageDivs[slideshow2_slideIndex].style.filter = 'alpha(opacity='+slideshow2_currentOpacity+')';
			slideshow2_imageDivs[slideshow2_slideIndexNext].style.filter = 'alpha(opacity='+(100-slideshow2_currentOpacity)+')';
		}else{
			slideshow2_imageDivs[slideshow2_slideIndex].style.opacity = Math.max(0.01,slideshow2_currentOpacity/100);	// Can't use 1 and 0 because of screen flickering in FF
			slideshow2_imageDivs[slideshow2_slideIndexNext].style.opacity = Math.min(0.99,(1 - (slideshow2_currentOpacity/100)));
		}
		if(slideshow2_currentOpacity>0){
			setTimeout('revealImage()',slideshow2_fadingSpeed);
		}else{
			slideshow2_imageDivs[slideshow2_slideIndex].style.visibility = 'hidden';			
			showGallery();
		}
	}
	
	function initImageGallery()
	{
		slideshow2_galleryContainer = document.getElementById('imageSlideshowHolder');
		slideshow2_galleryWidth = slideshow2_galleryContainer.clientWidth;
		slideshow2_galleryHeight = slideshow2_galleryContainer.clientHeight;
		galleryImgArray = slideshow2_galleryContainer.getElementsByTagName('IMG');
		for(var no=0;no<galleryImgArray.length;no++){
			galleryImgArray[no].id = 'galleryImage' + no;
		}
		slideshow2_imagesInGallery = galleryImgArray.length;
		getGalleryImageSize(0);		
		
	}
			
	

    addLoadEvent(hideelementbyid_yukleme_genel);	
    //addLoadEvent(initMenu);
    
	