// JavaScript Document
//generic AJAX initialisation
//***Author: JMAMMOUS***
//***Date: Feb 11 2009***
 var xhr;
 if (window.XMLHttpRequest)     // Object of the current windows
  { 
      xhr = new XMLHttpRequest();     // Firefox, Safari, ...
  } 
  else 
    if (window.ActiveXObject)   // ActiveX version
     {
        xhr = new ActiveXObject("MSXML2.XMLHTTP");  // Internet Explorer 
     } 
    
//****************************************************
//start your functions here

//this function cotnrols which actionFunction to call and which page to include
function actionMain(actionFunction, actionPage, displayDivName, postString) {
 actionFunction(actionPage, displayDivName, postString);
 return false;
}


function sendInfo(actionPage, displayDivName, nothing) {
	//alert('caleed' + displayDivName);
	window.frames[110].document.location.href = 'propFeed.php';
			 
 xhr.open("GET", actionPage);  
 xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
			 
			// window.frames['110'].src = 'http://www.pafilia.com';
   document.getElementById('110').src = xhr.responseText;
    //alert(xhr.responseText);
         }
    }
 
     xhr.send(null);
 //alert(xhr.responseText); 
 
}

function showRapidEnquiry(actionPage, displayDivName) {
	//alert(actionPage);
	//xhr.open("GET", actionPage);  
 	//xhr.onreadystatechange  = function()
    //{ 
        // if(xhr.readyState  == 4)
         //{
			 if(document.getElementById('villasincyprusprivate').innerHTML == '') {
			document.getElementById('villasincyprusprivate').innerHTML = document.getElementById('villarental').innerHTML;
			 }
			 document.getElementById('cyprusvillas').style.display= 'none';
   			document.getElementById('villarental').innerHTML = '<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="homeTables"><tr><td background="http://www.rentcyprus.co.uk/villasincyprus/villapooldark.png"><iframe src="' + actionPage + '" height="450" width="100%" frameborder="0" scrolling="no" allowtransparency="true">></iframe></td></tr></table>';
			//displayGroup(1);
        // }
    //}
 
    // xhr.send(null);
	
}

function showQuickEnquiry(actionPage, displayDivName) {
	//alert(actionPage);
	//xhr.open("GET", actionPage);  
 	//xhr.onreadystatechange  = function()
    //{ 
        // if(xhr.readyState  == 4)
         //{
			 //document.getElementById(displayDivName).style.display = "none";
			 
			document.getElementById(displayDivName).innerHTML = '<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="homeTables"><tr><td><iframe src="' + actionPage + '" height="570" width="100%" frameborder="0" scrolling="auto" allowtransparency="true">></iframe></td></tr></table>';
		
			//displayGroup(1);
        // }
    //}
 
    // xhr.send(null);
	
}

function restoreDiv() {
var stringVal = window.parent.document.getElementById('villasincyprusprivate').innerHTML;
window.parent.document.getElementById('villasincyprusprivate').innerHTML = '';
window.parent.document.getElementById('cyprusvillas').style.display= 'block';	
window.parent.document.getElementById('villarental').innerHTML = stringVal;	
	
}

function swapDiv(actionPage, displayDivName, nothing) {

alert(actionPage);	 
 xhr.open("GET", actionPage);  
 xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
			 
			// window.frames['110'].src = 'http://www.pafilia.com';
			document.getElementById('cyprusvillas').style.display = 'none';
			document.getElementById('luxurycyprusvillas').style.display = 'none';
   			document.getElementById('mainvillas').innerHTML = '<iframe src="' + actionPage + '" height="520" width="100%" frameborder="0" scrolling="no"></iframe>';
         }
    }
 
     xhr.send(null);
 //alert(xhr.responseText); 
 
}

/*
function addVillasToDiscussList(villaRef) {
	document.getElementById('villaList').innerHTML = 'http://www.rentcyprus.co.uk/images/loadingGif.gif';
	xhr.open("GET", 'http://www.rentcyprus.co.uk');  
 	xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
  			 document.getElementById('villaList').innerHTML = xhr.responseText;
         }
    }
 
     xhr.send(null);
 //alert(xhr.responseText); 
 
	
	//end function
}
*/



function deleteVilla(villaRef, chatID) {
	document.getElementById('discussionPoint').innerHTML = '<img src="http://www.rentcyprus.co.uk/images/loadingGif.gif" />';
	var actionPage = 'http://www.rentcyprus.co.uk/discussVillas.php?deleteVilla=1&villaRef=' + villaRef + '&chatID=' + chatID;
	xhr.open("GET", actionPage);  
 	xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
  			document.getElementById('discussionPoint').innerHTML = xhr.responseText;
         }
    }
 
     xhr.send(null);
 //alert(xhr.responseText); 
 
	
	//end function
}

function showSections(headerString, pageToLoad) {
	xhr.open("GET", pageToLoad);  
 	xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
  			doHeader(headerString);
			 document.getElementById('discussionPoint').innerHTML = xhr.responseText;
         }
    }
 
     xhr.send(null);
 //alert(xhr.responseText); 
 
	
	//end function
}


function addVillasToDiscussList(villaRef, chatID, headerString) {
	document.getElementById('discussionPoint').innerHTML = '<img src="http://www.rentcyprus.co.uk/images/loadingGif.gif" />';
	xhr.open("GET", 'http://www.rentcyprus.co.uk/discussVillas.php?villaRef=' + villaRef + '&chatID=' + chatID);  
 	xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
  			document.getElementById('mainHeader').innerHTML = '';
			document.getElementById('discussionPoint').innerHTML = xhr.responseText;
			doHeader(headerString);
         }
    }
 
     xhr.send(null);
 //alert(xhr.responseText); 
 
	
	//end function
}

function doHeader(headerString) {
	document.getElementById('discussionHeader').innerHTML = '<strong>' + headerString + '<strong>';
	
} //end function


function shrinkThisDiv(divName) {
	window.opener.animatedcollapse.hide('rapid')
	//end function
}

function createChat() {
	
var time = new Date();
	var expiry = new Date(time.getTime() + 5 * 24 * 60 * 60 * 1000); 

	var sitecid = Math.round(Math.random() * 999999 + time.getSeconds() * Math.random() * 999999 + time.getMinutes()* Math.random() * 999999);
	var j = Math.round(sitecid+Math.random()*999999*Math.random());
	var accname = "agios";
	var groupint = "0";

	var ccs_Page;
	ccs_Page = "http://ultra4.clickchatsold.com/D5/"+accname+"."+sitecid+"."+groupint+"."+j;
	return ccs_Page;
	
}
