function get_cookie(name_to_get) {
var cookie_pair
var cookie_name
var cookie_value    
// Split all the cookies into an array
var cookie_array = document.cookie.split("; ")    
// Run through the cookies
for (counter = 0; counter < cookie_array.length; counter++) {   
	// Split the cookie into a name/value pair
	cookie_pair = cookie_array[counter].split("=")
	cookie_name = cookie_pair[0]
	cookie_value = cookie_pair[1]        
	// Compare the name with the name we want
	if (cookie_name == name_to_get) {       
		// If this is the one, return the value
		return unescape(cookie_value)}}
// If the cookie doesn't exist, return null
return null
}

function set_cookie(cookie_name, cookie_value, cookie_expire, cookie_path, cookie_domain, cookie_secure) {
    // Begin the cookie parameter string
    var cookie_string = cookie_name + "=" + cookie_value
    
    // Add the expiration date, if it was specified
    if (cookie_expire) {
        var expire_date = new Date()
        var ms_from_now = cookie_expire * 24 * 60 * 60 * 1000
        expire_date.setTime(expire_date.getTime() + ms_from_now)
        var expire_string = expire_date.toGMTString()
        cookie_string += "; expires=" + expire_string
    }
    
    // Add the path, if it was specified
    if (cookie_path) {
        cookie_string += "; path=" + cookie_path
    }

    // Add the domain, if it was specified
    if (cookie_domain) {
        cookie_string += "; domain=" + cookie_domain
    }
    
    // Add the secure boolean, if it's true
    if (cookie_secure) {
        cookie_string += "; true"
    }    
    // Set the cookie
    document.cookie = cookie_string
}

function radio_active(radio_group) {
    // Run through the group
    for (counter = 0; counter < radio_group.length; counter++) {    
        // When we find the activated button, return the index
        if (radio_group[counter].checked) {
            return counter}}
    // If no button is activated, return -1
    return -1
}

function Photo(Property) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open('ShowPicp.asp?Property=' + Property, + '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=300,left=0,top=0');");
}

function popUpBook(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=840,height=680,left=100,top=100');");
}

function AvailpopUp(URL) {
day = new Date();
id = day.getTime();
l = (screen.availWidth-760) / 2;
t = (screen.availHeight-20 - 474) / 2;
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=740,height=480,left = '+l+',top = '+t);");
}

function popUp(URL) {
day = new Date();
id = day.getTime();
l = (screen.availWidth-760) / 2;
t = (screen.availHeight-20 - 474) / 2;
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=760,height=520,left = '+l+',top = '+t);");
}

function popUpRates(URL) {
day = new Date();
id = day.getTime();
l = (screen.availWidth-760) / 2;
t = (screen.availHeight-20 - 474) / 2;
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=360,left='+l+',top='+t);");
}

function OpenFull(URL) {
day = new Date();
id = day.getTime();
var h=screen.availHeight
var w=screen.availWidth
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=' + screen.availWidth + ',height=' + screen.availHeight + ',left=0,top=0');");
}

function popUpfriend(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=720,height=500,left=0,top=0');");
}

function CalcpopUp() {
day = new Date();
id = day.getTime();
l = (screen.availWidth-760) / 2;
t = (screen.availHeight-20 - 474) / 2;
eval("page" + id + " = window.open('Calculator.asp', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=740,height=470,left = '+l+',top = '+t);");
}

function get_selections(current_list) {
    var selected_array = new Array()
    var current_index = 0
    for (var counter = 0; counter < current_list.options.length; counter++) {
        if (current_list.options[counter].selected) {
            selected_array[current_index] = current_list.options[counter].index
            current_index++
        }
    }
    return selected_array
}

function display_selected(current_list) {
    var chosen_ones = new Array()
    var val_sel
    chosen_ones = get_selections(current_list)
    for (counter = 0; counter < chosen_ones.length; counter++) {
        val_sel += current_list.options[chosen_ones[counter]].text
    }
    return (val_sel)
}

function display_selectedX(current_list) {
    var chosen_ones = new Array()
    chosen_ones = get_selections(current_list)
    var alert_message = "You chose the following items:\n\n"
    for (counter = 0; counter < chosen_ones.length; counter++) {
        alert_message += current_list.options[chosen_ones[counter]].text
    }
    alert(alert_message)
}

function RateLineAdd(yr, mth, mday, yr0, mth0, mday0) {
var err=0, fD, tD 
fmd=new Date()
tod=new Date()
document.forms[0].elements["Function"].value = 'Add'
fmd.setFullYear(yr.options[yr.selectedIndex].text)
fmd.setMonth(mth.options[mth.selectedIndex].index)
fmd.setDate(mday.options[mday.selectedIndex].text)
if (fmd.getDate() != (mday.selectedIndex + 1)) {err = 1; alert('From Day does not exist.')}
fD = yr.options[yr.selectedIndex].text 
if (fmd.getMonth() < 9) {fD = fD + '0'}
fD = fD + (fmd.getMonth() + 1) 
fD = fD + mday.options[mday.selectedIndex].text
tod.setFullYear(yr0.options[yr0.selectedIndex].text)
tod.setMonth(mth0.options[mth0.selectedIndex].index)
tod.setDate(mday0.options[mday0.selectedIndex].text)
if (tod.getDate() != (mday0.selectedIndex + 1)) {err = 1; alert('To Date does not exist')}
tD = yr0.options[yr0.selectedIndex].text
if (tod.getMonth() < 9) {tD = tD + '0'}
tD = tD + (tod.getMonth() + 1) 
tD = tD + mday0.options[mday0.selectedIndex].text
//alert('From:' + fD + ' To:' + tD)
if (fmd > tod) {
	alert('From date cannot be greater than to date.');
	err=1;}
if (document.forms[0].Amt.value == 0) {alert('Rate amout of zero not allowed.'); err=1 } 
if (err == 0) {document.forms[0].submit();}
}

function RateLineDelete(Startdate) {
document.forms[0].elements["Function"].value = 'Del'
	document.forms[0].elements["StartDate"].value = Startdate
    document.forms[0].submit();
}

function FormProcess(Which) {
	if (Which == 'AddnewProperty') {document.forms[0].action='AddnewProperty.asp'
		document.forms[0].submit()}
	else {
		GetTabDat()	
		if (Which == 'Availability') {document.forms[0].action='Availability.asp'}
		if (Which == 'MakeLive') {document.forms[0].action='MakeLive.asp'}
		if (Which == 'Photo') {document.forms[0].action='UploadImages.aspx'}
		if (Which == 'Dp') {document.forms[0].action='ShowProperty.asp'}
		if (Which == 'De') {document.forms[0].action='ShowExtra.asp'}
		if (Which == 'Rates') {document.forms[0].action='UpdRates.asp'}
		if (Which == 'Extra') {document.forms[0].action='Extra.asp'}
		if (Which == 'Multi') {document.forms[0].action='Multi.asp'}
		if (Which == 'Property') {document.forms[0].action='Property.asp'
			if (get_cookie('Offer') == '0') {document.forms[0].action='FProperty.asp'} 
		}		
		document.forms[0].submit();}
}

function tick() {
  var hours, minutes, seconds, ap;
  var intHours, intMinutes, intSeconds;
  var today;
  today = new Date();
  intHours = today.getHours();
  intMinutes = today.getMinutes();
  intSeconds = today.getSeconds();

  if (intHours == 0) {
     hours = "12:";
     ap = "Midnight";
  } else if (intHours < 12) { 
     hours = intHours+":";
     ap = "A.M.";
  } else if (intHours == 12) {
     hours = "12:";
     ap = "Noon";
  } else {
     intHours = intHours - 12
     hours = intHours + ":";
     ap = "P.M.";
  }

  if (intMinutes < 10) {
     minutes = "0"+intMinutes+":";
  } else {
     minutes = intMinutes+":";
  }

  if (intSeconds < 10) {
     seconds = "0"+intSeconds+" ";
  } else {
     seconds = intSeconds+" ";
  } 

  timeString = hours+minutes+seconds+ap;
  Clock.innerHTML = timeString;
  window.setTimeout("tick();", 100);
}

function updateChrs(it, numb) {
document.forms[0].Ct1.value = numb - it.value.length;
}

function updateChrs2(numb) {
document.forms[0].Ct1.value = numb - document.forms[0].TextData.value.length;
}

function Prop_Click(OptID) {
set_cookie('Property',OptID.value)
document.forms[0].elements['Property'].value = OptID.value
var tbodynode = document.getElementById("T1")
var Rows = tbodynode.childNodes.length - 1
for (var row_counter = 1; row_counter <= Rows; row_counter++) {
	if (document.forms[0].Property.value == tbodynode.childNodes[row_counter].childNodes[0].childNodes[0].nodeValue) {
  	 	document.forms[0].Offer.value =	tbodynode.childNodes[row_counter].childNodes[5].childNodes[0].nodeValue
  	 	set_cookie('Offer',tbodynode.childNodes[row_counter].childNodes[5].childNodes[0].nodeValue)
		 if (tbodynode.childNodes[row_counter].childNodes[5].childNodes[0].nodeValue == '2') {
		 document.forms[0].B2.style.visibility='visible'}
	 else {document.forms[0].B2.style.visibility='hidden'}
	 	 if (tbodynode.childNodes[row_counter].childNodes[5].childNodes[0].nodeValue == '0') {
		document.forms[0].Avaimg.style.visibility='hidden'
		document.forms[0].RR.style.visibility='hidden'}
		 else {document.forms[0].Avaimg.style.visibility='visible'
		 	document.forms[0].RR.style.visibility='visible'}		
	 break }
} // End for
}

function Own_load() {
get_cookie('Offer')
if (get_cookie('Offer') == '2') {
	document.forms[0].B2.style.visibility='visible'}
else {document.forms[0].B2.style.visibility='hidden'}
if (get_cookie('Offer') == '0') {
	document.forms[0].RR.style.visibility='hidden'
	document.forms[0].Avaimg.style.visibility='hidden'}
else {document.forms[0].RR.style.visibility='visible'
	document.forms[0].Avaimg.style.visibility='visible'}
}

function GetTabDat() {
// Retrieve Data from table
var oRow, curr_row, curr_cell;
for (curr_row = 0; curr_row < Properties.rows.length; curr_row++)
{	oRow = Properties.rows[curr_row];
	idx = radio_active(document.forms[0].PropertyNo)	
		if ((radio_active(document.forms[0].PropertyNo)+1)==curr_row) {
}}}

function Owners(fm) {
X = FrontPage_Form1_Validator(document.forms[0])
if (X == (true)) {
	if (document.forms[0].PassWord.value != document.forms[0].PassWord2.value) {alert('Passwords do not match - please reenter');}
	else  
		document.forms[0].submit();
}}

function Owners2(fm) {
	X = FrontPage_Form1_Validator(document.forms[0])
if (X == (true)) {
	if (document.forms[0].PassWord.value != document.forms[0].PassWord2.value) {alert('Passwords do not match - please reenter');}
	else
		if (document.forms[0].Accept.checked) {document.forms[0].submit();}
		else
		{alert('You must accept the terms and conditions of use to register')}
}}

function Hover1(tbl,idx,cls) {
var t,d;
if(document.getElementById)t=document.getElementById(tbl);
else t=document.all(tbl);
if(t==null)return;
if(t.getElementsByTagName)d=t.getElementsByTagName("TD");
else d=t.all.tags("TD");
if(d==null)return;if(d.length<=idx)return;d[idx].className=cls;
}

function Search1() {
//var t;
//t=document.getElementById('SE1');
//t.className='Text';
}

function P1(Picture) {
if (Picture==9) document.forms[0].action='UploadLogo.asp';
else document.forms[0].action='UploadIMage.asp';
document.forms[0].elements['Photo'].value = Picture
document.forms[0].submit()
}

function cfm() {
var sub_ok = confirm('Are you very sure ?')
if (sub_ok) {
	document.forms[0].submit()
	}
}

function VTexts(Which) {
document.forms[0].elements['Texts'].value = Which
document.forms[0].action='Texts.asp'
document.forms[0].submit()
}

function Sform_Validator(theForm)
{

  if (theForm.Property.value == "")
  {
    alert("Please enter a value for the \"Property number\" field.");
    theForm.Property.focus();
    return (false);
  }

  if (theForm.Property.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Property number\" field.");
    theForm.Property.focus();
    return (false);
  }

  var checkOK = "0123456789-";
  var checkStr = theForm.Property.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Property number\" field.");
    theForm.Property.focus();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "1"))
  {
    alert("Please enter a value greater than or equal to \"1\" in the \"Property number\" field.");
    theForm.Property.focus();
    return (false);
  }
  return (true);
}

function climate(Dept) {
day = new Date();
id = day.getTime();
l = (screen.availWidth-790) / 2;
t = (screen.availHeight-20 - 395) / 2;
eval("page" + id + " = window.open('http://www.meteofrance.com/FR/climat/tmd/' + Dept + '/zcdm24.jsp', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=790,height=395,left = '+l+',top = '+t);");
}

function GoodProp(theForm)
{

  if (theForm.Property.value == "")
  {
    alert("Please enter a value for the \"Property number\" field.");
    theForm.Property.focus();
    return (false);
  }

  if (theForm.Property.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Property number\" field.");
    theForm.Property.focus();
    return (false);
  }

  var checkOK = "0123456789-";
  var checkStr = theForm.Property.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Property number\" field.");
    theForm.Property.focus();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "1"))
  {
    alert("Please enter a value greater than or equal to \"1\" in the \"Property number\" field.");
    theForm.Property.focus();
    return (false);
  }
  return (true);
}

function notme() {
document.forms[0].elements['Email'].value = ''
set_cookie('Email', '', -1)
}

function Edt(Prop) {
document.forms[0].elements["Property"].value = Prop
document.forms[0].action='UPDPD.asp'
document.forms[0].submit();
}

function Upg(Prop, Offer) {
document.forms[0].elements["Property"].value = Prop
document.forms[0].elements["Offer"].value = Offer
document.forms[0].action='Upgrade.asp?F=1'
document.forms[0].submit();
}

function LastRec(Prop) {
document.forms[1].elements['Next'].value = 'Yes'
document.forms[1].submit();
}

function Back(Prop) {
document.forms[1].elements['Back'].value = 'Yes'
document.forms[1].submit();
}

function FormProcess2(current_form) {
current_form.Search1.value = 'Yes'
current_form.submit()
}
