
jQuery(document).ready(function() {
	
	//carousel
    jQuery('#mycarousel').jcarousel({
    	scroll: 1,
        auto: 3,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });
    
    
    jQuery(".tooltip").easyTooltip(); // tooltips
    
    $(".item:not(.sponsor)").hover(
		function() {
			$(this).addClass("itemHover");
		},
		function() {
			$(this).removeClass("itemHover");
		}
	);
    $(".answer:not(.best-answer)").hover(
		function() {
			$(this).addClass("answerHover");
		},
		function() {
			$(this).removeClass("answerHover");
		}
	);
	
	// loading more on index
	$(".myQuestions").live("click", function() {
		var page = $(this).attr("page");
		var user = $(this).attr("u");
		$(this).addClass("loading2");
		$.ajax({
			type: "POST",
			url: "/work.php",
			async: false,
			data: "action=myQuestions&page="+page+"&user="+user,
			success: function(msg){
				$("#sb_10").append(msg);
				$("a.myQuestions[page="+page+"]").remove();
			}
		}); // end of ajax
	});
	
	// loading more on index
	$(".myFavorite").live("click", function() {
		var page = $(this).attr("page");
		var user = $(this).attr("u");
		$(this).addClass("loading2");
		$.ajax({
			type: "POST",
			url: "/work.php",
			async: false,
			data: "action=myFavorite&page="+page+"&user="+user,
			success: function(msg){
				$("#sb_12").append(msg);
				$("a.myFavorite[page="+page+"]").remove();
			}
		}); // end of ajax
	});
	
	// loading more on index
	$(".myAnswers").live("click", function() {
		var page = $(this).attr("page");
		var user = $(this).attr("u");
		$(this).addClass("loading2");
		$.ajax({
			type: "POST",
			url: "/work.php",
			async: false,
			data: "action=myAnswers&page="+page+"&user="+user,
			success: function(msg){
				$("#sb_11").append(msg);
				$("a.myAnswers[page="+page+"]").remove();
			}
		}); // end of ajax
	});
	
	// reporting a question
	$(".reporting_question").live("click", function() {
		var id = $(this).attr("id");
		id = id.replace("q", "");
		$(this).find("img").attr("src", "/images/loading.gif");
		$.ajax({
			type: "POST",
			url: "/work.php",
			data: "action=reportQuestion&id="+id,
			success: function(msg){
				$("#q"+id).html(msg);
				$("#q"+id).removeClass("reporting_question");
			}
		}); // end of ajax
	});
	
	// reporting a answer
	$(".reporting_answer").live("click", function() {
		var id = $(this).attr("id");
		var qid = $(this).attr("qid");
		id = id.replace("qa", "");
		$(this).find("img").attr("src", "/images/loading.gif");
		$.ajax({
			type: "POST",
			url: "/work.php",
			data: "action=reportAnswer&id="+id+"&qid="+qid,
			success: function(msg){
				$("#qa"+id).html(msg);
				$("#qa"+id).removeClass("reporting_answer");
			}
		}); // end of ajax
		return false;
	});
	
	// set best answer
	$(".best_answer").live("click", function() {
		var id = $(this).attr("id");
		var qid = $(this).attr("qid");
		id = id.replace("ba", "");
		$(this).find("img").attr("src", "/images/loading.gif");
		$.ajax({
			type: "POST",
			url: "/work.php",
			async: false,
			data: "action=bestAnswer&id="+id+"&qid="+qid,
			success: function(msg){
				$(".best_answer").remove();
				alertuj(msg);
				window.location.reload();
			}
		}); // end of ajax
		
	});
	
	// like
	$(".likebutton").live("click", function() {
		var id = $(this).attr("id");
		var qid = $(this).attr("qid");
		id = id.replace("like_", "");
		$(this).find("img").attr("src", "/images/loading.gif");
		var current = $(this).find("span").html();
		$.ajax({
			type: "POST",
			url: "/work.php",
			data: "action=setLike&id="+id+"&qid="+qid,
			success: function(msg){
				if(msg == "not") {
					current = parseInt(current) + 1;
					$(".likes").removeClass('likebutton');
					$(".dislikes").removeClass('dislikebutton');
					$("#like_"+id).find("img").attr("src", "/images/like.png");
					$("#like_"+id).find("span").html(current);
				} else {
					
					$("#like_"+id).removeClass("likebutton");
					$("#dislike_"+id).removeClass("dislikebutton");
					$("#like_"+id).find("img").attr("src", "/images/like.png");
					$("#like_"+id).find("span").html(msg);
				}
			}
		}); // end of ajax
		return false;
	});
	// dislike
	$(".dislikebutton").live("click", function() {
		var id = $(this).attr("id");
		var qid = $(this).attr("qid");
		id = id.replace("dislike_", "");
		$(this).find("img").attr("src", "/images/loading.gif");
		var current = $(this).find("span").html();
		$.ajax({
			type: "POST",
			url: "/work.php",
			data: "action=setDislike&id="+id+"&qid="+qid,
			success: function(msg){
				if(msg == "not") {
					current = parseInt(current) + 1;
					$(".likes").removeClass('likebutton');
					$(".dislikes").removeClass('dislikebutton');
					$("#dislike_"+id).find("img").attr("src", "/images/dislike.png");
					$("#dislike_"+id).find("span").html(current);
				} else {
					
					$("#dislike_"+id).removeClass("dislikebutton");
					$("#like_"+id).removeClass("likebutton");
					$("#dislike_"+id).find("img").attr("src", "/images/dislike.png");
					$("#dislike_"+id).find("span").html(msg);
				}
			}
		}); // end of ajax
		return false;
	});
	
	// favorite question
	$(".favorite_question").live("click", function() {
		var id = $(this).attr("id");
		id = id.replace("fq", "");
		$(this).addClass("loading");
		$.ajax({
			type: "POST",
			url: "/work.php",
			data: "action=favoriteQuestion&id="+id,
			success: function(msg){
				$("#fq"+id).removeClass("loading");
				
				if(msg == 1) {
					$("#fq"+id).html("Ukloni iz omiljenih");
					$("#fq"+id).removeClass("blue");
					$("#fq"+id).addClass("orange");
				} else if (msg == 0) {
					$("#fq"+id).html("Dodaj u omiljene");
					$("#fq"+id).addClass("blue");
					$("#fq"+id).removeClass("orange");
				}
				
			}
		}); // end of ajax
	});
	
	$("#reply_question").live("click", function() {
		
        var ed = tinyMCE.get('odgovor-text');
		var b = ed.getContent();
		b = jQuery.trim(b);
        var id = $(".question-header").attr("id");
        id = id.replace("quest_", "");
        b = b.replace(/&/g, "{AND}");
        
        if(b == "") {
        	alertuj("Morate da unesete tekst odgovora!");
        	return false;
        }
        
        ed.setProgressState(1);
        
        $.ajax({
			type: "POST",
			url: "/work.php",
			data: "action=replyQuestion&id="+id+"&b="+b,
			success: function(msg){
				ed.setProgressState(0); // Hide progress
                alertuj("Hvala na odgovoru!");
                $(".forma-odgovor").remove();
                $(".answers").html(msg);
//                $(".loading_reply_question").fadeOut();
			}
		}); // end of ajax
		
	});
	
	// alert message
	$("#alert_message").dialog({
			autoOpen: false,
			title: "Sveznalica info",
			draggable: false,
			resizable: false,
			modal: true,
			buttons: {
				"U redu": function() {
					$( this ).dialog("close");
				}
			}
	});
	
	$("#u_name").live("click", function (){
		$(this).hide();
		$('#u_name_save').show();
		var old_val = $('#profileName').find(".info-value").html();
		var input_html = "<input type=\"text\" id=\"newName\" value=\""+old_val+"\" class=\"edit-input\" />";
		$('#profileName').find(".info-value").html(input_html);
	});
	
	$("#u_name_save").live("click", function (){
		$(this).find("img").attr("src", "/images/loading.gif");
		var new_val = $("#newName").val();
		$.ajax({
			type: "POST",
			url: "/work.php",
			async: false,
			data: "action=editProfile&new="+new_val+"&field=name",
			success: function(msg){
				if(msg == "0") {
					alertuj("Došlo je do greške!");
				} else {
					$('#u_name').show();
					$('#u_name_save').hide();
					$('#u_name_save').find("img").attr("src", "/images/save.png");
					$('#profileName').find(".info-value").html(new_val);
				}
			}
		}); // end of ajax
	});
	
	$("#u_gender").live("click", function (){
		$(this).hide();
		$('#u_gender_save').show();
		var old_val = $('#profileGender').find(".info-value").html();
		
		if(old_val == "muški") {
			var selected_male = "selected='selected'";
			var selected_female = "";
		}	
		
		if(old_val == "ženski") {
			var selected_female = "selected='selected'";
			var selected_male = "";
		}
		
		
		var input_html = "<select id=\"newG\" class=\"edit-select\"><option value='1' "+selected_female+" >Ženski</option><option value='0' "+selected_male+">Muški</option></select>";
		$('#profileGender').find(".info-value").html(input_html);
	});
	
	$("#u_gender_save").live("click", function (){
		$(this).find("img").attr("src", "/images/loading.gif");
		var new_val = $("#newG").val();
		if(new_val == "1") var new_text = "ženski";
		if(new_val == "0") var new_text = "muški";
		
		$.ajax({
			type: "POST",
			url: "/work.php",
			async: false,
			data: "action=editProfile&new="+new_val+"&field=gender",
			success: function(msg){
				if(msg == "0") {
					alertuj("Došlo je do greške!");
				} else {
					$('#u_gender').show();
					$('#u_gender_save').hide();
					$('#u_gender_save').find("img").attr("src", "/images/save.png");
					$('#profileGender').find(".info-value").html(new_text);
				}
			}
		}); // end of ajax
	});
	
	$("#u_location").live("click", function (){
		$(this).hide();
		$('#u_location_save').show();
		var old_val = $('#profileLocation').find(".info-value").html();
		var array = new Array();
		array = old_val.split(",");
		
		var city = array[0];
		var country = array[1];
		
		var c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9, c_10, c_11, c_12, c_13;
		
		if(country == "Srbija") 				c_1 = " selected=\"selected\"";
		else if(country == "Crna Gora") 		c_2 = " selected=\"selected\"";
		else if(country == "Hrvatska") 			c_3 = " selected=\"selected\"";
		else if(country == "Bosna i Hercegovina") c_4 = " selected=\"selected\"";
		else if(country == "Slovenija") 		c_5 = " selected=\"selected\"";
		else if(country == "Makedonija") 		c_6 = " selected=\"selected\"";
		else if(country == "SAD") 				c_7 = " selected=\"selected\"";
		else if(country == "Nemačka") 			c_8 = " selected=\"selected\"";
		else if(country == "Austrija") 			c_9 = " selected=\"selected\"";
		else if(country == "Švajcarska")		c_10 = " selected=\"selected\"";
		else if(country == "Francuska") 		c_11 = " selected=\"selected\"";
		else if(country == "Australija") 		c_12 = " selected=\"selected\"";
		else if(country == "Ostale zemlje") 	c_13 = " selected=\"selected\"";
		
		var input_html = "<input type=\"text\" id=\"newCity\" value=\""+city+"\" class=\"edit-input small-text\" /> " + 
						"<select id=\"newCountry\" class=\"edit-select small-select\">" +
						"	<option "+c_1+" value=\"Srbija\">Srbija</option>" +
	            		"	<option "+c_2+" value=\"Crna Gora\">Crna Gora</option>" +
	            		"	<option "+c_3+" value=\"Hrvatska\">Hrvatska</option>" +
	            		'	<option '+c_4+' value="Bosna i Hercegovina">Bosna i Hercegovina</option>' +
	            		'	<option '+c_5+' value="Slovenija">Slovenija</option>'+
	            		'	<option '+c_6+' value="Makedonija">Makedonija</option>' +
	            		'	<option '+c_7+' value="SAD">SAD</option>' +
	            		'	<option '+c_8+' value="Nemačka">Nemačka</option>' +
	            		'	<option '+c_9+' value="Austrija">Austrija</option>' +
	            		'	<option '+c_10+' value="Švajcarska">Švajcarska</option>' +
	            		'	<option '+c_11+' value="Francuska">Francuska</option>' +
	            		'	<option '+c_12+' value="Australija">Australija</option>' +
	            		'	<option '+c_13+' value="Ostale zemlje">Ostale zemlje</option>' +
						"</select>";
		
		
		$('#profileLocation').find(".info-value").html(input_html);
	});
	
	$("#u_location_save").live("click", function (){
		$(this).find("img").attr("src", "/images/loading.gif");
		var new_city = $("#newCity").val();
		var new_country = $("#newCountry").val();
												
		$.ajax({
			type: "POST",
			url: "/work.php",
			async: false,
			data: "action=editProfileLocation&new="+new_city+"&new2="+new_country+"&field=city&field2=country",
			success: function(msg){
				if(msg == "0") {
					alertuj("Došlo je do greške!");
				} else {
					$('#u_location').show();
					$('#u_location_save').hide();
					$('#u_location_save').find("img").attr("src", "/images/save.png");
					$('#profileLocation').find(".info-value").html(new_city+", "+new_country);
				}
			}
		}); // end of ajax
	});
	
	
});


$(function () {

	$(".sb_div").hide();
	
	if(window.location.hash && window.location.hash.match('sb')) {
	
		$("div.middle-header a[href="+window.location.hash+"]").addClass("active").show();
		$("div.header-content div.type-box").find("a[href=/"+window.location.hash+"]").addClass("active").show();
		$(".items .sb_div#"+window.location.hash).show();
	} else {
		if($(".items .sb_div").length != 0 && $("div.middle-header").length != 0) {
			if(window.location.hash && window.location.hash.match('pitaj')) {
				$('div.type-box a').removeClass("active");
				$("div.header-content div.pitaj").find("a").addClass("active");
				$("div.middle-header a").removeClass("active");
				$("div.middle-header a[href=#sb_1]").addClass("active");
				$("#question_title").focus();
				$("#question_title").val("");
				$(".submit_ask").slideDown();
				$("body").unbind("click");
			} else {
				$("div.middle-header a:first").addClass("active").show();
				$("div.header-content div:not(.pitaj):first").find('a').addClass("active").show();
			}
			$(".items .sb_div:first").show();
		}
	}

	$("div.middle-header a").click(function() {
	
		var activeTab = $(this).attr("href");
		window.location.hash = activeTab;
		
		$(this).parent().find('a').removeClass("active");
		$(this).addClass("active");
		
		$("div.header-content div.type-box").find('a').removeClass("active");
		$("div.header-content div.type-box").find("a[href=/"+activeTab+"]").addClass("active");
		
		$('.items').find(".sb_div").hide();			
		$(activeTab).show();
		return false;
	});	

	$("div.type-box a").live("click", function() {
	
		//alertuj(location.href);
		
		var activeTab = $(this).attr("href");
		if(activeTab == "/#sb_1" || activeTab == "/#sb_2") {
			activeTab = activeTab.replace("/", "");
			window.location.hash = activeTab;
			
			$('div.type-box a').removeClass("active");
			$(this).addClass("active");
			
			$("div.middle-header a").removeClass("active");
			$("div.middle-header").find("a[href="+activeTab+"]").addClass("active");
			
			$('.items').find(".sb_div").hide();	
			$(activeTab).show();
			return false;
		} else if(activeTab == "/#pitaj") {
			window.location.hash = activeTab;
			
			$('div.type-box a').removeClass("active");
			$(this).addClass("active");
			$("div.middle-header a").removeClass("active");
			$("#question_title").focus();
			$(".submit_ask").slideDown();
			
			$("body").unbind("click");
			
		} else {
			return true;
		}
	});	
	
	$('#question_title').focus(function(){
		$('.submit_ask').slideDown();
		var val = $(this).val();
		if(val == 'Postavi pitanje, dobij pravi odgovor...') {
			$(this).attr('value', '');
		} else {
			$(this).attr('value', val);
		}
	});

	$('#question_title').blur(function(){
		var val = $(this).val();
		if(val == '') {
			$(this).attr('value', 'Postavi pitanje, dobij pravi odgovor...');
		} else {
			$(this).attr('value', val);
		}
	});
	
	$('#pitaj_polje').focus(function(){
		var val = $(this).val();
		if(val == 'Opis pitanja...') {
			$(this).attr('value', '');
		} else {
			$(this).attr('value', val);
		}
	});
	
	$('#pitaj_polje').blur(function(){
		var val = $(this).val();
		if(val == '') {
			$(this).attr('value', 'Opis pitanja...');
		} else {
			$(this).attr('value', val);
		}
	});
	
	$('body').click(function(){
		
		$('#about-me-hidden').slideUp();
		
		$('.submit_ask').slideUp();
		var val = $('#pitaj_polje').val();
		if(val == '') {
			$('#pitaj_polje').attr('value', 'Opis pitanja...');
		} else {
			$('#pitaj_polje').attr('value', val);
		}
		
		var val2 = $('#question_title').val();
		if(val2 == '') {
			 $('#question_title').attr('value', 'Postavi pitanje, dobij pravi odgovor...');
		} else {
			 $('#question_title').attr('value', val2);
		}
		
	});
	
	$('#ask-form').click(function(e){
		e.stopPropagation();
		$("body").bind("click", function() {
			$('#about-me-hidden').slideUp();
		
			$('.submit_ask').slideUp();
			var val = $('#pitaj_polje').val();
			if(val == '') {
				$('#pitaj_polje').attr('value', 'Opis pitanja...');
			} else {
				$('#pitaj_polje').attr('value', val);
			}
			
			var val2 = $('#question_title').val();
			if(val2 == '') {
				 $('#question_title').attr('value', 'Postavi pitanje, dobij pravi odgovor...');
			} else {
				 $('#question_title').attr('value', val2);
			}
		});
	});
	var show = false;
	$('#login').bind("click", function(){
		if(show) {
			$('.login-box').slideUp();
			$('.search-box').show();
			show = false;
		} else {
			$('.login-box').slideDown();
			$('.search-box').hide();
			show = true;
		}
	});
	
	$('.profile-avatar').bind("mouseover", function(){
		$('#change-avatar').show();
		$('#take-avatar').show();
		$('#remove-avatar').show();
	});
	
	$('.profile-avatar').bind("mouseout", function(){
		$('#change-avatar').hide();
		$('#take-avatar').hide();
		$('#remove-avatar').hide();
	});
	
	$('#about-me').focus(function(){
		$('#about-me-hidden').slideDown();
	});
	
	$('#about-me-form').click(function(e){
		e.stopPropagation();
	});
	
});




/**
FUNCTIONS
**/

function alertuj(poruka) {
	$("#alert_message").html( "<p>" + poruka + "</p>" );
	$("#alert_message").dialog( "open" );
	return false;
}

function sendMessage(id) {
	$(".loading_inbox").show();
	var s = $('#message_subject').val();
	var b = $('#message_body').val();
	
	b = b.replace(/&/g, "{AND}");
	
	if(b != ""){
	
		$.ajax({
			type: "POST",
			url: "/work.php",
			data: "action=sendMessage&i_f="+id+"&s="+s+"&b="+b,
			success: function(msg){
				$('#message_subject').val('');
				$('#message_body').val('');
				$('.loading_inbox').fadeOut();
				alertuj('Vaša poruka je uspešno poslata!');
			}
		}); // end of ajax
		
		return true;
	} else if(b == ""){
		alertuj('Morate da unesete tekst poruke!');
		return false;
	} 
}

function changeLimit(pageURL) {
	$.ajax({
		type: "POST",
		async: false,
		url: "/work.php",
		data: "action=changeLimit&limit="+$(".limit_"+pageURL).val(),
		success: function(msg){
			location.href="/"+pageURL+"/";
		}
	});
}			
function savePicture() {
	if(checkCoords()) {
		
		var x = $('#x').val();
	    var y = $('#y').val();
	    var w = $('#w').val();
	    var h = $('#h').val();
	    var user_id = $('#user_id').val();
	    var picture_name = $('#picture_name').val();
	   
		return true;
	} else
		hideLoader('.izmeni-sliku');
		return false;
}


function updateCoords(c) {
    $('#x').val(c.x);
    $('#y').val(c.y);
    $('#w').val(c.w);
    $('#h').val(c.h);
};

function checkCoords() {
    if (parseInt($('#w').val())) return true;
    alertuj('Izaberite deo slike i pritisnite dugme Sačuvaj.');
    hideLoader('#izmeni-sliku');
    hideLoader('.izmeni-sliku');
    return false;
};

function mycarousel_initCallback(carousel) {
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

function updateDescription(id) {
	$(".loading_profile").show();
	var desc = jQuery.trim($("#about-me").val());
	$("#about-me-button").val("");
	$.ajax({
		type: "POST",
		async: false,
		url: "/work.php",
		data: "action=updateDescription&id="+id+"&desc="+desc,
		success: function(msg){
			$("#about-me-button").val("");
			$(".loading_profile").fadeOut();
		}
	});
	
}

function checkEmail(id){
	var email = $('#'+id).attr('value');
	var valid;
	$.ajax({
		type: "POST",
		async: false,
		url: "/work.php",
		data: "action=checkEmail&email="+email,
		success: function(msg){
			valid = msg;
		}
	});
	return valid;
}

function checkLostPassForm(){
	
	var email = jQuery.trim($('#email').val());
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var captcha = $('#captcha').length;
	
	if(email == ""){
		alertuj("Unesite e-mail!");
		return false;
	} else if(reg.test(email) == false) {
		alertuj("Unesite validan e-mail!");
        return false;	
	}
	
	if(captcha == 0) {
		alertuj("Potvrdite da ste čovek!");
		return false;
	}
	
	return true;
}

function checkRegisterForm() {
	
	var name = jQuery.trim($('#name').val());
	var username = jQuery.trim($('#username').val());
	var email = jQuery.trim($('#email').val());
	var password = jQuery.trim($('#password').val());
	var city = jQuery.trim($('#city').val());
	var captcha = $('#captcha').length;
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var uslovi = $('#uslovi:checked').length;
		
	if(name == "") {
		alertuj("Unesite ime!");
		return false;
	}
	
	var checke = checkEmail('email');
	var ve = parseInt(checke);
	
	if(name == "") {
		alertuj("Unesite ime!");
		return false;
	}
	
	if(username == "") {
		alertuj("Unesite korisničko ime!");
		return false;
	} else if (username.length < 4 || username.length > 14) {
		alertuj("Dužina korisničkog imena mora biti između 4 i 14 karaktera!");
		return false;
	}
	
	
	if(email == ""){
		alertuj("Unesite e-mail!");
		return false;
	} else if(reg.test(email) == false) {
		alertuj("Unesite validan e-mail!");
        return false;	
	} else if(ve == 1) {
		alertuj("E-mail je u upoterbi!");
        return false;	
	}
	
	if(city == "") {
		alertuj("Unesite grad!");
		return false;
	}
	
	if(uslovi == 0) {
		alertuj("Morate se složiti sa Uslovima i Pravilima korišćenja!");
		return false;
	}
	
	if(captcha == 0) {
		alertuj("Potvrdite da ste čovek!");
		return false;
	}
	
	return true;
}
					
function checkAsk(){
	
	var title_val = $('#question_title').val();
	var kategorije = $('#kategorije').val();
	
	if(title_val == 'Postavi pitanje, dobij pravi odgovor...') {
		alertuj("Unesite pitanje!");
		return false;
	} 
	
	if(title_val == '') {
		alertuj("Unesite pitanje!");
		return false;
	} 
	
	if(kategorije == '0') {
		var string = "Odaberite pravu kategoriju za Vaše pitanje. "+
				 "Time ćete povećati šansu da ljudi koji mogu "+
				 "da Vam daju najbolji odgovor primete i odgovore "+
				 "na Vaše pitanje.<br><br>Ako mislite da Vaše pitanje ne "+
				 "potpada ni u jednu od ponudjenih kategorija, izaberite RAZNO.";
		alertuj(string);
		return false;
	}
	
	return true;
}

function showLoader(parent) {
	$('div.loader', parent).show();
}

function hideLoader(parent) {
	$('div.loader', parent).hide();
}
