// ------------ GALERY.PHP
	var words = new Array("купува ", "купувам ", "купуваме ", "купуват ", "продава ", "продавам ", "продаваме ", "продават ", "наемам ", "наемат ", "наемаме ", "отдавам ", "отдаваме ", "отдават ", "заменям ", "заменят ", "заменяме ");
	
	function clearWords(input) {
		var lng = 0;
		var word = "";
		for(idx in words) {
			word = words[idx];
			lng =  word.length;
			
			if(input.value.substring(0, lng).toLowerCase() == word) {
				input.value = input.value.substring(lng);
			}
		}
	}
	
	function loadComments(id) {
		var f = document.form;
		if(f != null) {
			document.form.img_id.value = id;
		}
		$.getScript('http://www.hunter.bg/get_coments.php?id='+id); 
	}
	
	function loadImg(idx) {
		$("#g0").fadeTo("slow", 0.01, 
			function() {
				$.getScript('http://www.hunter.bg/get_pic.php?'+aidx+'img='+(imgidx+idx), 
					function () {
						$("#g0").fadeTo("fast", 1);
					}
				);
			}
		);
	}
		
		
	function processComment() {
		if($("#btn").val() == " ") {
			$("#btn").val("");
			$("#add_comment").show("slow");
			formstatus = 1;
		} else {
			$("#btn").val(" ");
			$("#add_comment").hide("fast"); 
			if ($("#new_comment").val()) $("#form").submit(); 
		}
	}


	$().ready(
		function() {
			
			function InitImages() {
				if(typeof(window['imgidx']) == "undefined") return;
				for($i=0; $i<6; $i++){ $("#g2"+$i).animate({left: $i*86+516}, 0);	}
				$("#scroll_left").hide();
				if(imgidx + 6 >= imgCnt) $("#scroll_right").hide(); else $("#scroll_right").show(); 
				if(imgidx - 6 < 0) $("#scroll_left").hide(); else $("#scroll_left").show(); 
				$.getScript('\get_pic.php?'+aidx+'id=1&first='+imgidx,
					function() {			
						for($i=0; $i<6; $i++){
							$("#g1"+$i).animate({left: $i*86}, 300);			
						}
					}
				);
				loadImg(show_idx);
				$("#add_comment").hide("fast");
			}
			
			
			$("#scroll_left").click( 
				function () {
					for($i=0; $i<6; $i++){
						i1 = document.getElementById("g1"+$i);
						i2 = document.getElementById("g2"+$i);	
						i2.src = i1.src; 
						i2.style.visibility = i1.style.visibility;
					}
						
					for($i=0; $i<6; $i++){ 
						$("#g2"+$i).animate({left: $i*86}, 0);	
						$("#g1"+$i).animate({left: $i*86-516}, 0);	
					}

					imgidx -= 6;
					if(imgidx < 0 ) {
						imgidx = 0;
						$("#scroll_left").hide(); 
					} else $("#scroll_left").show(); 
					$("#scroll_right").show(); 
					$.getScript('http://www.hunter.bg/get_pic.php?'+aidx+'id=1&first='+imgidx,
						function() {			
							for($i=0; $i<6; $i++){
								$("#g2"+$i).animate({left: $i*86+516}, 300);			
								$("#g1"+$i).animate({left: $i*86}, 300);			
							}
						}
					);
					
					return false;
				} 
			);

			$("#scroll_right").click(
				function () {
					for($i=0; $i<6; $i++){
						i1 = document.getElementById("g1"+$i);
						i2 = document.getElementById("g2"+$i);	
						i2.src = i1.src; 
						i2.style.visibility = i1.style.visibility;
					}
						
					for($i=0; $i<6; $i++){ 
						$("#g2"+$i).animate({left: $i*86}, 0);	
						$("#g1"+$i).animate({left: $i*86+516}, 0);	
					}

					if(imgidx + 6 < imgCnt) imgidx += 6;
					if(imgidx + 6 >= imgCnt) $("#scroll_right").hide(); else $("#scroll_right").show(); 
					$("#scroll_left").show();
					$.getScript('http://www.hunter.bg/get_pic.php?'+aidx+'id=1&first='+imgidx,
						function() {			
							for($i=0; $i<6; $i++){
								$("#g2"+$i).animate({left: $i*86-516}, 300);			
								$("#g1"+$i).animate({left: $i*86}, 300);			
							}
						}
					);
					
					return false;
				} 
			);
						
			InitImages();
			
			
			$('a[name="cat"]').click(
				function () {
					id = ($(this).attr("id"));
					$(".submenu").hide(500);
					$("#podcat"+id).show(500);
					return false;
				}
			);
		}
	);
// ------------ GALERY.PHP

function enterField(field, defaultVal) {
	if(field.value == defaultVal) field.value = '';
}

function blurField(field, defaultVal) {
	if(field.value == '') field.value = defaultVal;
}

