document.onselectstart = function () { return false; } // disable user selection
document.oncontextmenu = function () { alert('- All rights reserved -\n\u00A92007 Alrov Group'); return false; } // disable user rightclick

function slctctrl(v) { // override user selection control
	document.onselectstart = function () { return v; };
}

var init = true;
function init_page(dv) { // initiate main text height as page loads or resized
	with (document.getElementById('sideImg').style) {
		if (document.getElementById('sideImgTd').offsetHeight > document.getElementById('sideImg').height) display = 'block';
		else display = 'none';
	}
	if (!dv) dv = 50;
	if (document.getElementById('mainDiv')) {
		document.getElementById('mainDiv').style.height = document.getElementById('refHeight').offsetHeight - dv;
		if (document.getElementById('ancCtrl')) with (document.getElementById('mainDiv')) style.height = offsetHeight - document.getElementById('ancCtrl').offsetHeight;
		document.getElementById('mainDiv').style.visibility = 'visible';
	}
	window.onresize = function () { init_page(dv); };
	if (init == true) with (location.href) if (indexOf('?')>=0) {
		eval(slice(indexOf('?')+1,length));
		init = false;
	}
}

var class0,v;
function chg_cls(obj) { //change navigation class on mouseover and mouseout
	with (obj) {
		v = attributes['class'].value;
		if (v.indexOf('On') < 1) {
			class0 = v;
			attributes['class'].value += 'Over';
			onmouseout = function () { attributes['class'].value = class0; }
		}
	}
}

function chg_dsp(obj,state) { //change object display status by state
  document.getElementById(obj).style.display = state;
}

function applyfx(o) { //apply effects
	if(document.all&&!window.opera) {
		with (o) {
			if (filters.revealTrans) filters.revealTrans.Apply();
			if (filters.blendTrans) filters.blendTrans.Apply();
		}
	}
}

function playfx(o) { //play effects
	if(document.all&&!window.opera) {	
		with (o) {
			if (filters.revealTrans) filters.revealTrans.Play();
			if (filters.blendTrans) filters.blendTrans.Play();
		}
	}
}

function chg_cls_fade(obj) { //change navigation class on mouseover and mouseout with fade effect
	with (obj) {
		applyfx(obj);
		chg_cls(obj);
		playfx(obj);
		onmouseout = function () {
			applyfx(obj);
			attributes['class'].value = class0;
			playfx(obj);
		}
	}
}

function chg_cls_fade1(obj0,obj1) { //change OTHER navigation class on mouseover and mouseout with fade effect
	obj1 = document.getElementById(obj1);
	with (obj1) {
		w = attributes['class'].value;
		class1 = w;
		applyfx(obj1);
		attributes['class'].value += 'Over';
		playfx(obj1);
		obj0.onmouseout = function () {
			with (obj1) {
				applyfx(obj1);
				attributes['class'].value = class1;
				playfx(obj1);
			}
		}
	}
}

function side_nav_ctrl(num) { //sidebar control
	var oc, obj = document.getElementById('sideBtn'+num), clsar = new Array ();
	for(var i=0; i<obj.cells.length; i++) {
		oc = obj.cells[i];
		clsar[i] = oc.attributes['class'].value;
		with (oc) {
			applyfx(oc);
			attributes['class'].value += 'Over';
			playfx(oc);
			obj.cells[0].onmouseout = function () {
				for(var i=0; i<obj.cells.length; i++) {
					var o = obj.cells[i];
					with (o) {
						applyfx(o);
						attributes['class'].value = clsar[i];
						playfx(o);
					}
				}
			}
		}
	}
}

var rndnum,totalimg = 15;
function randimg() {  //randomaize sidebar images
	rndnum = Math.floor((Math.random()*totalimg)+1);
	document.getElementById('sideImg').src = 'images/sidebar/'+rndnum+'.jpg';
}

// START of homepage image gallery
var curimg, totalimg0 = 12, preLoader0 = new Array();
function initgallery0() { // initiate homepage image gallery 
	curimg = Math.floor((Math.random()*totalimg0)+1);
	for (var m=0; m<totalimg0; m++) {
		preLoader0[m] = new Image;
		preLoader0[m].src = 'images/home/' + (m+1) + '.jpg'
	}
}

function presentimg() { //present homepage images
	curimg %= totalimg0;
	curimg ++;
	with (document.getElementById('mainimg')) {
		var s = preLoader0[curimg-1].src;
		if(document.all&&!window.opera) {
			filters.BlendTrans.apply();
			src = s;
			filters.BlendTrans.play();
		} else {
			src = s;
		}
	}
}

function setdelay() { //repeat present homepage images
	presentimg();
	imgdelay = setTimeout('setdelay()',4000);
}

function cleardelay() { //clear present homepage images repeat
	clearTimeout(imgdelay);
}
// END of homepage image gallery

// START of gallery image presentation
var projname = new Array(
	 'mamilla',
	 'mamillahotel',
	 'davidhotel',
	 'stradivarius',
	 'caferoyal',
	 'switzerland',
	 'france',
	 'treetop',
	 'opera',
	 'alrovtower',
	 'alrovhouse',
	 'europehouse',
	 'hasharon',
	 'ashdod'
);
var projtxt = new Array(
	'Alrov Mamilla Project. Jerusalem',
	'Mamilla Hotel. Jerusalem',
	'The David Citadel Hotel. Jerusalem',
	'Conservatorium Hotel. Amsterdam [under construction]',
	'Caf\u00E9 Royal Hotel. London [under construction]',
	'Alrov Group - Real Estate Europe - Switzerland',
	'Alrov Group - Real Estate Europe - France',
	'Alrov Towers. Tel Aviv',
	'The Opera Tower. Tel Aviv',
	'The Alrov Tower. Tel Aviv',
	'The Alrov House. Tel Aviv',
	'The Europe House. Tel Aviv',
	'Hasharon Mall. Netanya',
	'Ashdod Office Complex. Ashdod'
);
var projlnk = new Array(
	'development.html',
	'israelhotels.html?go_anchor(2)',
	'israelhotels.html',
	'europehotels.html',
	'europehotels.html?go_anchor(2)',
	'switzerland.html',
	'france.html',
	'israel.html',
	'israel.html?go_anchor(2)',
	'income.html',
	'',
	'income.html?go_anchor(4)',
	'income.html?go_anchor(5)',
	'income.html?go_anchor(3)'
);

var k2,preLoader1 = new Image();
function presentimg1(obj) { //present gallery images
	if (obj.childNodes[0]) obj = obj.childNodes[0];
	with (obj) for (k2=0; k2<imgarray.length; k2++) if (src == imgarray[k2].src) break; 
	document.getElementById('bigPicFrame').attributes['class'].value = 'spinner';
	document.getElementById('bigPic').src = 'images/spacer.gif';
	if (document.getElementById('picBack').style.display != 'block') {
		obj = document.getElementById('picBack');
		with (obj) {
			applyfx(obj);
			style.display = 'block';
			playfx(obj);
		}
		obj = document.getElementById('picFront');
		with (obj) {
			applyfx(obj);
			style.display = 'block';
			playfx(obj);
		}
	}
	preLoader1.onload = function () {
		document.getElementById('bigPicFrame').attributes['class'].value = '';
		with (document.getElementById('bigPic')) {
			var s = preLoader1.src;
			if(document.all&&!window.opera) {
				filters.BlendTrans.apply();
				src = s;
				filters.BlendTrans.play();
			} else {
				src = s;
			}
		}
		var lt,o = document.getElementById('captionTxt');
		chg_dsp('captionTxt','none');
		for (var j=0; j<projname.length; j++) if (imgname[k2] == projname[j]) break;
		with (o) {
			document.getElementById('captionTxtLt').innerHTML = projtxt[j];
			if (projlnk[j].length > 0) lt = "<a href=\""+projlnk[j]+"\" title=\"Go to project's details page\">more details</a>";
			else lt = "";
			document.getElementById('captionTxtRt').innerHTML = lt;
			applyfx(o);
			chg_dsp('captionTxt','block');
			playfx(o);
		}
		if (document.getElementById('galleryBtnPlay').style.display == 'none') imgdelay1 = setTimeout('setcurimg(1)',4000);
	};
	if (typeof(imgdelay1) != "undefined") clearTimeout(imgdelay1);
	preLoader1.src = 'images/gallery/' + imgname[k2] + '_' + imgnum[k2] + '.jpg';
}

function setcurimg(ind) { //advance/back images
	if (ind == 1) {
		k2 ++;
		if (k2 > imgarray.length-1) k2 = 0;
	} else {
		k2 --;
		if (k2 < 0) k2 = imgarray.length-1;
	}
	presentimg1(imgarray[k2]);
}

function setdelay1() { //repeat present images
	chg_dsp('galleryBtnPause','');
	chg_dsp('galleryBtnPlay','none');
	setcurimg(1);
}

function cleardelay1() { //clear present images repeat
	chg_dsp('galleryBtnPlay','');
	chg_dsp('galleryBtnPause','none');
	if (typeof(imgdelay1) != "undefined") clearTimeout(imgdelay1);
}

function hidebigpic() { //hide gallery enlarged image layers
	cleardelay1();
	document.getElementById('picFront').style.display = 'none';
	document.getElementById('picBack').style.display = 'none';
}

// END of gallery image presentation

// scroll to div code lines
speed=5;//time to loop in milliseconds
sy=40;//nr pixels srolled/loop
function go_anchor(d) { //check if div position is above or below the mainDiv scrollTop
	var md = document.getElementById('mainDiv');
	var an = document.getElementById('anc'+d);	
	if (an.offsetTop < md.scrollTop) {
		md.scrollTop -= sy;
		if (an.offsetTop >= md.scrollTop) {
			md.scrollTop = an.offsetTop;
			clearTimeout(w);
		} else var w = setTimeout('go_anchor(\'' + d + '\')',speed);
	} else {
		md.scrollTop += sy;
		if ( md.scrollTop >= (md.scrollHeight - md.offsetHeight) ) clearTimeout(w);
		else {
			if (an.offsetTop <= md.scrollTop) {
				md.scrollTop = an.offsetTop;
				clearTimeout(w);
			} else var w = setTimeout('go_anchor(\'' + d + '\')',speed);
		}
	}
} //end scroll to div code lines

// scroll to gallery code lines
var speed1=5;//time to loop in milliseconds
var sy1=10;//nr pixels srolled/loop
var d1=0;//current anchor
var r1;
var imgname = new Array();
var imgnum = new Array();
var imgarray = new Array();
function initgallery1() { //initiate gallery rows id's
	r1 = document.getElementById('galleryTbl').rows;
	for (var i=0;i<r1.length-2;i++) r1[i].id = 'anc'+i;
	imgname = new Array();
	imgnum = new Array();
	imgarray = document.getElementById('galleryTbl').getElementsByTagName('img');
	for (var j=0; j<imgarray.length; j++) {
		with (imgarray[j].src) {
			if (indexOf('\u005C')<0) var r = '/';
			else var r = '\u005C';
			var l = split(r);
			with (l[l.length-1]) {
				imgname[j] = slice(0,indexOf('_'));
				imgnum[j] = slice(indexOf('_')+1,indexOf('t.jpg'));
			}
		}
		for (var k=0; k<projname.length; k++) if (imgname[j] == projname[k]) break;
		imgarray[j].alt = projtxt[k];
	}
}

function scrollto(ind,repeat) { //define anchor's name
	if (ind == 1) {
		d1 ++;
		if (d1 == r1.length-5) {
			if (typeof(document.to) != "undefined") clearTimeout(document.to);
			chg_dsp('scrldn','none');
			chg_dsp('scrldnoff','');
		} else {
			if (document.getElementById('scrlup').style.display == 'none') {
				document.getElementById('scrlup').attributes['class'].value = 'galleryScrlUp';			
				chg_dsp('scrlup','');
				chg_dsp('scrlupoff','none');
			}
			if (repeat == 1) document.to=setTimeout('scrollto('+ind+','+repeat+')',200);
		}
	} else {
		d1 --;
		if (d1 == 0) {
			if (typeof(document.to) != "undefined") clearTimeout(document.to);
			chg_dsp('scrlup','none');
			chg_dsp('scrlupoff','');
		} else {
			if (document.getElementById('scrldn').style.display == 'none') {
				document.getElementById('scrldn').attributes['class'].value = 'galleryScrlDn';
				chg_dsp('scrldn','');
				chg_dsp('scrldnoff','none');
			}
			if (repeat == 1) document.to=setTimeout('scrollto('+ind+','+repeat+')',200);
		}
	}
	go_anchor1(d1);
}

var sc = false;
function go_anchor1(d1) { //check if div position is above or below the mainDiv1 scrollTop
	sc = true;
	var md = document.getElementById('mainDiv1');
	var an = document.getElementById('anc'+d1);
	if (an.offsetTop < md.scrollTop) {
		md.scrollTop -= sy1;
		if (an.offsetTop >= md.scrollTop) {
			md.scrollTop = an.offsetTop;
			clearTimeout(w);
			sc = false;
		} else var w = setTimeout('go_anchor1(\'' + d1 + '\')',speed1);
	} else {
		md.scrollTop += sy1;
		if ( md.scrollTop >= (md.scrollHeight - md.offsetHeight) ) {
			clearTimeout(w);
			sc = false;
		}
		else {
			if (an.offsetTop <= md.scrollTop) {
				md.scrollTop = an.offsetTop;
				clearTimeout(w);
				sc = false;
			} else var w = setTimeout('go_anchor1(\'' + d1 + '\')',speed1);
		}
	}
}

function mwheelscroll(direction) { //add mouse wheel DIV scroll support
	if (sc == false) {
		if (typeof(event) != "undefined") var e = event.wheelDelta;
		else var e = 0-direction;
		if (e > 0 && d1 > 0) scrollto(0,0);
		else if (e < 0 && d1 < r1.length-3) scrollto(1,0);
	}
}
//end scroll to gallery code lines

function openPopUpWin(obj) { //open big picture pop-up
	with (obj.childNodes[0].src) {
		if (indexOf('\u005C')<0) var r = '/';
		else var r = '\u005C';
		var l = split(r);

	}
	document.bigpic=window.open( "popup.html?images/gallery/"+l[l.length-1],"bigpicwin","LEFT=10,TOP=125,HEIGHT=1,WIDTH=1,RESIZABLE=1");
	document.bigpic.focus();
}

function openPopUpWin1(obj) { //open big map pop-up
	document.bigpic=window.open( "popup.html?images/projects/"+obj,"bigpicwin","LEFT=10,TOP=125,HEIGHT=1,WIDTH=1,RESIZABLE=1");
	document.bigpic.focus();
}

onunload = function() { if (document.bigpic!=null && !document.bigpic.closed) document.bigpic.close(); }

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 MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
