
var surl ="http://www.retirementcommunities.net/";

function jtrim(s)
{
return s.replace(/^\s+|\s+$/, '');
}

function initindex() {
var f = document.getElementById('search_loc');
f.setAttribute("autocomplete", "off");
} 

/*--------------------------------------Check Browser------------------------------------------*/

check_browser();
function check_browser()
{
	style_margin = "";
	
	var ua = navigator.userAgent.toLowerCase();
	if ( ua.indexOf( "opera" ) != -1 ) 
	{
		browserName = "opera";
	} 
	else if ( ua.indexOf( "msie" ) != -1 ) 
	{
		browserName = "msie";
		
		var nameOffset,verOffset=0,ix;
		var fullVersion  = ''+parseFloat(navigator.appVersion); 
		var majorVersion = parseInt(navigator.appVersion,10);
		var nAgt = navigator.userAgent;
		verOffset = ua.indexOf( "msie" );
		fullVersion = nAgt.substring(verOffset+5);
		// trim the fullVersion string at semicolon/space if present
		if ((ix=fullVersion.indexOf(";"))!=-1) fullVersion=fullVersion.substring(0,ix);
		if ((ix=fullVersion.indexOf(" "))!=-1) fullVersion=fullVersion.substring(0,ix);
		
		majorVersion = parseInt(''+fullVersion,10);
		if (isNaN(majorVersion)) {
		 fullVersion  = ''+parseFloat(navigator.appVersion); 
		}
		
		if(fullVersion>=8.0)
		{
			style_margin = "no margin";
		}


	} 
	else if ( ua.indexOf( "safari" ) != -1 ) 
	{
		browserName = "safari";
		style_margin = "no margin";
	} 
	else if ( ua.indexOf( "mozilla" ) != -1 ) 
	{
		if ( ua.indexOf( "firefox" ) != -1 ) 
		{
			browserName = "firefox";
		} else 
		{
			browserName = "mozilla";
		} 
	}


if(browserName!='safari' && style_margin=='')
	{
		//alert(style_margin);
		document.write('<style>.count_list a span { margin:-15px 0 0 0; }</style>');
	}
}

//----------------------------------------------------AJAX--------------------------------------------------------------------
function createRequestObject() 
	{
		var ro='';
		
		var browser = navigator.appName;
		if(browser == "Microsoft Internet Explorer")
			{
				ro = new ActiveXObject("Microsoft.XMLHTTP");
			}
		else
			{
				ro = new XMLHttpRequest();
			}
		return ro;
	}

var http = createRequestObject();

//---------------------------------------------ajax for login page username-------------------------------------------//
function validateFormAjax(txtfield)
	{
		var val=txtfield.value;
		if(jtrim(val)!="")
		{	
			document.getElementById('divMembAviRed').innerHTML ="<img src='"+surl+"templates/images/loadingsm.gif' width='16' height='16' border='0'>";
			var url =surl+'ajax_retirement.php?field='+val+'&ajaxfor=checkusername';
			http.open('get', url);
			http.onreadystatechange = handleResponsecheckusername;
			http.send(null);
		}
	}

function handleResponsecheckusername()
	{
		//alert('ters');
		if(http.readyState==4)
			{	//alert(req.status);
				if(http.status==200)
				{
					var response = '';
					response = http.responseText
					//var respone = http.responsXml;
					
					document.getElementById('divMembAviRed').innerHTML =response;
				}
			}
	}
//---------------------------------------------ajax for login page username-------------------------------------------//



//---------------------------------------------Ajax For Home Page Featured Retirement Communities-------------------------------------------//
function loading()
{
	document.getElementById('show_featured').innerHTML="<div align='center' id='no-border'><img src='"+surl+"templates/images/loading.gif' width='44' height='44' border='0' align='center'></div>";
	setTimeout("getfeatured()", 2000);
}

var featured = createRequestObject();

function getfeatured()
	{
		
		var url =surl+'ajax_retirement.php?ajaxfor=random_community';
		featured.open('get', url);
		featured.onreadystatechange = handleResponsecheckfeatured;
		featured.send(null);
		setTimeout("loading()", 8000);
	}

function handleResponsecheckfeatured()
	{
		if(featured.readyState == 4)
			{
				var response = '';
				response = featured.responseText
				//var respone = http.responsXml;
				//alert(response);
				document.getElementById('show_featured').innerHTML =response;
			}
	}
//---------------------------------------------Ajax For Home Page Featured Retirement Communities-------------------------------------------//



//-------------------------------------------------Ajax for login page City list-------------------------------------------//
var httpaddreqcity = createRequestObject();
function retloginCityajax(state)
	{
	var val= (state.value);	
	
	document.getElementById('lodingspancity').innerHTML ="<img src='"+surl+"templates/images/loadingsm.gif' width='16' height='16' border='0'>";
	//alert('test');
	var url = surl+'ajax_retirement.php?stateid='+val+'&ajaxfor=citylist';
	
	httpaddreqcity.open('get', url);
	httpaddreqcity.onreadystatechange = handleResponseddreqcity;
	httpaddreqcity.send(null);
	}

function handleResponseddreqcity()
	{
		if(httpaddreqcity.readyState == 4)
			{ 
				response1= httpaddreqcity.responseText;
				//alert(response1);
				
				document.forms['user-register'].selectCity.options.length = 0;
				document.forms['user-register'].selectCity.options[0] = new Option("---Select---","0");
				//var i=document.forms['frmaddrequirement'].selectPropertyType.options.length;
				var ajaxcitylist=response1.split(",");
				var optionlen=ajaxcitylist.length;
				for(c=0;c<optionlen-1;c++)
					{
						var optionval=ajaxcitylist[c++];
						var optiontext=ajaxcitylist[c];
						var i=document.forms['user-register'].selectCity.options.length;
						document.forms['user-register'].selectCity.options[i] = new Option(optiontext,optionval);
					}
					document.getElementById('lodingspancity').innerHTML="";
			}
			
	}

function func_get_lat_lon_ajax(val)
{
	var url =surl+'ajax_retirement.php?cityid='+val+'&ajaxfor=getlonlat';
		http.open('get', url);
		http.onreadystatechange = handleResponsechecklatlon;
		http.send(null);
}
function handleResponsechecklatlon()
	{
		if(http.readyState == 4)
			{
				var response = http.responseText;
				//var respone = http.responsXml;
				var ajaxlatlon=response.split("###");
				document.getElementById('city_lat').value =ajaxlatlon[0];
				document.getElementById('city_lon').value =ajaxlatlon[1];
			}
	}


function loadMap(){

var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());


map.setCenter(new GLatLng(document.getElementById("city_lat").value,document.getElementById("city_lon").value), 14);

	GEvent.addListener(map, "click", function(overlay, point){
	map.clearOverlays();
		if (point) {
		  
		map.addOverlay(new GMarker(point));
		map.panTo(point);
		msg = point.lat();
		msg1 = point.lng();
		document.getElementById("lat").value = msg;
		document.getElementById("long").value = msg1;
		//latlon(point.lat(),point.lng());
		
		}
	});
	
}


var map = null;
    var geocoder = null;

    function initialize() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
			map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        geocoder = new GClientGeocoder();
      }
    }

function delayfunction()
{
	setTimeout("showAddress()", 1000);
}

function showAddress(condition) {
	address = '';
	state = document.getElementById('state').value;
	city = document.getElementById('selectCity').value;
	statename = document.getElementById('state').options[document.getElementById('state').selectedIndex].text;
	cityname = document.getElementById('selectCity').options[document.getElementById('selectCity').selectedIndex].text;
	paddress = document.getElementById('comm_address').value;
	zipcode = document.getElementById('comm_zipcode').value;
	lat = document.getElementById('lat').value;
	long = document.getElementById('long').value;

	//alert(state)
	//alert(city)
	//alert(paddress)
	//alert(zipcode)
	
	//if(state!='0'&&city!='0'&&paddress!=''&&zipcode!='')
	//{
/*		if(state=='0')
		info_address = paddress+"<br/>"+cityname+", "+zipcode;
		else if(city=='0')
		info_address = paddress+"<br/>"+statename+" "+zipcode;
		else if(zipcode=='')
		info_address = paddress+"<br/>"+cityname+", "+statename;
		else
		info_address = paddress+"<br/>"+cityname+", "+statename+" "+zipcode;
		*/
		if(state!='0'&&city=='0'&&zipcode=='')
		info_address =  paddress+"<br/>"+statename;
		else if(state!='0'&&city!='0'&&zipcode=='')
		info_address =  paddress+"<br/>"+cityname+", "+statename;
		else if(state=='0'&&city=='0'&&zipcode!='')
		info_address =  paddress+"<br/>"+zipcode;
		else if (state!='0'&&city=='0'&&zipcode!='')
		info_address =  paddress+"<br/> "+statename+", "+zipcode;
		else if (state!='0'&&city!='0'&&zipcode!='')
		info_address =  paddress+"<br/>"+cityname+", "+statename+" "+zipcode;
		
		
		if(state!='0'&&city=='0'&&zipcode=='')
		address = statename;
		else if(state!='0'&&city!='0'&&zipcode=='')
		address = cityname+", "+statename;
		else if(state=='0'&&city=='0'&&zipcode!='')
		address = zipcode;
		else if (state!='0'&&city=='0'&&zipcode!='')
		address = zipcode+", "+statename;
		else if (state!='0'&&city!='0'&&zipcode!='')
		address = zipcode+", "+cityname+", "+statename;
		
		
		gaddr='';
		if(state!='0')
		gaddr = statename;
		if(city!='0')
		gaddr = gaddr+" "+cityname;
		if(zipcode!='')
		gaddr = gaddr+" "+zipcode;
		if(paddress!='')
		gaddr = gaddr+" "+paddress;
		
		//alert("show address is = "+address);
		/*
		if(condition='')
		address = zipcode+", "+paddress+", "+cityname+", "+statename;
		else
		{
			address = zipcode+", "+cityname+", "+statename;
		}*/
			 var gmarkers = [];
			  var htmls = [];
			  var i = 0;
			  var icons=[];
		   	  var point;
			  var marker
			  
		     map.clearOverlays();
			  var community = new GIcon();
			  community.image = surl+"templates/images/map-marker-orange.png";
			  community.iconSize = new GSize(20, 34);
			  community.shadowSize = new GSize(36, 34);
			  community.iconAnchor = new GPoint(5, 34);
			  community.infoWindowAnchor = new GPoint(9, 2);
			  community.infoShadowAnchor = new GPoint(15, 20);
			  
			  var icons = [];
			  icons[0] = community;
				  if (geocoder) {
					geocoder.getLatLng(
					  address,
					  function(point) {
						if (!point) {
						  	alert(address + " not found");
							return false;
						} else {
						   if(condition!='onloadmap')	
						  {
						  	map.setCenter(point, 13); 
							marker = new GMarker(point,{icon:icons[0], draggable:true, title:'Draggable'});
						 	lat = point.lat();
							long = point.lng();
						  }
						  else
						  {
						  	map.setCenter(new GLatLng(lat,long), 13);
							point = new GLatLng(lat,long);
							marker = new GMarker(point,{icon:icons[0], draggable:true, title:'Draggable'});
						 	//lat = point.lat();
							//long = point.lng();
						  }
							
						  //map.addOverlay(marker);
						  //marker.openInfoWindowHtml(address);
						  document.getElementById("lat").value = lat;
						  document.getElementById("long").value = long;
							
							map.setCenter(new GLatLng(document.getElementById("city_lat").value,document.getElementById("city_lon").value), 14);
			
							
							GEvent.addListener(marker, "dragstart", function() {
							  map.closeInfoWindow();
							});
					
							GEvent.addListener(marker, "dragend", function(overlay) {
							  point = overlay;
							  
							 
							  lat = point.lat();
							  long = point.lng();
							  document.getElementById("lat").value = lat;
							  document.getElementById("long").value = long;
							  marker.openInfoWindowHtml(info_address);
							});
							map.addOverlay(marker);

							/*GEvent.addListener(marker, "dragend", function(overlay, point){
							map.clearOverlays();
								point = overlay;
								
								if (point) {

								//map.addOverlay(new GMarker(point));
								var marker = new GMarker(point,{icon:icons[0], draggable:true, title:'Draggable'});
										lat = point.lat();
										long = point.lng();
										map.addOverlay(marker);
								map.panTo(point);
								msg = point.lat();
								msg1 = point.lng();
								alert(msg1)
								marker.openInfoWindowHtml(address);
								document.getElementById("lat").value = msg;
								document.getElementById("long").value = msg1;
								//latlon(point.lat(),point.lng());
								
								}
							});*/
						  marker.openInfoWindowHtml(info_address);
						}
					  }
					);
				  }
	/*  }
	  else
	  {
		  map.clearOverlays();
		  document.getElementById("lat").value = '';
	      document.getElementById("long").value = '';
	  }*/
    }

function show_map()
{
	if(document.getElementById("showmap").checked== true)
	{
		//alert(document.getElementById("selectCity").value);
		//alert(document.getElementById("state").value);
		
		if(document.getElementById("state").value!= '0' && document.getElementById("selectCity").value!= '0')
		{
			document.getElementById("googlemap").style.display="block";
			loadMap();
		}
		else
		{
			alert("please select state and city");
			document.getElementById("showmap").checked= false;
			document.getElementById("lat").value = '';
			document.getElementById("long").value = '';
		}
	}
	else
	{
		document.getElementById("googlemap").style.display="none";
	}
}

var httpchkcoupon = createRequestObject();
function func_check_coupon()
{
	val = document.getElementById("coupon").value;
	document.getElementById("on1").value=val;
		var url =surl+'ajax_retirement.php?coupon='+val+'&ajaxfor=chkcoupon';
		//alert(url);
			httpchkcoupon.open('get', url);
			httpchkcoupon.onreadystatechange = handleResponsecheckcoupon;
			httpchkcoupon.send(null);
}

function handleResponsecheckcoupon()
{
	if(httpchkcoupon.readyState == 4)
		{
			var response = '';
			response = httpchkcoupon.responseText;
			//alert(response);
			if(val!='')
			{
				if(response =='')
				msg = "<label style='color:#FF0000;'>Invalid Coupon</label>"
				else
				msg = "<label style='color:#669933;'>Valid Coupon</label>"
				document.getElementById('divcoupon').innerHTML = msg;
			}
			
			first_val = document.getElementById('hidden_price_option').value;
			
			discout_val = first_val-(first_val*(response)/100);
			discout_val = discout_val.toFixed(2);
			document.getElementById('price_option').innerHTML = '$'+discout_val;
			document.getElementById('amount').value = discout_val;
			document.getElementById('a3').value = discout_val;
			
		}
}

function get_duration_price(val,val2)
{
	
	document.getElementById('price_option').innerHTML = '$'+val;
	document.getElementById('hidden_price_option').value = val;
	
	dropduration = document.getElementById('duration').options[document.getElementById('duration').selectedIndex].text;
	
	
	document.getElementById('on2').value = dropduration;
	//noofmonth = dropduration.split(/ /);
	
	if(dropduration=='Monthly')
	document.getElementById('p3').value = 1;
	else if(dropduration=='Annual')
	document.getElementById('p3').value = 12;
	
	document.getElementById('t3').value = 'M';
	document.getElementById('amount').value = val;
	document.getElementById('a3').value = val;
}
function search_fields()
{
	search_key = document.getElementById('search_loc').value;
	
	if(trim(search_key)=='' || trim(search_key)=='City & State')
	{
		alert('Select Location');
		return false  // return false value to onSubmit handler
   	}
   	else 
   	{
   		return true
   	}
}
function search_keyword()
{
	search_key = document.getElementById('search_key').value;
	
	if(trim(search_key)=='' || trim(search_key)=='City & State')
	{
		alert('Enter Keyword');
		return false  // return false value to onSubmit handler
   	}
   	else 
   	{
   		return true
   	}
}
function func_search()
{
	search_key = document.getElementById('search_loc').value;
	//cityid = document.getElementById('search_loc_hidden').value;
	life_style = document.getElementById('life_style').value;
	if(trim(search_key)=='' || trim(search_key)=='City & State')
	{
		alert('Select Location');
	}
	else
	{
		search_key = search_key.split(', ')
		city_key = search_key[0].toLowerCase();
		city_key = city_key.replace(/ /g,'-');
		
		if(search_key.length<=1)
		state_key = '';
		else
		{
			state_key = search_key[1].toLowerCase();
			state_key = state_key.replace(/ /g,'-');
		}
		
		
		if(life_style!=0)
		{
			if(state_key=='')
			{
				location = surl+"search/k="+city_key+"/l="+life_style;
			}
			else
			{
				location = surl+"search/c="+city_key+"/s="+state_key+"/l="+life_style;
			}
		}
		else
		{	
			if(state_key=='')
			{
				location = surl+"search/k="+city_key;
			}
			else
			{
				location = surl+"search/c="+city_key+"/s="+state_key;
			}
		}
	}
}

function func_detail_search()
{
	state = document.getElementById('state').options[document.getElementById('state').selectedIndex].text;
	city = document.getElementById('selectCity').options[document.getElementById('selectCity').selectedIndex].text;
	search_key = document.getElementById('search_ketword').value;
	str_key_location = new Array();
	str_life_style= new Array();
	
	if(city!='---Select---')
	{
		city = city.toLowerCase();
		city = "c="+city.replace(/ /g,'-');
		str_key_location.push(city);
	}
	if(state!='---Select---')
	{
		state = state.toLowerCase();
		state = "s="+state.replace(/ /g,'-');
		str_key_location.push(state);
	}
	if(search_key!='')
	{
		search_key = search_key.toLowerCase();
		search_key = search_key.replace(/ /g,'-');
		search_key = "k="+search_key.replace(/,/g,'');
		str_key_location.push(search_key);
	}
	
	life_style = document.getElementsByTagName('input');
	
	for(chk=0;chk<life_style.length;chk++)
	{
		if(life_style[chk].type=="checkbox")
		{
			if(life_style[chk].checked==true)
			str_life_style.push(life_style[chk].value);
		}
	}
	
	if(str_key_location=='' && str_life_style=='')
		alert("Select at least one field")
	else if(str_key_location=='')
		location = surl+"search/l="+str_life_style;
	else if(str_life_style=='')
		location = surl+"search/"+str_key_location;
	else
		location = surl+"search/"+str_key_location+"/l="+str_life_style;
		
	//alert(str_life_style)
}

function processKey(e)
{
	if (null == e)
    e = window.event ;
  if (e.keyCode == 13)  {
    searchsymb() ;
  }
}
function searchsymb()
{
	search_key = document.getElementById('search_key').value;
	if(trim(search_key)=='')
	{
		alert('Enter Keyword');
	}
	else
	{
		document.frmsearch.submit();
	}
}
function mapload() 
  {
    if (GBrowserIsCompatible()) 
	{

      // arrays to hold copies of the markers and html used by the sidebar
      // because the function closure trick doesnt work there
      var gmarkers = [];
      var htmls = [];
      var i = 0;
	  var icons=[];
   
	  var community = new GIcon();
      community.image = surl+"templates/images/map-marker-orange.png";
      community.iconSize = new GSize(20, 34);
      community.shadowSize = new GSize(36, 34);
      community.iconAnchor = new GPoint(5, 34);
      community.infoWindowAnchor = new GPoint(9, 2);
      community.infoShadowAnchor = new GPoint(15, 20);
	  
	  var icons = [];
      icons[0] = community;
    
	  
  	function createMarker(point,name,html,icontype,featured,bysun) 
	{
		//alert(name);
		var marker = new GMarker(point,icons[0]);
        GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(html);
        });
	   // save the info we need to use later for the sidebar
        gmarkers[i] = marker;
        htmls[i] = html;
        // add a line to the sidebar html
	
        i++;
        return marker;
      }
	
	lat = document.getElementById('hidden_lat').value;
	long = document.getElementById('hidden_long').value;
	name = document.getElementById('hidden_name').value;
	addr = document.getElementById('hidden_address').value;
	state = document.getElementById('hidden_state').value;
	city = document.getElementById('hidden_city').value;

      // This function picks up the click and opens the corresponding info window
      function myclick(i) {
        gmarkers[i].openInfoWindowHtml(htmls[i]);
      }

      // Display the map, with some controls and set the initial location
      var map = new GMap2(document.getElementById("map"));
		
	  //alert(map);


      map.addControl(new GSmallMapControl());
      map.setCenter(new GLatLng(lat,long), 14);
      
      // Set up three markers with info windows

      var point = new GLatLng(lat,long);
      var marker = createMarker(point,'Milind','<div style="width:180px; height:80px; font-size:13px; font-family:Verdana, Arial, Helvetica, sans-serif">'+name+'<br>'+addr+'<br>'+city+', '+state+'</div>')
      map.addOverlay(marker);
      
	//map.addControl(new GScaleControl());
 	//map.addControl(new GMapTypeControl());
       

     //  ======== Add a map overview ==========
      map.addControl(new GOverviewMapControl(new GSize(120,120)));

     

    }

    // display a warning if the browser was not compatible
    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }
}	
function func_clrall()
{

	document.getElementById('search_loc').value='';
	document.getElementById('search_loc_hidden').value='';
}

var httpfreeactive = createRequestObject();
function chk_listing(val)
{
	var duration = document.getElementById('duration').value;
	
	if(duration == "" || duration == 0)  //if field is left empty
	{
  	 alert("Please Select Listing option")
	 return false  // return false value to onSubmit handler
    }
   else 
   {
	  var price = document.getElementById('amount').value;
	  
	   if(price<=0.00)
	   {
		   
		   	var coupon = document.getElementById("coupon").value;
			
		   var dropduration = document.getElementById('duration').options[document.getElementById('duration').selectedIndex].text;
		   var priorityid =  document.getElementById('custom').value;
			
			if(dropduration=='Monthly')
			var dbduration = "1 M";
			else if(dropduration=='Annual')
			var dbduration = "12 M";
	
	
		  var url =surl+'ajax_retirement.php?ajaxfor=freeactive&cid='+val+'&dur='+dbduration+'&pid='+priorityid+'&coup='+coupon;
			httpfreeactive.open('get', url, true);
			httpfreeactive.onreadystatechange = handleResponsefreeactive;
			httpfreeactive.send(null);
		
		   	
	   }
	   else
   return true
   }
}
function handleResponsefreeactive()
{
		if(httpfreeactive.readyState == 4)
		{
			//alert('test');
			
			location.href = surl+"mycommunities";
			return false;
			
		}
}


function assign_val()
{
	if(document.getElementById('terms').checked==true)
	{
			document.getElementById('terms').value=1
	}
	else
	{
			document.getElementById('terms').value=0
	}
}
function func_advertise(val)
{
	document.getElementById('adv_type').value=val;
	document.frmadvertise.submit();
	
}


/*------------------check Comunity availality--------------------------*/
var httpavailable = createRequestObject();
function checkavailablecommunity(val)
{
	document.getElementById('show_other_community').innerHTML ="<img src='"+surl+"templates/images/loadingsm.gif' width='16' height='16' border='0'>";
	var url =surl+'searchcom.php?comname='+val;
	//document.write(url);
		httpavailable.open('get', url, true);
		httpavailable.onreadystatechange = handleResponsecheckcommunity;
		httpavailable.send(null);
}

function handleResponsecheckcommunity()
{
	if(httpavailable.readyState == 4)
		{
			var response = '';
			response = httpavailable.responseText
			
			document.getElementById('show_other_community').innerHTML =response;
			
		}
}

/***** Listing Picture *****/

function slide_setting(){

  slide = document.getElementById('pic');

  slide.src = imgAr1[0];

  slide.setAttribute("width",width);

  slide.setAttribute("height",height);

}



function slide_prev(){

  if(picture > 0 ){

    picture=picture-1;

    slide.src = imgAr1[picture];

    document.getElementById("picNum").innerHTML = picture+1;

  } else {

    picture=imgAr1.length-1;

    slide.src = imgAr1[picture];

    document.getElementById("picNum").innerHTML = picture+1;

  }

}



function slide_next(){

  if(picture < imgAr1.length-1){

    picture=picture+1;

    slide.src = imgAr1[picture];

    document.getElementById("picNum").innerHTML = picture+1;

  } else {

    picture=0;

    slide.src = imgAr1[picture];

    document.getElementById("picNum").innerHTML = picture+1;

  }

}



function slide_start(){

  slide.src = imgAr1[0];

  picture = 0;

  document.getElementById("picNum").innerHTML = picture+1;

}



function slide_end(){

  slide.src = imgAr1[imgAr1.length-1];

  picture = imgAr1.length-1

  document.getElementById("picNum").innerHTML = picture+1;

}

/*--------------------------Font Increase----------------------------------*/
function changeFontSize(inc)
{
  var p = document.getElementsByTagName('div');
    for(n=0; n<p.length; n++) {
	 if(p[n].id!='colortab')
	 {
		if(p[n].style.fontSize) {
		   var size = parseInt(p[n].style.fontSize.replace("px", ""));
		} else {
		   var size = 12;
		}
		p[n].style.fontSize = size+inc + 'px'; 
	}
   }
}


/*------------------Downgrade to basic--------------------------*/
var httpdowngrade = createRequestObject();
function unsubscribe(val1, val2)
{
	var url =surl+'ajax_retirement.php?cid='+val1+'&action='+val2+'&ajaxfor=downgrade';
	//document.write(url);
		httpdowngrade.open('get', url, true);
		httpdowngrade.onreadystatechange = handleResponsedowngrade;
		httpdowngrade.send(null);
}

function handleResponsedowngrade()
{
	if(httpdowngrade.readyState == 4)
		{
			var response = '';
			response = httpdowngrade.responseText
			if(response=='paypal')
			location.href="https://www.paypal.com/cgi-bin/webscr?cmd=_subscr-find&alias=BBMKJQYCCM68N";
			else
			location.href=surl+"mycommunities";
		}
}

/*------------------3rd party code include in to detail page--------------------------
var httpdetail = createRequestObject();

function get_ajax_blocks(val)
{
	document.getElementById('image_ad').innerHTML ="<img src='"+surl+"templates/images/loadingsm.gif' width='16' height='16' border='0'>";
	document.getElementById('text_ad').innerHTML ="<img src='"+surl+"templates/images/loadingsm.gif' width='16' height='16' border='0'>";
	var url =surl+'ajax_retirement.php?field='+val+'&ajaxfor=thirdparty';
	
		httpdetail.open('get', url, true);
		httpdetail.onreadystatechange = handleResponsecheckcoupon;
		httpdetail.send(null);
}

function handleResponsecheckcoupon()
{
	if(httpdetail.readyState == 4)
		{
			var response = '';
			response = httpdetail.responseText
			
			var ajaxdetailfields=response.split("###");
			alert(ajaxdetailfields[0]);
			document.getElementById('image_ad').innerHTML =ajaxdetailfields[0];
			document.getElementById('text_ad').innerHTML =ajaxdetailfields[1];
			
		}
}

*/



/*---------------Ajax Send Move------------------------------
var sendmoveobj = createRequestObject();

function sendmove(val)
	{
		//sendmoveobj = Server.CreateObject("MSXML2.ServerXMLHTTP");
		
		var url ="http://gen.moving.com/movers/request-leads.asp?"+val;
		
		sendmoveobj.open('get', url, true);
		sendmoveobj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		
		sendmoveobj.onreadystatechange = handleResponsegetmovemsg;
		sendmoveobj.send(null);
	}

function handleResponsegetmovemsg()
	{
		if(sendmoveobj.readyState == 4)
			{
				var response = '';
				response = sendmoveobj.responseText;
				subresponse = response.substr(6);
				splitresponce = response.split(/ /);
				//var respone = http.responsXml;
				errorcode = Number(jtrim(splitresponce[1]));
				
				switch(errorcode)
				{
				case 101: sReturn = "Missing First Name"; break;
				case 102: sReturn = "Missing Last Name"; break;
				case 201: sReturn = "Missing or invalid Email Address"; break;
				case 202: sReturn = "No valid phone number provided"; break;
				case 206: sReturn = "Missing or invalid Best Time To Call"; break;
				case 207: sReturn = "Missing or invalid response to Can We Contact You at Work"; break;
				case 208: sReturn = "Missing home, work, or mobile phone number"; break;
				case 210: sReturn = "Invalid area code"; break;
				case 301: sReturn = "Missing or invalid Move Type"; break;
				case 302: sReturn = "Missing or invalid Move Date"; break;
				case 303: sReturn = "Missing or invalid Move Size"; break;
				case 304: sReturn = "Over 6 months until move date"; break;
				case 305: sReturn = "No Intrastate move with self-service moves"; break;
				case 306: sReturn = "Invalid move date (move date in the past)"; break;
				case 307: sReturn = "Move date empty"; break;
				case 401: sReturn = "Missing or invalid From Zip"; break;
				case 402: sReturn = "Missing From country"; break;
				case 403: sReturn = "Unrecognized From country"; break;
				case 501: sReturn = "Missing moving To location"; break;
				case 502: sReturn = "Invalid To City value"; break;
				case 503: sReturn = "Invalid To State value"; break;
				case 504: sReturn = "Missing To country"; break;
				case 505: sReturn = "Unrecognized To country"; break;
				case 601: sReturn = "Missing Vehicle Information"; break;
				case 602: sReturn = "Invalid Vehicle Information"; break;
				case 801: sReturn = "Error sending lead"; break;
				case 900: sReturn = "Invalid SiteID"; break;
				default:  sReturn = "Your lead request was successfully submitted.";
				}
				document.getElementById('return_message').innerHTML =sReturn;
			}
	}
*/