// JavaScript Document

/***** GLOBALS **********/
var _SITE_ROOT = location.protocol + '//' + location.host + '/';
var _AJAX_ROOT = _SITE_ROOT + 'ajax/';

/***** JQUERY INIT *****/
$(document).ready(function(){
	/*
	* Triggers when DOM is fully loaded
	* but before all content are loaded.
	* Good place to run fast functions
	* that only depend on the DOM
	*/
	// Set autocomplete for post search
	$('#txtInlSearch').autocomplete({serviceUrl:_AJAX_ROOT + 'ac_post.php', noCache:true, onSelect:inlFritextSearch});
	$('#txtInlSearch').keydown(function(e){if(e.which==13)inlFritextSearch();});
	// Set autocomplete for profile search
	$('#txtMedSearch').autocomplete({serviceUrl:_AJAX_ROOT + 'ac_profil.php', noCache:true, onSelect:medSearchByName, minChars:2});
	$('#txtMedSearch').keydown(function(e){if(e.which==13)medSearchByName();});
	// Hide NybrevMessBox
	$('#nybrvMess').hide();
	// Set nyhetsbrevs functions
	$('#prenNybrvBtn').click(function(){
		if($('#txtNyhetsbrev').val().length > 0 && $('#txtNyhetsbrev').val() != "Skriv in din e-post"){
			$.get(parent._AJAX_ROOT + 'mail_server.php',{email:$('#txtNyhetsbrev').val(),typ:'pren'},function(Data){
				$('#nybrvFull').hide();
				$('#nybrvMess').html(Data).show();
				var t = setTimeout(function(){$('#nybrvMess').hide(); $('#nybrvFull').show(); $('#txtNyhetsbrev').focus();},5000);
			});
		}
	});
	// Initiate internmeddelande tabs
	 $("#internmeddelandeTabs").tabs({
    	select: function(event, ui){
        	$('#internmeddelandeprofile').html('');
			$('#internmeddelandeTextbox').html('');
    	},
		load: function(event, ui){
			if(ui.index == 0){
				// Set mouseover/out behaviour on Mail-Rows
				$('tr.mailFrRow').hover(function(){$(this).css('background-color','#FF9');}, function(){$(this).css('background-color','#FFF');});
				// Set onclick for mailrows
				$('tr').filter(function(index){return $(this).attr('class') == 'mailFrRow';}).click(function(){
					var mailid = $(this).attr('relmid');
					var profileid = $(this).attr('relpid');
					$('tr.mailFrAct > td').css('background-color','#FFF');
					$('tr.mailFrAct').each(function(){$(this).removeClass().addClass('mailFrRow');});
					$(this).removeClass().addClass('mailFrAct').css({'background-color': '#FF9', 'font-weight': 'normal'});
					$('tr.mailFrAct > td').css('background-color','#FF9');
					$('td').filter(function(index){return $(this).attr('rel') == mailid && $(this).attr('class') == 'mailIconUnread';}).removeClass().addClass('mailIconRead');
					$.get(_AJAX_ROOT + 'mail_server.php',{pid:profileid},function(Data){$('#internmeddelandeprofile').html(Data);});
					$.get(_AJAX_ROOT + 'mail_server.php',{mbid:mailid, typ:'mailbody', dir:'in'},function(Data){$('#internmeddelandeTextbox').html(Data);});
				});
				$('tr.mailFrRow').first().click();
			}
			else{
				// Set mouseover/out behaviour on Mail-Rows
				$('tr.mailToRow').hover(function(){$(this).css('background-color','#FF9');}, function(){$(this).css('background-color','#FFF');});
				// Set onclick for mailrows
				$('tr').filter(function(index){return $(this).attr('class') == 'mailToRow';}).click(function(){
					var mailid = $(this).attr('relmid');
					var profileid = $(this).attr('relpid');
					$('tr.mailToAct > td').css('background-color','#FFF');
					$('tr.mailToAct').each(function(){$(this).removeClass().addClass('mailToRow');});
					$(this).removeClass().addClass('mailToAct').css({'background-color': '#FF9', 'font-weight': 'normal'});
					$('tr.mailToAct > td').css('background-color','#FF9');
					$.get(_AJAX_ROOT + 'mail_server.php',{pid:profileid},function(Data){$('#internmeddelandeprofile').html(Data);});
					$.get(_AJAX_ROOT + 'mail_server.php',{mbid:mailid, typ:'mailbody', dir:'out'},function(Data){$('#internmeddelandeTextbox').html(Data);});
				});
				$('tr.mailToRow').first().click();
			}
    	}
	});
	// Run the init function
	init();
	
});

$(window).load(function(){
	/*
	* Triggers when all content in the page 
	* is fully loaded.
	* Good place to run functions that depend
	* on content (heights of images and boxes etc.)
	*/
	// Adjust leftcolumn height
	setMainColH();
	// Set profilepopups
	setProfilePopups();
	
});

function setHemlnkPos(){
	var s = $('#head_top').offset();
	$('#head_top_hemlnk').css({ left: (s.left + 12) + 'px' });
}

function setMainColH(){
	var fOS = $('#layout_footer').offset();
	var mOS = $('#layout_main').offset();
	var mHeigth = $('#layout_main').height();
	var mEp = mOS.top + mHeigth + 20;
	if(fOS.top > mEp){
		var nyh = fOS.top - mOS.top - 20;
		$('#layout_main').css({height:nyh + 'px'});
	}
}

function setMainColHaftCom(){
	var cOS = $('#commentListInlagg').offset();
	var cHe = $('#commentListInlagg').height();
	var cTo = cOS.top + cHe;
	var mOS = $('#layout_main').offset();
	var mHe = $('#layout_main').height();
	var mTo = mOS.top + mHe;
	if(cTo > mTo){
		var nyh = cTo - mOS.top + 20;
		$('#layout_main').css({height:nyh + 'px'});
	}
}

function setProfilePopups(){
	$('#profilePopUpDiv').hide();
	$('#profilePopUpDiv').mouseleave(function(){
		$(this).offset({top:0,left:0});
		$(this).html('');
		$(this).hide();
	});
	$("span.profiletrg").mouseenter(function(){
		if($('#profilePopUpDiv').is(':hidden')){
			var s = $(this).offset();
			$('#profilePopUpDiv').css({ top: (s.top - 20) + 'px', left: (s.left + 10) + 'px' });
			$.get(_AJAX_ROOT + 'get_miniprofile.php',{mid:$(this).attr('mid')},function(Data){
    			$('#profilePopUpDiv').html(Data);
			});
			$('#profilePopUpDiv').show();
		}
  	});
}

// INIT-FUNCTION
// *************
function init(){
	// Set Hemlnk
	setHemlnkPos();
	// Set mouseover/out behaviour on listpage-paging
	$('li.pagingItem').hover(
		function(){$(this).css('background-color','#FF9');},
		function(){$(this).css('background-color','#FFF');}
	);
	// Set mouseover/out behaviour on hem-paging
	$('div.pagPrevActive,div.pagNextActive').hover(
		function(){$(this).css('background-color','#FF9');},
		function(){$(this).css('background-color','#FFF');}
	);
	// Set show/hide on most-lists
	$('ul').filter(function(index){
		return $(this).attr('rel') == '12' || $(this).attr('rel') == '13' || $(this).attr('rel') == '22' || $(this).attr('rel') == '23';
	}).hide();
	// Set onclick for most-list-view-navigation
	$('span').filter(function(index){
		return $(this).attr('rel') == '11' || $(this).attr('rel') == '12' || $(this).attr('rel') == '13';
	}).click(function(){
		var valnum = $(this).attr('rel');
		$('span').each(function(){
			if($(this).attr('rel') == '11'){
				valnum == '11' ? $(this).removeClass().addClass('Aktiv') : $(this).removeClass().addClass('Item');}
			if($(this).attr('rel') == '12'){
				valnum == '12' ? $(this).removeClass().addClass('Aktiv') : $(this).removeClass().addClass('Item');}
			if($(this).attr('rel') == '13'){
				valnum == '13' ? $(this).removeClass().addClass('Aktiv') : $(this).removeClass().addClass('Item');}
		});
		$('ul').each(function(){
			if($(this).attr('rel') == '11'){
				valnum == '11' ? $(this).show() : $(this).hide();}
			if($(this).attr('rel') == '12'){
				valnum == '12' ? $(this).show() : $(this).hide();}
			if($(this).attr('rel') == '13'){
				valnum == '13' ? $(this).show() : $(this).hide();}
		});
    });
	// Set onclick for most-list-com-navigation
	$('span').filter(function(index){
		return $(this).attr('rel') == '21' || $(this).attr('rel') == '22' || $(this).attr('rel') == '23';
	}).click(function(){
		var valnum = $(this).attr('rel');
		$('span').each(function(){
			if($(this).attr('rel') == '21'){
				valnum == '21' ? $(this).removeClass().addClass('Aktiv') : $(this).removeClass().addClass('Item');}
			if($(this).attr('rel') == '22'){
				valnum == '22' ? $(this).removeClass().addClass('Aktiv') : $(this).removeClass().addClass('Item');}
			if($(this).attr('rel') == '23'){
				valnum == '23' ? $(this).removeClass().addClass('Aktiv') : $(this).removeClass().addClass('Item');}
		});
		$('ul').each(function(){
			if($(this).attr('rel') == '21'){
				valnum == '21' ? $(this).show() : $(this).hide();}
			if($(this).attr('rel') == '22'){
				valnum == '22' ? $(this).show() : $(this).hide();}
			if($(this).attr('rel') == '23'){
				valnum == '23' ? $(this).show() : $(this).hide();}
		});
    });

	
}

// NOMINATE MEMBER OF THE MONTH
//*****************************
function nominateMonMed(givid,getid){
	if(confirm("Bekräfta din nominering av denna medlem?")){
		$.post(_AJAX_ROOT + 'profil_server.php',{typ:'nominate', geid:givid, faid:getid},function(Data){});
		$('#nomMonMedOpen').hide();
		$('#nomMonMedClosed').show();
	}
}

// SHOW NOMINATED MEMBERS THIS MONTH
//**********************************
function showMonMedNom(){
	$.fancybox({
		'showCloseButton'   : true,
		'hideOnOverlayClick': false,
		'hideOnContentClick': false,
		'autoDimensions'    : false,
		'autoScale'         : false,
		'scrolling'         : 'auto',
		'width'             : 360,
		'height'            : 420,
		'href'			    : _AJAX_ROOT + 'manmed_shownom.php',
		'type'			    : 'iframe'
	});
}

// SET INTERNMEDDELANDE REPLYED
//*****************************
function mailReplyed(mailid){
	$('td').filter(function(index){
		return $(this).attr('rel') == mailid;
		}).removeClass().addClass('mailIconReplyed');
}

// SHOW INTERNMEDDELANDE-POPUP
// ***************************
function showMailEdit(mailid,toid){
	if(checkCookie('Mid')){
		$.fancybox({
			'showCloseButton'   : true,
			'hideOnOverlayClick': false,
			'hideOnContentClick': false,
			'autoDimensions'    : false,
			'autoScale'         : false,
			'scrolling'         : 'no',
			'width'             : 360,
			'height'            : 420,
			'href'			    : _AJAX_ROOT + 'mail_edit.php?imid=' + mailid + '&topid=' + toid,
			'type'			    : 'iframe'
		});
	}
	else{
		ShowLogin('internmeddelande');
	}
}

// DELETE INTERNMEDDELANDE
//************************
function delInternmeddelande(mailid,dirre){
	if(confirm("Är du säker att du vill ta bort meddelandet?")){
		$.get(_AJAX_ROOT + 'mail_server.php',{mbid:mailid, typ:'del', dir:dirre},function(Data){});
		$('#internmeddelandeTextbox').html('');
		$('#internmeddelandeprofile').html('');
		$('tr').filter(function(index){return $(this).attr('relmid') == mailid;}).css('display','none');
		if(dirre == 'from'){
			$('tr.mailFrRow').first().click();
		}
		else{
			$('tr.mailToRow').first().click();
		}
	}
}

// CONFIRM FRIEND
//***************
function confFriend(myID,frID){
	if(confirm("Vill du acceptera denna kompis?")){
		$.post(_AJAX_ROOT + 'profil_server.php',{typ:'confirmfriend', pid:myID, fpid:frID},function(Data){
			alert("Ni är nu vänner!");
		});
	}
}

// ADD FRIEND
//***********
function addFriend(myID,frID){
	if(confirm("Vill du lägga till denna kompis?")){
		$.post(_AJAX_ROOT + 'profil_server.php',{typ:'addfriend', pid:myID, fpid:frID},function(Data){
			location.reload();
		});
	}
}

// DELETE FRIEND
//**************
function delFriend(myID,frID){
	if(confirm("Vill du ta bort denna kompis?")){
		$.post(_AJAX_ROOT + 'profil_server.php',{typ:'delfriend', pid:myID, fpid:frID},function(Data){
			location.reload();
		});
	}
}

// DELETE PROFIL-LAND
//*******************
function profilDelLand(profid,landid){
	if(confirm("Vill du ta bort detta land?")){
		$.post(_AJAX_ROOT + 'profil_server.php',{typ:'delland', pid:profid, lid:landid},function(Data){
			location.reload();
		});
	}
}

// ADD PROFIL-LAND
//****************
function profilNyttLand(pid){
	$.fancybox({
		'showCloseButton'   : true,
		'hideOnContentClick': false,
		'hideOnOverlayClick': false,
		'autoDimensions'    : false,
		'autoScale'         : false,
		'scrolling'         : 'no',
		'width'             : 340,
		'height'            : 220,
		'href'			    : _AJAX_ROOT + 'profil_prevland.php?id=' + pid,
		'type'			    : 'iframe',
		'onClosed'          : function(){location.reload();}
	});
}

// CHECK COOKIE
//*************
function checkCookie(c_name){
	var retVal = false;
	if(document.cookie.length > 0){
  		var c_start = document.cookie.indexOf(c_name + "=");
  		if(c_start != -1){
			retVal = true;
		}
	}
	return retVal;
}

// SHOW COMMENTS-POPUP
// *******************
function showCommentPopup(pidVal,avdVal){
	if(checkCookie('Mid')){
		$.fancybox({
			'showCloseButton'   : true,
			'hideOnOverlayClick': false,
			'hideOnContentClick': false,
			'autoDimensions'    : false,
			'autoScale'         : false,
			'scrolling'         : 'no',
			'transitionIn'	    : 'elastic',
			'transitionOut'	    : 'elastic',
			'speedIn'           : 300,
			'speedOut'          : 300,
			'orig'              : $('#btnFormComment'),
			'width'             : 360,
			'height'            : 350,
			'href'			    : _AJAX_ROOT + 'comment_edit.php?pid=' + pidVal + '&avd=' + avdVal,
			'type'			    : 'iframe',
			'onClosed': function(){
				var cur_num = $('#numofcom').text();
				var new_num;
				$.post(_AJAX_ROOT + 'comment_server.php',{avd:avdVal,pid:pidVal,typ:'num'},function(Data){
					new_num = Data;
					if(new_num > cur_num)
					{
						$('#numofcom').text(new_num);
						showCommentList(avdVal,pidVal,1,'get');
					}
				});
			}
		});
	}
	else{
		ShowLogin('comment');
	}
}

// SHOW OR UPDATE LIST OF COMMENTS
// *******************************
function showCommentList(avdVal,pidVal,pageVal,typVal){
	$.post(_AJAX_ROOT + 'comment_server.php',{avd:avdVal,pid:pidVal,pag:pageVal,typ:typVal},function(Data){
    	$('#commentListInlagg').html(Data);
		setProfilePopups();
		setMainColHaftCom();
	});
}

// SHOW OR UPDATE LIST OF EVENTS
// *****************************
function showEventList(pageVal,typVal){
	$.post(_AJAX_ROOT + 'event_server.php',{pag:pageVal,typ:typVal},function(Data){
    	$('#eventListBox').html(Data);
	});
}

// SHOW LOGIN-POPUP
// ****************
function ShowLogin(qStr){
	if(!checkCookie('Mid')){
		if(qStr == 'comment')
			qStr = '?comment=1';
		else if(qStr == 'post')
			qStr = '?post=1';
		else if(qStr == 'formaner')
			qStr = '?formaner=1';
		else if(qStr == 'internmeddelande')
			qStr = '?internmeddelande=1';	
		$.fancybox({
			'showCloseButton'   : true,
			'hideOnContentClick': false,
			'hideOnOverlayClick': false,
			'autoDimensions'    : false,
			'autoScale'         : false,
			'scrolling'         : 'no',
			'transitionIn'	    : 'elastic',
			'transitionOut'	    : 'elastic',
			'speedIn'           : 300,
			'speedOut'          : 300,
			'orig'              : $('#headLoginBtn'),
			'width'             : 360,
			'height'            : 320,
			'href'			    : _AJAX_ROOT + 'login.php' + (qStr == null ? '' : qStr),
			'type'			    : 'iframe',
			'onClosed'          : function(){location.href =  _SITE_ROOT + 'hem';}
		});
	}
}

// SHOW LOGOUT-POPUP
// *****************
function ShowLogout(){
	if(checkCookie('Mid')){
		$.fancybox({
			'showCloseButton'   : true,
			'hideOnContentClick': false,
			'hideOnOverlayClick': false,
			'autoDimensions'    : false,
			'autoScale'         : false,
			'scrolling'         : 'no',
			'transitionIn'	    : 'elastic',
			'transitionOut'	    : 'elastic',
			'speedIn'           : 300,
			'speedOut'          : 300,
			'orig'              : $('#logoutBtn'),
			'width'             : 200,
			'height'            : 200,
			'href'			    : _AJAX_ROOT + 'logout.php',
			'type'			    : 'iframe',
			'onClosed'          : function(){location.href =  _SITE_ROOT + 'hem';}
		});
	}
}

// SHOW FORGOTPASS-POPUP
// *********************
function ShowForgotPass(){
	$.fancybox({
		'showCloseButton'   : true,
		'hideOnContentClick': false,
		'hideOnOverlayClick': false,
		'autoDimensions'    : false,
		'autoScale'         : false,
		'scrolling'         : 'no',
		'width'             : 360,
		'height'            : 280,
		'href'			    : _AJAX_ROOT + 'forgotpass.php',
		'type'			    : 'iframe'
	});
}

// SHOW EDIT EVENT-(POPUP)
// **********************
function ShowEditEvent(EID){
	if(checkCookie('Mid')){
		$.fancybox({
			'showCloseButton'   : true,
			'hideOnContentClick': false,
			'hideOnOverlayClick': false,
			'autoDimensions'    : false,
			'autoScale'         : false,
			'scrolling'         : 'no',
			'transitionIn'	    : 'elastic',
			'transitionOut'	    : 'elastic',
			'speedIn'           : 300,
			'speedOut'          : 300,
			'width'             : 480,
			'height'            : 660,
			'href'			    : _AJAX_ROOT + 'event_edit.php?eid=' + EID,
			'type'			    : 'iframe',
			'onClosed'          : function(){location.href =  _SITE_ROOT + 'hem';}
		});
	}
	else{
		ShowLogin('post');
	}
}

// SHOW EDIT POST-(POPUP)
// **********************
function ShowEditPost(PID,BTN){
	if(checkCookie('Mid')){
		$.fancybox({
			'showCloseButton'   : true,
			'hideOnContentClick': false,
			'hideOnOverlayClick': false,
			'autoDimensions'    : false,
			'autoScale'         : false,
			'scrolling'         : 'no',
			'transitionIn'	    : 'elastic',
			'transitionOut'	    : 'elastic',
			'speedIn'           : 300,
			'speedOut'          : 300,
			'orig'              : $('#' + BTN),
			'width'             : 480,
			'height'            : 660,
			'href'			    : _AJAX_ROOT + 'post_edit.php?pid=' + PID,
			'type'			    : 'iframe',
			'onClosed'          : function(){location.href =  _SITE_ROOT + 'hem';}
		});
	}
	else{
		ShowLogin('post');
	}
}

// SHOW ABUSE-(POPUP)
// ******************
function ShowAbuse(typId,itmId,usrId){
	if(checkCookie('Mid')){
		$.fancybox({
			'showCloseButton'   : true,
			'hideOnContentClick': false,
			'hideOnOverlayClick': false,
			'autoDimensions'    : false,
			'autoScale'         : false,
			'scrolling'         : 'no',
			'width'             : 360,
			'height'            : 320,
			'href'			    : _AJAX_ROOT + 'abuse.php?typid=' + typId + '&itmid=' + itmId + '&usrid=' + usrId,
			'type'			    : 'iframe'
		});
	}
}

// SHOW REGISTRATION-(POPUP)
// *************************
function ShowRegistration(){
	$.fancybox({
		'showCloseButton'   : true,
		'hideOnContentClick': false,
		'hideOnOverlayClick': false,
		'autoDimensions'    : false,
		'autoScale'         : false,
		'scrolling'         : 'auto',
		'width'             : 520,
		'height'            : 520,
		'href'			    : _AJAX_ROOT + 'registration.php',
		'type'			    : 'iframe',
		'onClosed'          : function(){location.href =  _SITE_ROOT + 'hem';}
	});
}

// SHOW EDIT PROFIL-(POPUP)
// *************************
function profilEdit(id){
	$.fancybox({
		'showCloseButton'   : true,
		'hideOnContentClick': false,
		'hideOnOverlayClick': false,
		'autoDimensions'    : false,
		'autoScale'         : false,
		'scrolling'         : 'auto',
		'width'             : 520,
		'height'            : 600,
		'href'			    : _AJAX_ROOT + 'profil_edit.php?id=' + id,
		'type'			    : 'iframe',
		'onClosed'          : function(){location.reload();}
	});
}

// SHOW ACTIVATION-(POPUP)
// *************************
function ShowActivation(kod){
	$.fancybox({
		'showCloseButton'   : true,
		'hideOnContentClick': false,
		'hideOnOverlayClick': false,
		'autoDimensions'    : false,
		'autoScale'         : false,
		'scrolling'         : 'no',
		'width'             : 360,
		'height'            : 320,
		'href'			    : _AJAX_ROOT + 'activation.php?kod=' + kod,
		'type'			    : 'iframe',
		'onClosed'          : function(){location.href =  _SITE_ROOT + 'hem';}
	});
}

// SHOW MAIL OPTIN-(POPUP)
// *************************
function ShowMailOptIn(kod){
	$.fancybox({
		'showCloseButton'   : true,
		'hideOnContentClick': false,
		'hideOnOverlayClick': false,
		'autoDimensions'    : false,
		'autoScale'         : false,
		'scrolling'         : 'no',
		'width'             : 360,
		'height'            : 320,
		'href'			    : _AJAX_ROOT + 'mail_server.php?typ=optin&kod=' + kod,
		'type'			    : 'iframe',
		'onClosed'          : function(){location.href =  _SITE_ROOT + 'hem';}
	});
}

// SHOW MAIL OPTOUT-(POPUP)
// *************************
function ShowMailOptOut(email){
	$.fancybox({
		'showCloseButton'   : true,
		'hideOnContentClick': false,
		'hideOnOverlayClick': false,
		'autoDimensions'    : false,
		'autoScale'         : false,
		'scrolling'         : 'no',
		'width'             : 360,
		'height'            : 320,
		'href'			    : _AJAX_ROOT + 'mail_server.php?typ=optout&email=' + email,
		'type'			    : 'iframe',
		'onClosed'          : function(){location.href =  _SITE_ROOT + 'hem';}
	});
}

// EDIT PAGE - ADMIN - (POPUP)
// ***************************
function EditPage(id){
	$.fancybox({
		'showCloseButton'   : true,
		'hideOnContentClick': false,
		'hideOnOverlayClick': false,
		'autoDimensions'    : false,
		'autoScale'         : false,
		'scrolling'         : 'auto',
		'width'             : 480,
		'height'            : 660,
		'href'			    : _AJAX_ROOT + 'page_edit.php?id=' + id,
		'type'			    : 'iframe',
		'onClosed'          : function(){location.reload();}
	});
}

// EDIT MANMED - ADMIN - (POPUP)
// *****************************
function EditManMed(id){
	$.fancybox({
		'showCloseButton'   : true,
		'hideOnContentClick': false,
		'hideOnOverlayClick': false,
		'autoDimensions'    : false,
		'autoScale'         : false,
		'scrolling'         : 'auto',
		'width'             : 480,
		'height'            : 660,
		'href'			    : _AJAX_ROOT + 'manmed_edit.php?id=' + id,
		'type'			    : 'iframe',
		'onClosed'          : function(){if(id > 0){location.reload();}}
	});
}

// LIST KATEGORI - ADMIN - (POPUP)
// *******************************
function ListKategori(){
	$.fancybox({
		'showCloseButton'   : true,
		'hideOnContentClick': false,
		'hideOnOverlayClick': false,
		'autoDimensions'    : false,
		'autoScale'         : false,
		'scrolling'         : 'auto',
		'width'             : 480,
		'height'            : 660,
		'href'			    : _AJAX_ROOT + 'kategori_list.php',
		'type'			    : 'iframe'
	});
}

// LIST ANNONS - ADMIN - (POPUP)
// *****************************
function ListAnnons(){
	$.fancybox({
		'showCloseButton'   : true,
		'hideOnContentClick': false,
		'hideOnOverlayClick': false,
		'autoDimensions'    : false,
		'autoScale'         : false,
		'scrolling'         : 'auto',
		'width'             : 994,
		'height'            : 660,
		'href'			    : _AJAX_ROOT + 'annons_list.php',
		'type'			    : 'iframe'
	});
}

// SEARCH PROFILE - ADMIN - (POPUP)
// ********************************
function SokProfil(){
	$.fancybox({
		'showCloseButton'   : true,
		'hideOnContentClick': false,
		'hideOnOverlayClick': false,
		'autoDimensions'    : false,
		'autoScale'         : false,
		'scrolling'         : 'auto',
		'width'             : 994,
		'height'            : 660,
		'href'			    : _AJAX_ROOT + 'profil_sok.php',
		'type'			    : 'iframe'
	});
}

// ADD FILE - ADMIN - (POPUP)
// **************************
function AddFil(){
	mcImageManager.browse({
		fields:'url',
		relative_urls:true
	});
}

// SÖK MEDLEM PÅ NAMN
// ******************
function medSearchByName(){
	if($('#txtMedSearch').val() != '' && $('#txtMedSearch').val() != 'Sök på medlems namn'){
		location.href = _SITE_ROOT + 'profil/namn/' + $('#txtMedSearch').val() + '/1';
	}
}

// SÖK MEDLEM I LAND
// *****************
function medSearchByCountry(){
	if($('#ddMedSearch').val() != '0'){
		location.href = $('#ddMedSearch').val();
	}
}

// FRITEXTSÖK INLÄGG
// *****************
function inlFritextSearch(){
	if($('#txtInlSearch').val() != '' && $('#txtInlSearch').val() != 'Fritextsök inlägg'){
		location.href = _SITE_ROOT + 'inlagg/sok/' + $('#txtInlSearch').val() + '/1';
	}
}

//SÖK INLÄGG BY COUNTRY/CATEGORY
//******************************
function inlSearchBy(search_type){
	if($('#ddInlSearchBy' + search_type).val() != '0'){
		location.href = $('#ddInlSearchBy' + search_type).val();
	}
}




