
var imauto = 1;
var currimage = 0;

function slideControl() {
	if (imauto == 0) {
		autoImage(currimage);
		imauto = 1;
		document.getElementById('slidecontrol').innerHTML = 'Pause';
		}
	else {
		imauto = 0;
		document.getElementById('slidecontrol').innerHTML = 'Play';
		}
	}

function newImaGo(src) {
	imauto =0;
	newImaThemeGo(src);
	document.getElementById('slidecontrol').innerHTML = 'Play';
	}
function newImaThemeGo(src) {
	var newsrc =src;
	currimage = newsrc;
	src = 'images/th0' +src+'.jpg';
	opacity('prima', 100, 0, 200);
	setTimeout("document.getElementById('prima').src='"+src+"';",200)
	setTimeout("opacity('prima', 0, 100, 200);",200);
	}

function autoImage(src) {
	if (!src) {var src=imast -1}
	src = src*1;
	src = src+1;
	if (src > imaend) {src=imast}
	if (src < imast) {src=imast}
	setTimeout("newImaTheme("+src+");",5000);
	
	}



function newImaTheme(src) {
	if (imauto == 1) {
		var newsrc =src;
		src = 'images/th0' +src+'.jpg';
		opacity('prima', 100, 0, 200);
		setTimeout("document.getElementById('prima').src='"+src+"';",200)
		setTimeout("opacity('prima', 0, 100, 200);",200);
		autoImage(newsrc);
		}
	}


function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 

function shiftOpacity(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
    if(document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 100, millisec);
    } else {
        opacity(id, 100, 0, millisec);
    }
} 




   function makeRequest(url, params, typos) {
	var params = params;
	if (!url) {document.getElementById(params).innerHTML = ""; return;}
	var randomnumber=Math.floor(Math.random()*101);
	if (url.indexOf('=')!=-1){url = url + "&noc2=" + randomnumber;}
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }


      http_request.onreadystatechange = function() { alertContents(params,typos); };
      http_request.open('GET', url, true);
      http_request.send(null);

   }




function alertContents(par,typ) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			//alert(http_request.responseText);
			result = http_request.responseText;
			if (typ=="img"){
				document.getElementById(par).innerHTML = "<img src=\""+ result+"\" border=0>";}
			else{document.getElementById(par).innerHTML = result;}
		} else {
			alert('There was a problem with the request.\n' + par);
		}
      }
   }











  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  var scrOfX = 0;
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
//  return [ scrOfX, scrOfY ];



function Start(page,ima) {

if (!page) {
	document.getElementById('vipic').innerHTML =  '';
	document.getElementById('vipic').style.width =  0;
	document.getElementById('vipic').style.height = 0;
	document.getElementById('vipic').style.top = 0;
	document.body.style.overflow = 'auto';
	}
else {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }


  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
	var vi='';
	document.body.style.overflow = 'hidden';


		w = myWidth *1;
		h = scrOfY *1;
		hc = myHeight*1;

	document.getElementById('vipic').style.width =  w+'px';
	document.getElementById('vipic').style.height = hc+'px';
	document.getElementById('vipic').style.top = h+'px';

	vi += "<table height=100% width=100%><tr><td align=center title=\"Click to resume\"><table cellpadding=6 cellspacing=0 border=0><tr><td bgcolor=\"#ffffff\" colspan=2><img src=\"";
	vi += page;
	vi += "\" border=0 id=startpicshow></td></tr>";
	vi += "<tr><td class=btr11 align=left>&copy;kastriproperties.com "+ima;
	vi += "</td><td align=right class=btr11>Click to go back</td></tr></table></td></tr></table>";
	document.getElementById('vipic').innerHTML =  vi;
	document.getElementById('startpicshow').onload=function(){
		if (document.getElementById('startpicshow').width > w){document.body.style.overflow = 'auto';}
		if (document.getElementById('startpicshow').height > hc){document.body.style.overflow = 'auto';}
 		//document.getElementById('vipic').innerHTML += 'ola'+document.getElementById('startpicshow').height+'<br>';
		}
	}
   }











