var custommode;
function I(obj) {
	if (editmode=="content" || custommode=="content") {
		activeImg=obj;

		str="";
		propertiesWindow=window.open("?window=pb_properties&menuid="+menuid,"propertiesWindow","status,scrollbars,resizable=yes,height=500,width=650");
		propertiesWindow.focus();
	}
	else {
		what=obj.action;
		if (what==1) {
			return true;
		}
		if (what==3) {
			imgBig=window.open('?window=enlarge&dirStr='+encodeURI(obj.src),'big','menubar=no, status=no, location=no, scrollbars=no');imgBig.focus();
		}
		if (what==2) {
			newBrowser=window.open(obj.url,'newBrowser');
			newBrowser.focus();
		}
		if (what==4) {
			document.location.href=obj.url;
		}
	}
}

function setSession(){
	var itemcount = setSession.arguments.length;
	var requestStr="";
  for (i = 0;i < itemcount;i+=2){
  	requestStr+="&name[]="+setSession.arguments[i]+"&value[]="+setSession.arguments[i+1];
	}
	sessionImage = new Image();
	sessionImage.src="blueprint/session.php?"+requestStr;
}

function init() {

	createSpecialHTML(((editmode=='content')?true:false));
	if (editmode!='content') createMP3Links();



}
function custom_functions_after_paste() {

}

$(function(){
	var posCTRL = false;
	if (editmode) {
		$(document).keypress(function(event){
			if(event.keyCode==17) {
				if (cmenu)hideContextMenu();
				else{
					if (editmode=="content" || custommode=="content") {
						knoppressed=true;
						if (changed) {
							if  (confirm('Are you sure you want to go back and discard changes?')) url('?menuid='+menuid+'&editmode=start');
						}
						else url('?menuid='+menuid+'&amp;editmode=start');
					}
					else if (editmode=="menu") url('?menuid='+menuid+'&amp;editmode=start');
					else if (editmode=="start") if (confirm("Are you sure you want to log out?")) url('?menuid='+menuid+'&login=logout');
				}
			}
		});
	}
	$(document).keydown(function(event){

		if(event.keyCode==17) {
			posCTRL = true;
		}
		else if (posCTRL && event.keyCode == 13) {
			jumpToEditMode();
			posCTRL = false;
		}


	});
	$(document).keyup(function(event){
		posCTRL = false;

	});

	$("select[@extendable='true']").each(function(){

		var new_input_id='extend_'+$(this).attr('name');
		var optionwidth = this.offsetWidth;
		$(this).before('<input type="text" name="'+$(this).attr('name')+'" id="'+new_input_id+'" />');
		this.name=new_input_id;
		$('input#'+new_input_id).css({
			position:'absolute',

			width:(optionwidth-22)+'px'
		});

		$(this).change(function(){
			$('input#'+this.name).val(this.options[this.selectedIndex].text);
		}).change();

	});

	$('#linked form').each(function(){
		this.onsubmit = function() {
			var allfieldsok=true;
			$('#linked form input.required').each(function(){
				if (this.value=='') {
					this.style.backgroundImage='url(blueprint/img/required.gif)';
					allfieldsok=false;
				}
				else {
					this.style.backgroundImage='url(blueprint/img/required_ok.gif)';

				}
			});
			if (!allfieldsok) {
				alert('Niet alle verplichte velden zijn ingevuld!');
				return false;
			}
		}
	});
	$('input#gebruikersnaam').focus();


});

