//jQuery.noConflict();

jQuery.fn.clearForm = function() {
  return this.each(function() {
    var type = this.type, tag = this.tagName.toLowerCase();
    if (tag == 'form')
      return jQuery(':input',this).clearForm();
    if (type == 'text' || type == 'password' || tag == 'textarea')
      this.value = '';
    else if (type == 'checkbox' || type == 'radio')
      this.checked = false;
    else if (tag == 'select')
      this.selectedIndex = -1;
  });
};

function crateCaptchaImage() {
	var img = new Image();
	jQuery(img).load(function () {
		
    	jQuery('#captcha').html(this);
        
    }).attr('src', '/captcha/image.php?'+Math.random()).attr('id', 'img');
}

jQuery(document).ready(
	function($)
	{
		$(".attention").bind(
				'click',
				function() {
					$('#reportBox').show();
				}
		);
		
		$(".attentionClose").bind(
				'click',
				function() {
					$('#reportBox').hide();
				}
		);
		
		$('#reportSubmit').bind(
				'click',
				function() {
					$.post("/ajax/ajax_reportMap_save.php",
					   { 
						text: $("#reportText").val()
					   },
					   	function(result) {
						   //	alert(result);
						  	if(result == 'true') {
						  		$('#reportForm').hide();
						  		$('#reportSent').show();
							}
						  	else {
						  		$("#captchaText").addClass("error");
							}
						  	
						}
					);
				}	
			);
	}
);

function ShowElement(objectName) {
	if (document.getElementById(objectName))
    {
        document.getElementById(objectName).style.visibility = "visible";
        return true;
    }
	else {
		return false;
	}
	 
}

function HideElement(objectName) {
	//alert(objectName);
	if (document.getElementById(objectName))
    {
        document.getElementById(objectName).style.visibility = "hidden";
        return true;
    }
	else {
		return false;
	}
	
}

function change_city(param,language) {
	
	var city = document.getElementById("search_city").value;

	document.location = '/'+city+'/'+language;
	
	return true;
	
}

function ShowHideElement(objectName) {
	//alert(objectName);
	if (document.getElementById(objectName))
    {
		
		if(document.getElementById(objectName).style.display == "block") {
			document.getElementById(objectName).style.display = "none";
		}
		else {
			document.getElementById(objectName).style.display = "block";
		}
        return true;
    }
	else {
		return false;
	}
}

function changeImage(objectName,newSrc) {
	
	if(document.getElementById(objectName).style.backgroundPosition == '0px 0px') {
		document.getElementById(objectName).style.backgroundPosition = '0px 18px';
	}
	else {
		document.getElementById(objectName).style.backgroundPosition = '0px 0px';
	}
	
}

function highlightElement(objectName) {
	if (document.getElementById(objectName))
    {
		document.getElementById(objectName).style.color = "#000"; //"#3497bc";
		document.getElementById(objectName).style.fontWeight = "Bold";
        return true;
    }
	else {
		return false;
	}
}

function lowlightElement(objectName) {
	if (document.getElementById(objectName))
    {
		document.getElementById(objectName).style.color = "#626160";
		document.getElementById(objectName).style.fontWeight = "";
        return true;
    }
	else {
		return false;
	}
}
