// JavaScript Document

/**********************
* GOOGLE MAP
**********************/
// Ajax function to get the event window upon clicking on a marker
var receiveReq = setAjaxObject();

//the google map object
var map;

//array of markers so we can keep track of which to remove
var marks = new Array();

// tableau des icones
var icons = new Array();

//is the a fetch in progress?
var running = false;

//the ajax request object
var request;

//these are for zoomin optimization (if prev zoom had all markers then no need to load them again for zooming in)
var prevZoom = 20;
var shownall = false;
var sentBounds = '';

function map_load() {
	Custom.init();
	
	if (GBrowserIsCompatible()) {
		container = document.getElementById("ggmap");
		map_resize();

		map = new GMap2(container, {draggableCursor:"crosshair"});
		map.setCenter(centerPoint, zoom);
		map.addControl(new GScaleControl());
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());

		// Create our "tiny" marker icon 
		create_icons();
		
		// Update map listener, and initial update map
		GEvent.addListener(map, "moveend", function() { update_map(); });
		GEvent.addListener(map, "zoomend", function() { update_map(); });
		update_map();

	}
}

function map_resize() {
	container.style.width = (document.body.clientWidth > 0 ? document.body.clientWidth : document.body.offsetWidth) - 380 + 'px';
	// alert(document.body.clientHeight);
	var windowheight = getWindowHeight();
	// 700 = 600 (adsense) + 10 (p padding) + 5+5 (droite padding) + 80 statistiques
	// 100 = 70 (header)  + 30 (pied)
	container.style.height = ((windowheight > 800)?windowheight-200:630)  + 'px'; 
	if (map) {
		map.checkResize();
	}
}


// Fonction retournant la hauteur de la fenetre, quel que soit le browser
function getWindowHeight() {
    var windowHeight=0;
    if (typeof(window.innerHeight)=='number') {
        windowHeight=window.innerHeight;
    }
    else {
     if (document.documentElement&&
       document.documentElement.clientHeight) {
         windowHeight = document.documentElement.clientHeight;
    }
    else {
     if (document.body&&document.body.clientHeight) {
         windowHeight=document.body.clientHeight;
      }
     }
    }
    return windowHeight;
}

// function that initialises the icons
function create_icons() {
	// Définition d'une icone
	icons["appartement"] = new GIcon(); 
	icons["appartement"].image = "/images/gg_map/appartement.png"; 
	icons["appartement"].shadow = "/images/gg_map/appartement_shadow.png"; 
	icons["appartement"].iconSize = new GSize(25, 25); 
	icons["appartement"].shadowSize = new GSize(55, 25); 
	icons["appartement"].iconAnchor = new GPoint(12, 25); 
	icons["appartement"].infoWindowAnchor = new GPoint(5, 1); 
	icons["appartement"].imageMap = [0,25,25,25,25,0,0,0]; 
	icons["appartement"].transparent = "/images/gg_map/mm_20_transparent.png";
	
	// Définition des autres icones en fonction de la première
	get_icon('maison');
	get_icon('parking');
	get_icon('commerce');
	get_icon('interrogation');
}

function get_icon(icon) {
   if ((typeof(icon)=="undefined") || (icon==null)) { 
	  icon = "appartement"; 
   }
   if (!icons[icon]) {
	  icons[icon] = new GIcon(icons["appartement"]);
	  icons[icon].image = "/images/gg_map/"+ icon +".png";
	  icons[icon].shadow = "/images/gg_map/"+ icon +"_shadow.png";
	  icons[icon].iconSize = new GSize(25, 25); 
	  icons[icon].shadowSize = new GSize(55, 25); 
   }
}

function update_map() {
	if (running) {
		request.abort();
		running = false;
	}

	// alert(shownall+'-'+map.getZoom()+'-'+prevZoom); <= changé dessous.. bug de concept? 
	if (shownall == false || map.getZoom() <= prevZoom) {
		var bounds = map.getBounds();
		var center = map.getCenter();
		var zoom = map.getZoom();
		sentBounds = '('+bounds.getSouthWest().lat()+','+bounds.getSouthWest().lng()+','+bounds.getNorthEast().lat()+','+bounds.getNorthEast().lng()+')';
		sentCenter = '(' + center.lat() + ',' + center.lng() + ')';
		
		//build a list of layers to request
		var ob = document.getElementById("select_layers");
		var layers = '';
		for (var i = 0; i < ob.elements.length; i++) {
			if (ob.elements[i].checked)
				layers = layers + ',' +ob.elements[i].name;
		}
		layers = layers.substr(1);

		//alert("layers " + layers);

		request = GXmlHttp.create();
		// alert(sentCenter + ' - ' + zoom + ' - ' + sentBounds + ' - ' + layers);
		request.open("GET", "/ajax/googleMaps.xml.php?center=" + sentCenter + "&zoom=" + zoom + "&bounds="+sentBounds+"&layers="+layers, true);
		
		request.onreadystatechange = function() {
			if (request.readyState == 4 && running && request.responseText != "") {
				// alert(request.responseText);
				var xmlDoc = GXml.parse(request.responseText);
				//var xmlDoc = request.responseText;
				//alert(xmlDoc);
				if (!xmlDoc.documentElement) {
					alert("Error: Unable to Parse XML");
					running = false;
					return;
				}
				var markers = xmlDoc.documentElement.getElementsByTagName("marker");
				
				//flag all current markers as old
				for (i in marks) 
					if (marks[i] != null) {
						//alert('Old marker: ' + i);
						marks[i].old = true;
					}

				for (var i = 0; i < markers.length; i++) {
					lng = parseFloat(markers[i].getAttribute("lng"));
					lat = parseFloat(markers[i].getAttribute("lat"));
					type = parseFloat(markers[i].getAttribute("type"));
					// alert(lng + ' ' + lat + ' ' + type);
					id = lng+' '+lat+' '+type;
					if (marks[id] && marks[id] != null) {
						//we have this one so lets flag it as valid
						//alert('Flag old marker OK: ' + id);
						marks[id].old = false;
					} else {
						var point = new GPoint(lng, lat);
						//add any extra fields to this line
						marks[id] = createMarker(point, type);
						marks[id].old = false;
						
						map.addOverlay(marks[id]); 
						//alert(marks[id].isHidden());
					}
				}
				
				for (i in marks) {
					if (marks[i] != null) 
						if (marks[i].old == true) {
							// alert('Delete marker: ' + i);
							map.removeOverlay(marks[i]);
							marks[i] = null; //marks.splice(i,1);
						}
				}

				//print out a message
				var count = xmlDoc.documentElement.getElementsByTagName("count");
				if (count && count.length > 0) {
					c = count[0].getAttribute("value");
					if (markers.length == c) {
						// m.innerHTML = "Finished, showing "+markers.length+" markers.";
						shownall = true;
					} else {
						//m.innerHTML = "Finished, showing random "+markers.length+" of "+c+" markers, Zoom-in to see more!";
						shownall = false;
					}
				} else {
					//m.innerHTML = "Finished, showing "+markers.length+" of unknown markers.";
					shownall = true;
				}
				running = false;
			}
		}//end function
		
		running = true;
		request.send(null);
	}
	prevZoom = map.getZoom();
}

function map_set_center(latitude, longitude, zoom) {
	map.setCenter(new GLatLng(latitude, longitude), zoom);
	update_map();
}

function createMarker(point, type) {
	switch (type) {
		case 1: // Maison
			var marker = new GMarker(point, icons['maison']);
			break;
		case 2: // Appartement
		case 4: // Immeuble
			var marker = new GMarker(point, icons['appartement']);
			break;
		case 3:
			var marker = new GMarker(point, icons['parking']);
			break;
		case 5:
			var marker = new GMarker(point, icons['commerce']);
			break;
		case 7:
			var marker = new GMarker(point, icons['interrogation']);
			break;	
	}

	GEvent.addListener(marker, "click", function() {
		getMarkerInfo(marker.getPoint().lat(), marker.getPoint().lng(), type);
	});

	return marker;
}

function getMarkerInfo(lat, lng, type) { 
 if (receiveReq.readyState == 4 || 
	 receiveReq.readyState == 0) 
 {     
   receiveReq.open("GET", '/ajax/google_get_marker_info.php?lat='+lat+'&lng='+lng+'&type='+type, true);
   receiveReq.onreadystatechange = getMarkerInfoCallback;
   receiveReq.send(null);       
 } // end  if   
} // end  function

function getMarkerInfoCallback() {
 // state == 4 is when the response is complete
 if (receiveReq.readyState == 4) {
	var response = eval(receiveReq.responseText);

	map.openInfoWindowHtml(new GLatLng(response[0],response[1]),response[2]);				
 } // end   if (state == 4)
} // end   function

function center_map() {
	var xhr_object = setAjaxObject();
	if (xhr_object == null) return;	
	
	var center_data = document.getElementById('center_data').value;
	var center_data_country_index = document.getElementById('center_data_country').value;

	if (center_data_country_index == 0) {
		alert('Veuillez sélectionner un pays')
	} else if ( (receiveReq.readyState == 4 || receiveReq.readyState == 0)) {    
	   receiveReq.open("GET", '/ajax/ajax_centrer-cp.php?adresse='+center_data+'&pays_index='+center_data_country_index, true);
	   receiveReq.onreadystatechange = center_mapCallback;      
	   receiveReq.send(null);       				
	} // end if
}
function center_mapCallback() {
  if(receiveReq.readyState == 4) {
	 var response = $.parseJSON(receiveReq.responseText);
	 //alert(receiveReq.responseText);
	 if (response['result']) {
		// Centrer la map
		map_set_center(response.lat, response.long, response.zoom);
	 } else {
		alert(response['reason']);
	 }
  }
}

/***************
* AJAX
***************/
function setAjaxObject() {
   var xhr_object = null;
   
   if(window.XMLHttpRequest) // Firefox 
	  xhr_object = new XMLHttpRequest(); 
   else if(window.ActiveXObject) // Internet Explorer 
	  xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
   else { // XMLHttpRequest non supporté par le navigateur 
	  alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	  xhr_object = null;
   } 
   return xhr_object;
}

/*********************
* DEPOSER UNE ANNONCE
**********************/

function depose_liste_request(formlist) {
	// alert(formlist);
	var liste = document.getElementById('liste_'+formlist); 
	var index = liste.value; 
	// if(index >= 1) {
	   depose_request("step=" + formlist + "&" + formlist + "_type="+escape(index));
	//}
}

function depose_liste_request_update(formlist) {
	var liste = document.getElementById('liste_'+formlist); 
	var index = liste.value; 
	depose_update("step=" + formlist + "&" + formlist + "_type="+escape(index));
}

function depose_text_update(formlist) {
	var text = document.getElementById(formlist).value;
    depose_update("step=" + formlist + "&" + formlist + "=" +escape(text));
}

function depose_adresse_request() {
	var span_ville_bien = document.getElementById('span_ville');
	var ville_bien = ((span_ville_bien != null)?span_ville_bien.innerHTML:'');

	var adresse_bien = document.getElementById('adresse_bien').value;
	var cp_bien = document.getElementById('cp_bien').value;
	var pays = document.getElementById('liste_pays');
	var paysindex = pays.value; 
	var etage = document.getElementById('liste_etage').value;
	var ascenceur = document.getElementById('cb_ascenceur').checked;
	
	depose_request("step=adresse&adresse_bien="+escape(adresse_bien)+"&cp_bien="+escape(cp_bien)+"&ville_bien="+escape(ville_bien)+"&pays_bien="+escape(paysindex)+"&etage="+escape(etage)+"&ascenceur="+escape(ascenceur)); 
}

function depose_pieces_request() {
	var pieces_bien = document.getElementById('pieces_bien').value;
	
	depose_request("step=pieces&pieces_bien="+escape(pieces_bien)); 
}

function depose_expo_request() {
	var expo_n = document.getElementById('cb_expo_n').checked;
	var expo_s = document.getElementById('cb_expo_e').checked;
	var expo_e = document.getElementById('cb_expo_s').checked;
	var expo_o = document.getElementById('cb_expo_o').checked;
	
	depose_request("step=expo&expo_n="+escape(expo_n)+"&expo_s="+escape(expo_s)+"&expo_e="+escape(expo_e)+"&expo_o="+escape(expo_o)); 
}

function depose_surface_request() {
	var surface_carrez_bien = document.getElementById('surface_carrez_bien').value;
	var surface_reelle_bien = document.getElementById('surface_reelle_bien').value;
	
	depose_request("step=surface&surface_carrez_bien="+escape(surface_carrez_bien)+"&surface_reelle_bien="+escape(surface_reelle_bien)); 
}

function depose_elements_additionnels_request() {
	var parkingindex = document.getElementById('liste_parking').value;
	var cave = document.getElementById('cb_cave').checked;
	var balcon = document.getElementById('cb_balcon').checked;
	var surface_terrasse = document.getElementById('surface_terrasse').value;
	var surface_terrain = document.getElementById('surface_terrain').value;
	
	depose_request("step=surface_add&parkingindex="+escape(parkingindex)+"&cave="+escape(cave)+"&balcon="+escape(balcon)+"&surface_terrasse="+escape(surface_terrasse)+"&surface_terrain="+escape(surface_terrain)); 
}

function depose_texte_request() {
	var texte_annonce = document.getElementById('texte').value;
	
	depose_request("step=texte&texte_annonce="+escape(texte_annonce)); 
}

function depose_valeur_request() {
	var prix_bien = document.getElementById('prix_bien').value;
	var charges_bien = document.getElementById('charges_bien').value;
	var annee_bien = document.getElementById('liste_annee').value;
	var origine_index = document.getElementById('liste_origine').value;
	
	depose_request("step=valeur&prix_bien="+escape(prix_bien)+"&charges_bien="+escape(charges_bien)+"&origine_index="+escape(origine_index)+"&annee_bien="+escape(annee_bien)); 
}

function depose_contact_request() {
	var telephone1 = document.getElementById('telephone1').value;
	var telephone2 = document.getElementById('telephone2').value;
	var email = document.getElementById('email').value;
	
	depose_request("step=contact&telephone1="+escape(telephone1)+"&telephone2="+escape(telephone2)+"&email="+escape(email)); 
}

function depose_photo_action(id, action, index) {
	depose_request("step=photo_actions&id="+escape(id)+"&action="+escape(action)+"&index="+escape(index));
}

function depose_photos_request() {
	depose_request("step=photos");
}

function confirme_annonce() {
	depose_request("step=confirme"); 
}

function depose_request(data) {
	ajax_eval("ajax_deposer.php", data);	
}

function depose_update(data) {
	ajax_eval("ajax_update.php", data);		
}

function ajax_eval(ajax_script, data) {
	var xhr_object = setAjaxObject();
	if (xhr_object == null) return;
	 
	xhr_object.open("POST", "/ajax/" + ajax_script, true); 
	 
	xhr_object.onreadystatechange = function() { 
	  if(xhr_object.readyState == 4)
		 eval(xhr_object.responseText);
	} 
	
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
	xhr_object.send(data);			
}

function isUnsignedInteger(s) {
	return (s.toString().search(/^[0-9]+$/) == 0);
}

function checkLen(Target, maxLength, span_id) {
 // cette fonction calcule et affiche le nombre de caracteres saisis
    if (Target.value.length > maxLength) {
       Target.value = Target.value.substring(0,maxLength);
       CharsLeft = 0;
     }
     else {
       CharsLeft = maxLength - Target.value.length;
     }
     document.getElementById(span_id).innerHTML = '(' + CharsLeft + " caract&egrave;res restants)";
}

function set_indicator_upload(display) {
	if (display) {
	
	} else {
		
	}
}

/*******************
* CONTACTS
*******************/

function contacter_membre_ad(id_ad) {
	var texte = document.forms.formemail.inputemail.value;
	var captcha = document.forms.formemail.captcha_code.value;
	
	var xhr_object = setAjaxObject();
	if (xhr_object == null) return;
	 
	xhr_object.open("POST", "/ajax/ajax_send_mail.php", true); 
	 
	xhr_object.onreadystatechange = function() { 
	  if(xhr_object.readyState == 4) {
		 var response = $.parseJSON(xhr_object.responseText);
		 if (response['result']) {
			var msg = 'Email envoyé.';
		 } else {
			var msg = '<span class="red">Problème rencontré lors de l\'envoi du mail: ' + response.reason + '.</span>';
		 }
		 var newspan = document.createElement("span");
		 newspan.innerHTML = '<br>'+msg;
		 document.forms.formemail.appendChild(newspan);
		 regenerate_captcha();
	  }
	} 
	
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
	xhr_object.send("id_ad="+id_ad+"&texte="+escape(texte)+"&captcha="+escape(captcha));				
}

function regenerate_captcha() {
	document.getElementById('captcha').src = '/functions/captcha/securimage_show.php?' + Math.random();	
}

/*

CUSTOM FORM ELEMENTS

Created by Ryan Fait
www.ryanfait.com

The only thing you need to change in this file is the following
variables: checkboxHeight, radioHeight and selectWidth.

Replace the first two numbers with the height of the checkbox and
radio button. The actual height of both the checkbox and radio
images should be 4 times the height of these two variables. The
selectWidth value should be the width of your select list image.

You may need to adjust your images a bit if there is a slight
vertical movement during the different stages of the button
activation.

Visit http://ryanfait.com/ for more information.
http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/

*/

var checkboxHeight = "25";
var radioHeight = "25";
var selectWidth = "190";

/* No need to change anything after this */

document.write('<style type="text/css">input.styled { display: none; } select.styled { position: relative; width: ' + selectWidth + 'px; opacity: 0; z-index: 5; }</style>');

var Custom = {
	init: function() {
		// alert('init');
		var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active;
		for(a = 0; a < inputs.length; a++) {
			if((inputs[a].type == "checkbox" || inputs[a].type == "radio") && inputs[a].className == "styled") {
				//alert('styled');
				span[a] = document.createElement("span");
				span[a].className = inputs[a].type;

				if(inputs[a].checked == true) {
					if(inputs[a].type == "checkbox") {
						position = "0 -" + (checkboxHeight*2) + "px";
						span[a].style.backgroundPosition = position;
						span[a].innerHTML='&nbsp;'; // ajouté pour IE .. (raison inconnue)
					} else {
						position = "0 -" + (radioHeight*2) + "px";
						span[a].style.backgroundPosition = position;
					}
				}
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.clear;
				span[a].onmousedown = Custom.pushed;
				span[a].onmouseup = Custom.check;
				document.onmouseup = Custom.clear;
			}
		}
		inputs = document.getElementsByTagName("select");
		for(a = 0; a < inputs.length; a++) {
			if(inputs[a].className == "styled") {
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) {
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}
				span[a] = document.createElement("span");
				span[a].className = "select";
				span[a].id = "select" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.choose;
			}
		}
	},
	pushed: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight*3 + "px";
		} else if(element.checked == true && element.type == "radio") {
			this.style.backgroundPosition = "0 -" + radioHeight*3 + "px";
		} else if(element.checked != true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight + "px";
		} else {
			this.style.backgroundPosition = "0 -" + radioHeight + "px";
		}
	},
	check: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 0";
			element.checked = false;
		} else {
			if(element.type == "checkbox") {
				this.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else {
				this.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
				group = this.nextSibling.name;
				inputs = document.getElementsByTagName("input");
				for(a = 0; a < inputs.length; a++) {
					if(inputs[a].name == group && inputs[a] != this.nextSibling) {
						inputs[a].previousSibling.style.backgroundPosition = "0 0";
					}
				}
			}
			element.checked = true;
		}
	},
	clear: function() {
		inputs = document.getElementsByTagName("input");
		for(var b = 0; b < inputs.length; b++) {
			if(inputs[b].type == "checkbox" && inputs[b].checked == true && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else if(inputs[b].type == "checkbox" && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			} else if(inputs[b].type == "radio" && inputs[b].checked == true && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
			} else if(inputs[b].type == "radio" && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			}
		}
	},
	choose: function() {
		option = this.getElementsByTagName("option");
		for(d = 0; d < option.length; d++) {
			if(option[d].selected == true) {
				document.getElementById("select" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;
			}
		}
	}
}

/******************
* RECHERCHER
*******************/
function check_display_date2() {
	var option = document.getElementById("date_query").value;
	if (option == 4) {
		document.getElementById("date2").style['display'] = "block";
	} else {
		document.getElementById("date2").style['display'] = "none";	
	}
}

/**********************
* DIVERS
***********************/

function remove_all_childs(cell) {
	if ( cell.hasChildNodes() )
	{
		while ( cell.childNodes.length >= 1 )
		{
			cell.removeChild( cell.firstChild );       
		} 
	}
}

/**********************
* JQUERY PLUGINS
**********************/

/**** JSON **********/
(function ($) {
    var m = {
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"' : '\\"',
            '\\': '\\\\'
        },
        s = {
            'array': function (x) {
                var a = ['['], b, f, i, l = x.length, v;
                for (i = 0; i < l; i += 1) {
                    v = x[i];
                    f = s[typeof v];
                    if (f) {
                        v = f(v);
                        if (typeof v == 'string') {
                            if (b) {
                                a[a.length] = ',';
                            }
                            a[a.length] = v;
                            b = true;
                        }
                    }
                }
                a[a.length] = ']';
                return a.join('');
            },
            'boolean': function (x) {
                return String(x);
            },
            'null': function (x) {
                return "null";
            },
            'number': function (x) {
                return isFinite(x) ? String(x) : 'null';
            },
            'object': function (x) {
                if (x) {
                    if (x instanceof Array) {
                        return s.array(x);
                    }
                    var a = ['{'], b, f, i, v;
                    for (i in x) {
                        v = x[i];
                        f = s[typeof v];
                        if (f) {
                            v = f(v);
                            if (typeof v == 'string') {
                                if (b) {
                                    a[a.length] = ',';
                                }
                                a.push(s.string(i), ':', v);
                                b = true;
                            }
                        }
                    }
                    a[a.length] = '}';
                    return a.join('');
                }
                return 'null';
            },
            'string': function (x) {
                if (/["\\\x00-\x1f]/.test(x)) {
                    x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) {
                        var c = m[b];
                        if (c) {
                            return c;
                        }
                        c = b.charCodeAt();
                        return '\\u00' +
                            Math.floor(c / 16).toString(16) +
                            (c % 16).toString(16);
                    });
                }
                return '"' + x + '"';
            }
        };
 
	$.toJSON = function(v) {
		var f = isNaN(v) ? s[typeof v] : s['number'];
		if (f) return f(v);
	};
	
	$.parseJSON = function(v, safe) {
		if (safe === undefined) safe = $.parseJSON.safe;
		if (safe && !/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(v))
			return undefined;
		return eval('('+v+')');
	};
	
	$.parseJSON.safe = false;
 
})(jQuery);

//////////////
// JQUERY onready
//////////////

/***************
* JQUERY
***************/
$(document).ready( 
	function(){ 
		$('#news').innerfade({ 
			animationtype: 'fade', 
			speed: 750, 
			timeout: 5000, 
			type: 'sequence', 
			containerheight: '50px' 
		});
 	} 
);