var isgroup = false;
var isShift=null;
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
var OP = (navigator.appName.indexOf("Opera")!=-1);
if(OP)isNN=true;
var key;
function xkeyd(event){
    key = (isNN) ? event.which : event.keyCode;
    if (key==17)isShift=1;
    return false;
}
function xkeypr(event){
    key = (isNN) ? event.which : event.keyCode;
    if ((key==13 || key == 10) &&isShift==1){
        document.quickaddform.submit();
    }
    if (key!=17)isShift=null;
    return false;
}


function setPicture(name, uid) {
		
	var obj = document.forms['blog'].gallery;
	var pobj = document.forms['blog'].picture;
	
	var gallery_id = obj.options[obj.options.selectedIndex].value;
	var gallery_name = obj.options[obj.options.selectedIndex].text;
	
	var p = (isgroup == 1) ? '/mb_groupuploads/' : '/mb_useruploads/';

	if(name == '' || !name || name.indexOf('.') == -1) {
		
		if($('imgAvatarAuswahl')) {
			$('imgAvatarAuswahl').src = '/images/1pixeltransparent.gif';
			$('imgInsertForm').hide();
		}
	}
	else {
		if($('imgAvatarAuswahl')) {		
			$('imgAvatarAuswahl').src = p + uid + '/gallery/' + gallery_id + '/size_1/' + name;
			$('imgInsertForm').show();
		}		
	}
}

function do_addImageToBlog() {
	if($('imgAvatarAuswahl').src == '/images/1pixeltransparent.gif') {
		alert('Kein Bild ausgewählt!');
	}
	else {
		var obj = document.blog['imgInsertSelect'];
		var img = $('imgAvatarAuswahl').src;
		var newimg = img.replace('/size_1/', '/size_2/');
		
		if(obj.value == 'blog2_text' && $('rm_container').style.display == 'none') {
			return;
		}
		
		addImageToBlog(obj.value, newimg);
	}
}

function loadPictures(id, uid) {
	
	if(!id || id < 0) return;

	var obj = document.forms['blog'].gallery;
	var pobj = document.forms['blog'].picture;

	new Ajax.Request('/request/blog/getpictures.php', { 
					method: "post",
					asynchronous:true, 
					evalScripts:true, 
					parameters: {
						profileid: uid,
						galleryid: id,
						isgroup: isgroup
					},
					onComplete: function(response) {
							
						if(response.responseText != '0') {

							$('imgAvatarAuswahl').src = 'images/1pixeltransparent.gif';
															
							pobj.options.length = 0;							
							
							pobj.options[0] = new Option(no_picture, '');
							pobj.options[1] = new Option('- - - - - - - - - - - - -', '');
							
							eval(response.responseText);
		
						}
						else {
							pobj.options.length = 0;							
							
							pobj.options[0] = new Option(no_picture, '');
							pobj.options[1] = new Option('- - - - - - - - - - - - -', '');
						}
					}
				});	
}

function open_external_Bookmark(site) {
	switch(site.toLowerCase()) {
		case 'mybuffed':
			alert('Coming soon...');
		break;
		case 'yahoo':
			window.open('http://myweb2.search.yahoo.com/myresults/bookmarklet?t='+encodeURIComponent(document.title)+'&d=&tag=&u='+	encodeURIComponent(location.href));
		break;
		case 'webnews':
			window.open('http://www.webnews.de/einstellen?url='+encodeURIComponent(document.location)+'&title='+encodeURIComponent(document.title));
		break;
		case 'myspace':
			window.open('http://www.myspace.com/Modules/PostTo/Pages/?l=5&u='+encodeURIComponent(document.location)+'&t='+encodeURIComponent(document.title)+'&c=%3Cp%3EPowered%20by%20%3Ca%20href=%22http://www.buffed.de%22%3EBuffed.de%3C/a%3E%3C/p%3E');
		break;
		case 'google':
			window.open('http://www.google.com/bookmarks/mark?op=add&hl=de&bkmk='+encodeURIComponent(location.href)+'&annotation=&labels=&title='+encodeURIComponent(document.title));
		break;
		case 'windows live':
			window.open('https://favorites.live.com/quickadd.aspx?marklet=1&mkt=de-de&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title));
		break;
		case 'favoriten':
			window.open('http://www.favoriten.de/url-hinzufuegen.html?bm_url='+encodeURIComponent(location.href)+'&bm_title='+encodeURIComponent(document.title));
		break;
		case 'facebook':
			window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(location.href)+'&t='+encodeURIComponent(document.title));
		break;
		case 'yigg':
			window.open('http://yigg.de/neu?exturl='+encodeURIComponent(location.href));
		break;
		case 'digg':
			window.open('http://digg.com/submit?phase=2&url='+encodeURIComponent(location.href)+'&bodytext=&tags=&title='+encodeURIComponent(document.title));
		break;
		case 'wong':
			window.open('http://www.mister-wong.de/index.php?action=addurl&bm_url='+encodeURIComponent(location.href)+'&bm_notice=&bm_description='+encodeURIComponent(document.title)+'&bm_tags=');
		break;
		case 'delicious':
			window.open('http://del.icio.us/post?v=2&url='+encodeURIComponent(location.href)+'&notes=&tags=&title='+encodeURIComponent(document.title));
		break;
		case 'bookmarkscc':
			window.open('http://www.bookmarks.cc/bookmarken.php?action=neu&url='+(document.location.href)+'&title='+(document.title));
		break;
		case 'twitter':
			window.open('http://twitter.com/home?status='+(document.title) + ' ' + (document.location.href));
		break;		
		case 'webbrowser':
		
			if(navigator.appName != "Microsoft Internet Explorer")
				window.external.addPanel(document.title, location.href, '');
			else
				window.external.addFavorite(location.href, document.title);
		break;
	}
	
	return false;	 

}

function set_Bookmark_Title(obj, id) {
	
	if(document.getElementById('bookmark_title_' + id)) {
		if(obj == false)
			document.getElementById('bookmark_title_' + id).innerHTML = '';
		else
			document.getElementById('bookmark_title_' + id).innerHTML = obj.id;
	}
}

function checkArchiveFilterForm(obj) {
	
	var year = obj.year.value;
	var month = obj.month.value;
	
	if(month != '' && year == '') {
		
		alert(TXT_NO_YEAR);
		
		return (false);
		
	}
	
}
