function messages(){
	var html = $.ajax({
	url: "ajax/messages_all.php",
	async: false
	}).responseText;
	$("div#messages_all").empty().append(html);
}

function set_notify_mode(stuff){
	var result = $.ajax({
		type: "GET",
		url: "ajax/set_notify_way.php",
		data: "stuff=" + stuff,
		async: false
	}).responseText;
	$("#ncmr").empty().append(result);
}

function set_msg_notification(stuff){
	var result = $.ajax({
		type: "GET",
		url: "ajax/message_notification.php",
		data: "stuff=" + stuff,
		async: false
	}).responseText;
	$("#mnr").empty().append(result);
}


function countBytes(value) {
	var escaped = encodeURI(value);
   if (escaped.indexOf("%") != -1) {
	   var count = escaped.split("%").length - 1;
	   if (count == 0) {
		   count++;                  }
	   var tmp = escaped.length - (count * 3);
	   count = count + tmp;
   } else {
	   count = escaped.length;
   }
	 return count;
};

var initPostMessage = function() {
    $(function() {
        var $profileHeader = $("#profile_header");
        var $textarea = $("#message");
        var $fileInput = $("#add_photo");
        var $videoIdInput = $("#video_id");
        var $saveRecordCont = $("#saveRecordCont");
        var $label = $profileHeader.find("label");
        var $recorderCont = $("#recorderCont");
        var flashWidth = 216;
        
        var show = function(pred) {
            if (pred) {
                $saveRecordCont.hide();
                $textarea.width((590 - flashWidth) + "px");
                $fileInput.css("margin-left", Math.max((5 - flashWidth), 0) + "px");
                $fileInput.attr("disabled", "true");
                $recorderCont.show();
                
                var flashObject = new SWFObject("http://bz.yaika.ee/BiziWidget.swf", "videoRecorder", flashWidth, "185", "9.0.28", "#FFFFFF");
                flashObject.addParam("quality", "high");
                flashObject.addParam("allowScriptAccess", "always");
                flashObject.addParam("allowFullscreen", "true");
                //flashObject.addVariable("locale", "http://bz.yaika.ee/loc_bizi.xml");
				flashObject.addVariable("locale", mainLoc['yaikaurl']);
                flashObject.addVariable("status", "publisher");
                flashObject.addVariable("rtmp", "212.47.217.102");
                flashObject.write("recorderCont");
            } else {
                $videoIdInput.val("");
                $recorderCont.empty();
                $recorderCont.hide();
                $fileInput.css("margin-left", "5px");
                $fileInput.attr("disabled", false);
                $textarea.width("590px");
                $saveRecordCont.show();
            }
        };
        window.showVideoRecorder = show;
        
        window.setRecordedVideoId = function(id) {
            $videoIdInput.val(id);
        };
    
        $("#saveRecord").click(function(e) {
            e.preventDefault();
            show(true);
        });
    });
};

var attachVideoPlay = function() {
    var clickHandler = function() {
        var $a = $(this);
        var videoSplit = $a.attr("id").split("_");
        var videoId = videoSplit[2] + "_" + videoSplit[3];
    
        $a.before("<div class='right video' id='video_cont_" + videoId + "'>&nbsp;</div>");
        $a.remove();
        
        var flashObject = new SWFObject("http://bz.yaika.ee/BiziWidget.swf", "videoRecorder" + videoId, "216", "185", "9.0.28", "#FFFFFF");
		flashObject.addParam("quality", "high");
        flashObject.addParam("allowScriptAccess", "always");
        flashObject.addParam("allowFullscreen", "true");
        //flashObject.addVariable("locale", "http://bz.yaika.ee/loc_bizi.xml");
		flashObject.addVariable("locale", mainLoc['yaikaurl']);
        flashObject.addVariable("rtmp", "212.47.217.102");
        flashObject.addVariable("status", "viewer");
        flashObject.addVariable("postId", videoId);
        flashObject.write("video_cont_" + videoId);
        
        return false;
    };
    
    $("a[@id^=video_thumb_]").each(function() {
        var $a = $(this);
        
        if (!$a.attr("play_handler_attached")) {
            $a.attr("play_handler_attached", "true");
            $a.click(clickHandler);
        }
    });
};

$(document).ready(function(){
	$("#note").keyup(function(){
		$("#additional_note").empty().append($(this).val());
	});

	$("#choose_photo").hide();
	$("#upload").addClass("current");

	$("#upload").click(function(){
		$("#choose_photo").hide();
		$("#upload_photo").fadeIn("slow");
		$(this).addClass("current");
		$("#photo_set").removeClass("current");
		return false;
	});

	$("#photo_set").click(function(){
		$("#upload_photo").hide();
		$("#choose_photo").fadeIn("slow");
		$(this).addClass("current");
		$("#upload").removeClass("current");
		return false;
	});

	//$("#emailclnt").hide();
	//$("#emailclnt").hide();
	//$("#fbclnt").hide();

	$("#tab_emailclnt").click(function(){
		$("#imclnt").hide();
		$("#fbclnt").hide();
		$("#emailclnt").fadeIn("slow");
		$(this).addClass("current");
		$("#tab_imclnt").removeClass("current");
		$("#tab_fbclnt").removeClass("current");
		return false;
	});
	$("#tab_fbclnt").click(function(){
		$("#imclnt").hide();
		$("#emailclnt").hide();
		$("#fbclnt").fadeIn("slow");
		$(this).addClass("current");
		$("#tab_imclnt").removeClass("current");
		$("#tab_emailclnt").removeClass("current");
		return false;
	});
	$("#tab_imclnt").click(function(){
		$("#emailclnt").hide();
		$("#fbclnt").hide();
		$("#imclnt").fadeIn("slow");
		$(this).addClass("current");
		$("#tab_emailclnt").removeClass("current");
		$("#tab_fbclnt").removeClass("current");
		return false;
	});

	$("img.avatar.choose").click(function(){
		$("img.avatar.choose").removeClass("chosen");
		$(this).addClass("chosen");
		$("#chosen_photo").val($(this).attr("alt"));
		return false;
	});

	$("#message").keyup(function(){
		var chars;
		chars = 140 - countBytes($(this).val());
		if(chars == 0 || chars < 0) $(this).val($(this).val().substr(0, 139))
		$("#chars_left").html(chars);
	});
	$("#bio, #interests").keyup(function(){
		var chars;
		chars = 200 - countBytes($(this).val());
		if(chars == 0 || chars < 0) $(this).val($(this).val().substr(0, 199));
	});


//login/register tabs switching
	if($("#show_register_form").val() == 1){
		$("#login_stuff").hide();
		$("#link_register").addClass("current");
	} else {
		$("#register_stuff").hide();
		$("#link_login").addClass("current");
	}

	$("#link_register").click(function(){
		$("#login_stuff").hide();
		$("#register_stuff").fadeIn("slow");
		$(this).addClass("current");
		$("#link_login").removeClass("current");
		return false;
	});
	$("#link_login").click(function(){
		$("#register_stuff").hide();
		$("#login_stuff").fadeIn("slow");
		$(this).addClass("current");
		$("#link_register").removeClass("current");
		return false;
	});

//direct messages
	$("#dm_outbox").hide();
	$("#link_inbox").addClass("current");
	$("#link_inbox").click(function(){
		$("#dm_outbox").hide();
		$("#dm_inbox").fadeIn("slow");
		$(this).addClass("current");
		$("#link_outbox").removeClass("current");
		return false;
	});
	$("#link_outbox").click(function(){
		$("#dm_inbox").hide();
		$("#dm_outbox").fadeIn("slow");
		$(this).addClass("current");
		$("#link_inbox").removeClass("current");
		return false;
	});

//most popular and most recent users
	$("#most_popular_stuff").hide();
	$("#link_recent").addClass("current");
	var recent = $.ajax({
		url: "ajax/most_recent.php",
		async: false
	}).responseText;
	$("#most_recent_stuff").html(recent);

	$("#link_popular").click(function(){
		$("#most_recent_stuff").hide();
		$("#most_popular_stuff").fadeIn("slow");
		$(this).addClass("current");
		$("#link_recent").removeClass("current");
		var popular = $.ajax({
			url: "ajax/most_popular.php",
			async: false
		}).responseText;
		$("#most_popular_stuff").html(popular);
		recent_popular_enable();
		return false;
	});

	$("#link_recent").click(function(){
		$("#most_popular_stuff").hide();
		$("#most_recent_stuff").fadeIn("slow");
		$(this).addClass("current");
		$("#link_popular").removeClass("current");
		var recent = $.ajax({
			url: "ajax/most_recent.php",
			async: false
		}).responseText;
		$("#most_recent_stuff").html(recent);
		recent_popular_enable();
		return false;
	});

//latest message tooltip
	var winH = $("body").height();
	if(winH < window.innerHeight) winH = window.innerHeight;
	var winW = window.innerWidth;
	var tooltip_w, tooltip_h;
	function eventMouseX(e, w) {
		if (e.pageX) xval = e.pageX;
		//if(xval + w > winW) xval = winW - w - 30;
		return xval;
	}
	function eventMouseY(e, h) {
		if (e.pageY) yval = e.pageY;
		//if(yval + h > winH) yval = winH - h - 30;
		return yval;
	}
	$("body").mousemove(function(e){
		var mouse_x = eventMouseX(e, 200)-100;
		var mouse_y = eventMouseY(e, tooltip_h)+10;
		$("#last_msg_tooltip").css({
			left: mouse_x + 'px',
			top: mouse_y + 'px'
		});
		tooltip_h = $("#last_msg_tooltip").height;
	});
	$(".show_msg_tooltip").hover(function(){
		var markup = $.ajax({
			type: "GET",
			url: "ajax/user_last_message.php",
			data: "user=" + $(this).attr("alt"),
			async: false
		}).responseText;
		$("body").append("<div id='last_msg_tooltip'><strong>" + $(this).attr("alt") + "</strong>: " + markup + "</div>");
	}, function(){
		$("#last_msg_tooltip").remove();
	});
	$(".show_msg_tooltip").mouseout(function(){
		$("#last_msg_tooltip").remove();
	});

	function recent_popular_enable(){
		$(".show_msg_tooltip").hover(function(){
			var markup = $.ajax({
				type: "GET",
				url: "ajax/user_last_message.php",
				data: "user=" + $(this).attr("alt"),
				async: false
			}).responseText;
			$("body").append("<div id='last_msg_tooltip'><strong>" + $(this).attr("alt") + "</strong>: " + markup + "</div>");
		}, function(){
			$("#last_msg_tooltip").remove();
		});
	}
//favorites ajax stuff

	function enable_add(){
		$(".fav_add").click(function(){
			var res = $.ajax({
				type: "GET",
				url: "ajax/add_favorite.php",
				data: "stuff=" + $(this).attr("alt"),
				async: false
			}).responseText;
			var result = res.split('|');
	
			if(result[0] != "OK") alert(mainLoc['errAddFavorite']);
			if(result[0] == "OK") {
				//$(this).parent().append("<img src='grafika/heart_delete.png' class='fav_del' width='16' height='16' alt='"+ $(this).attr("alt") +"' title='"+result[1]+"' />");
				$(this).parent().append("<input type='submit'  name='fav_del' class='fav_del' alt='"+ $(this).attr("alt") +"' value='"+result[1]+"' />");
				enable_del();
				$(this).remove();
			}
		});
	}

	function enable_del(){
		$(".fav_del").click(function(){
			var res = $.ajax({
				type: "GET",
				url: "ajax/del_favorite.php",
				data: "stuff=" + $(this).attr("alt"),
				async: false
			}).responseText;
			var result = res.split('|');
			if(result[0] != "OK") alert(mainLoc['errDelFavorite']);
			if(result[0] == "OK") {
				//$(this).parent().append("<img src='grafika/heart_add.png' class='fav_add' width='16' height='16' alt='"+ $(this).attr("alt") +"' title='Add to favorites' />");
				$(this).parent().append("<input type='submit'  name='fav_add' class='fav_add' alt='"+ $(this).attr("alt") +"' value='"+result[1]+"' />");
				enable_add();
				$(this).remove();
			}
		});
	}

	$(".fav_add").click(function(){
		var res = $.ajax({
			type: "GET",
			url: "ajax/add_favorite.php",
			data: "stuff=" + $(this).attr("alt"),
			async: false
		}).responseText;
		var result = res.split('|');
		if(result[0] != "OK") alert(mainLoc['errAddFavorite']);
		if(result[0] == "OK") {
			//$(this).parent().append("<img src='grafika/heart_delete.png' class='fav_del' width='16' height='16' alt='"+ $(this).attr("alt") +"' title='Remove from favorites' />");
			$(this).parent().append("<input type='submit'  name='fav_del' class='fav_del' alt='"+ $(this).attr("alt") +"' value='"+result[1]+"' />");
			enable_del();
			$(this).remove();
		}
	});

	$(".fav_del").click(function(){
		var res = $.ajax({
			type: "GET",
			url: "ajax/del_favorite.php",
			data: "stuff=" + $(this).attr("alt"),
			async: false
		}).responseText;
		var result = res.split('|');
		if(result[0] != "OK") alert(mainLoc['errDelFavorite']);
		if(result[0] == "OK") {
			//$(this).parent().append("<img src='grafika/heart_add.png' class='fav_add' width='16' height='16' alt='"+ $(this).attr("alt") +"' title='Add to favorites' />");
			$(this).parent().append("<input type='submit'  name='fav_add' class='fav_add' alt='"+ $(this).attr("alt") +"' value='"+result[1]+"' />");
			enable_add();
			$(this).remove();
		}
	});

//scripts to copy and paste
	$("#paste_code").click(function(){
		this.select();
	});
	$("#js_my_status").click(function(){
		this.select();
	});
	$("#js_my_friends").click(function(){
		this.select();
	});

//notification mode setting
	$("#notify_mode1").click(function(){
		set_notify_mode($(this).val());
	});
	$("#notify_mode2").click(function(){
		set_notify_mode($(this).val());
	});
	$("#notify_mode3").click(function(){
		set_notify_mode($(this).val());
	});
	$("#notify_mode4").click(function(){
		set_notify_mode($(this).val());
	});

//message notification
	$("#notify_direct1").click(function(){
		set_msg_notification($(this).val());
	});
	$("#notify_direct2").click(function(){
		set_msg_notification($(this).val());
	});

//autoselect of api key
	$("#api_key").click(function(){
		this.select();
	});

//autofill of the mail address in the invite page
	$("#check_user").val("@hotmail.com");
	$("#check_type").change(function(){
		$("#check_user").val("@"+ $(this).val() +".com");
	});

//password for account deletion
	$("#del_pass_form").hide();
	$("#del_pass").click(function(){
		$(this).hide();
		$("#del_pass_form").show();
	});


// ==========================
// tabs in user's profile
// ==========================

// opening the right tab
	switch($("#current_tab").val()){
		case "mine":
			$("#profile_my_msg").addClass("current");
			$("#profile_my_msg").siblings("a").removeClass("current");
			$("#tab_content").html("<p>Laadib...</p>");
			var stuff = $.ajax({
				type: "GET",
				url: "ajax/messages_mine.php",
				data: "stuff=" + $("#profile_my_msg").attr("rel"),
				async: false
			}).responseText;
			$("#tab_content").html(stuff).fadeIn("slow");
			enable_mine();
			enable_add();
			enable_del();
			break;
		case "with_friends":
			$("#profile_friends").addClass("current");
			$("#profile_friends").siblings("a").removeClass("current");
			$("#tab_content").html("<p>Laadib...</p>");
			var stuff = $.ajax({
				type: "GET",
				url: "ajax/messages_with_friends.php",
				data: "stuff=" + $("#profile_friends").attr("rel"),
				async: false
			}).responseText;
			$("#tab_content").html(stuff).fadeIn("slow");
			enable_add();
			enable_del();
			enable_friends();
			break;
		case "replys":
			$("#profile_replys").addClass("current");
			$("#profile_replys").siblings("a").removeClass("current");
			$("#tab_content").html("<p>Laadib...</p>");
			var stuff = $.ajax({
				type: "GET",
				url: "ajax/messages_replys.php",
				data: "stuff=" + $("#profile_replys").attr("rel"),
				async: false
			}).responseText;
			$("#tab_content").html(stuff).fadeIn("slow");
			enable_add();
			enable_del();
			enable_replys();
			break;
		case "customize":
			$("#profile_customize").addClass("current");
			$("#profile_customize").siblings("a").removeClass("current");
			var stuff = $.ajax({
				type: "GET",
				url: "ajax/profile_customize.php",
				data: "user=" + $("#current_user").val(),
				async: false
			}).responseText;
			$("#tab_content").html(stuff).fadeIn("slow");
			enable_customize();
			break;
		default:
//			$("#profile_my_msg").addClass("current");
//			$("#profile_my_msg").siblings("a").removeClass("current");
//			$("#tab_content").html("<p>Laadib...</p>");
//			var stuff = $.ajax({
//				type: "GET",
//				url: "ajax/messages_mine.php",
//				data: "stuff=" + $("#profile_my_msg").attr("rel"),
//				async: false
//			}).responseText;
//			$("#tab_content").html(stuff).fadeIn("slow");
//			enable_mine();
//			enable_add();
//			enable_del();
//			break;
	}
// when user clicks on a tab...
	$("#profile_my_msg").click(function(){
		$(this).addClass("current");
		$(this).siblings("a").removeClass("current");
		$("#tab_content").html("<p>Laadib...</p>");
		var stuff = $.ajax({
			type: "GET",
			url: "ajax/messages_mine.php",
			data: "stuff=" + $(this).attr("rel"),
			async: false
		}).responseText;
		$("#tab_content").html(stuff).fadeIn("slow");
		attachThickbox();
		attachVideoPlay();
		enable_mine();
		return false;
	});

	$("#profile_friends").click(function(){
		$(this).addClass("current");
		$(this).siblings("a").removeClass("current");
		$("#tab_content").html("<p>Laadib...</p>");
		var stuff = $.ajax({
			type: "GET",
			url: "ajax/messages_with_friends.php",
			data: "stuff=" + $(this).attr("rel"),
			async: false
		}).responseText;
		$("#tab_content").html(stuff).fadeIn("slow");
		attachThickbox();
		attachVideoPlay();
		enable_add();
		enable_del();
		enable_friends();
		return false;
	});
	$("#profile_replys").click(function(){
		$(this).addClass("current");
		$(this).siblings("a").removeClass("current");
		$("#tab_content").html("<p>Laadib...</p>");
		var stuff = $.ajax({
			type: "GET",
			url: "ajax/messages_replys.php",
			data: "stuff=" + $(this).attr("rel"),
			async: false
		}).responseText;
		$("#tab_content").html(stuff).fadeIn("slow");
		attachThickbox();
		attachVideoPlay();
		enable_add();
		enable_del();
		enable_replys();
		return false;
	});
	$("#profile_customize").click(function(){
		$(this).addClass("current");
		$(this).siblings("a").removeClass("current");
		var stuff = $.ajax({
			type: "GET",
			url: "ajax/profile_customize.php",
			data: "user=" + $(this).attr("rel"),
			async: false
		}).responseText;
  		$("#tab_content").html(stuff).fadeIn("slow");
  		attachThickbox();
  		attachVideoPlay();
		enable_customize();
		return false;
	});

    var attachThickbox = function() {
        tb_init('a.thickbox,area.thickbox,input.thickbox');
    };
	attachThickbox();

// pagination enable
	function enable_mine(){
		$("a.pagination.mine").click(function(){
			$("#tab_content").empty().html("<p>Laadib...</p>");
			var stuff = $.ajax({
				type: "GET",
				url: "ajax/messages_mine.php",
				data: "stuff=" + $(this).attr("rel"),
				async: false
			}).responseText;
			$("#tab_content").hide().empty().html(stuff).fadeIn("slow");
			enable_mine();
			attachThickbox();
			return false;
		});
	}

	function enable_friends(){
		$("a.pagination.friends").click(function(){
			$("#tab_content").empty().html("<p>Laadib...</p>");
			var stuff = $.ajax({
				type: "GET",
				url: "ajax/messages_with_friends.php",
				data: "stuff=" + $(this).attr("rel"),
				async: false
			}).responseText;
			$("#tab_content").html(stuff).fadeIn("slow");
			enable_add();
			enable_del();
			enable_friends();
			attachThickbox();
			return false;
		});
	}

	function enable_replys(){
		$("a.pagination.replys").click(function(){
			$("#tab_content").empty().html("<p>Laadib...</p>");
			var stuff = $.ajax({
				type: "GET",
				url: "ajax/messages_replys.php",
				data: "stuff=" + $(this).attr("rel"),
				async: false
			}).responseText;
			$("#tab_content").hide().empty().html(stuff).fadeIn("slow");
			enable_add();
			enable_del();
			enable_replys();
			attachThickbox();
			return false;
		});
	}

	//color picker stuff
    var add_picker = (function() {
        var current_element = null;
        var showHandler = null;

        var close = function() {
            current_element.parent().unbind('click', showHandler);
            if(current_element.val().substr(0, 1) == "#") current_element.val(current_element.val().substr(1));
            current_element.css("background", "#"+current_element.val());
            switch(current_element.attr("id")){
                case "back_color":
                    $("html").css("background-color", "#" + current_element.val());
                    break;
                case "side_fill_color":
                    $(".side_stuff").css("background", "#" + current_element.val());
                    break;
                case "text_color":
                    $("*, h1, h2, h3, h4, #footer, #copyright").not("a").css("color", "#"+current_element.val());
                    break;
                case "link_color":
                    $("a, a:visited, #footer a, #footer a:visited, .side_middle a, .side_middle a:visited, .username, .username:visited").css("color", "#"+current_element.val());
                    $("input.submit").css("background-color", "#"+current_element.val());
                    break;
                case "top_area_color":
                    $("#profile_header").css("background", "#" + current_element.val());
                    break;
            }
            $("#colorpicker").remove();
            current_element = null;
            showHandler = null;

            return false;
        };

        $(function() {
            $("body").click(function() {
                if (current_element) {
                    close();
                }
            });
        });

        return function(currentElem) {
            if (current_element) {
                close();
            }
            current_element = currentElem;

            var move_picker = true;
            current_element.parent().prepend("<div id='colorpicker'><div id='wheel'></div><a id='cmClose' href='#'>" + mainLoc['selectColor'] + "</a></div>");
            $("#wheel").farbtastic(current_element);
            $("#colorpicker").show();
            
            showHandler = function(e) {
                var mouse_x = eventMouseX(e, 200)-100;
                var mouse_y = eventMouseY(e, $("#colorpicker").height())+10;
                if(move_picker == true){
                    $("#colorpicker").css({
                        left: mouse_x + 'px',
                        top: mouse_y + 'px'
                    });
                    move_picker = false;
                }
                
                return false;
            };
            
            current_element.parent().click(showHandler);
            $("#cmClose").click(close);

            return false;
        };
    })();

	var current_element;
	$("#colorpicker").hide();
	if($("#current_tab").val() != "customize") enable_customize();

	function bglib_enable(){
		$("#backs").hide();
		$(".back_lib").click(function(){
			var x = false;
			if(x==false){
				$("#backs").show("slow");
				x = true;
			} else {
				$("#backs").fadeOut("slow");
				x = false;
			}
			return false;
		});
		$("a.bglib_link").click(function(){
			$("a.bglib_link").not($(this)).children("img").removeClass("bglib_pic_current").addClass("bglib_pic");
			$(this).children("img").removeClass("bglib_pic").addClass("bglib_pic_current");
			$("#background_name").val($(this).attr("rel"));
			$("#use_image1").attr("checked", "checked");
			return false;
		});
	}

	function enable_customize(){
		bglib_enable();
		$("#sticker_color").css("background", "#"+$("#sticker_color").val());
		$("#sticker_color").click(function(){add_picker($(this));});

		$("#back_color").css("background", "#"+$("#back_color").val());
		$("#back_color").click(function(){add_picker($(this));});

		$("#text_color").css("background", "#"+$("#text_color").val());
		$("#text_color").click(function(){add_picker($(this));});

		$("#link_color").css("background", "#"+$("#link_color").val());
		$("#link_color").click(function(){add_picker($(this));});

		$("#side_fill_color").css("background", "#"+$("#side_fill_color").val());
		$("#side_fill_color").click(function(){add_picker($(this));});

		$("#top_area_color").css("background", "#"+$("#top_area_color").val());
		$("#top_area_color").click(function(){add_picker($(this));});
	}

//invitations check all and uncheck all
	$("#check_all").click(function(){
		$("table input").attr("checked", "checked");
		return false;
	});
	$("#uncheck_all").click(function(){
		$("table input").removeAttr("checked");
		return false;
	});

//blocking confirmation
	$(".block_user").click(function(){
		return confirm(mainLoc['lockMember']);
	});

	$("#search_words").click(function(){
		$(this).val(' ');
	});
	
	$("#search_words").blur(function(){
		if($(this).val() == "") $(this).val(" " + mainLoc['search']);
	});
	
	$("#search").click(function(){
		var a = $("#search_words").val();
		if ((a == "") || (a == " " + mainLoc['search']) || (a.length < 3)){
			return false;
		}
	});

	$("a.infoclose").click(function(){
		var stuff = $.ajax({
			type: "GET",
			url: "ajax/infoline_close.php",
			async: false
		}).responseText;
		$("#infoline").hide();
		return false;
	});    
    
    attachVideoPlay();

//sms credit paypal form
	if($("#item_name").val() != "") $("#item_name").parent().submit();
});

