function edit_rumor(){
	var win = new Window({width:415, height:465, draggable:false, resizable:false,maximizable:false,minimizable:false,closable:false,className: "alphacube" })
	win.setURL("rumors/embedded_new")
	win.showCenter(true);	
}

function add_fave(){
	var win = new Window({width:445, height:470, draggable:false, resizable:false,maximizable:false,minimizable:false,closable:true, className: "alphacube" })
	win.setURL("favorites/embedded_add")
	win.showCenter(true);	
}

function edit_fave(nid){
	var win = new Window({width:445, height:470, draggable:false, resizable:false,maximizable:false,minimizable:false,closable:false,className: "alphacube" })
	win.setURL("favorites/embedded_edit?id="+nid)
	win.showCenter(true);	
}

function add_friend(name){
	var win = new Window({width:350, height:120, draggable:false, resizable:false,maximizable:false,minimizable:false,closable:true, className: "alphacube" })
	win.setURL("friends/mysettings_add/"+name);
	win.showCenter(true);	
}

function fave_it(nid){
	var win = new Window({width:329, height:90, draggable:false, resizable:false,maximizable:false,minimizable:false,closable:true,className: "alphacube" })
	win.setURL("favorites/embedded_faveit?id="+nid)
	win.showCenter(true);	
}

function new_win(win_width,win_height,destination,arg,modal,theme){
	var win = new Window({width:win_width, height:win_height, draggable:false, resizable:false,maximizable:false,minimizable:false,closable:true,className: theme })
	win.setURL(destination)
	if(modal)
		win.showCenter(true);	
	else
		win.showCenter(false);
}

function new_wins(win_width,win_height,destination,arg,modal,theme,mytitle,myparent){

	var win = new Window({onBeforeShow:function() {focus();}, recenterAuto:true, width:win_width, height:win_height, draggable:false, resizable:false,maximizable:false,minimizable:false,closable:true,title:mytitle,className: theme,parent:$(myparent) })
	win.setURL(destination)
	if(modal)
		win.showCenter(true);	
	else
		//win.showCenter(true,400,x);
		win.showCenter(false);

	/*
	var winw = getWinWidth();
	alert(winw);
	var x = ((winw - 891) / 2) + 55;
	//alert(x);
	*/
	
}

function getWinHeight() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && document.documentElement.clientHeight  ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && document.body.clientHeight ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  
  return myHeight;
}

function getWinWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myWidth -= 20;
  } else if( document.documentElement && document.documentElement.clientWidth ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && document.body.clientWidth) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

function confirm_del(formname,op,he,msg){
	var myform = document.getElementById(formname);
	var hidden_el = document.getElementById(he);
	if(he != ''){
		Dialog.confirm(msg, {width:300, okLabel: "Yes", cancelLabel:"No", buttonClass: "form-submit-smaller", className: "alphacube",  cancel:function(win) {return false;}, ok:function(win) {hidden_el.value=op; myform.submit(); return true;} });
	}
	else{
		Dialog.confirm(msg, {width:300, okLabel: "Yes", cancelLabel:"No", buttonClass: "form-submit-smaller", className: "alphacube",  cancel:function(win) {return false;}, ok:function(win) {myform.submit(); return true;} });
	}
}

function selectcell(element_id,clicked_id){
	var el = document.getElementById(element_id);
	var tds = el.getElementsByTagName("td");
	for (var e = 0; e < tds.length; e++){
		td = tds[e];
		if(td.id == clicked_id){
			td.className = 'icon-selected';
			var pic = document.getElementById('picture');
			pic.value = 'themes/default/images/'+clicked_id+'.jpg';
		}
		else{
			td.className = 'icon-normal';
		}
	}
}

function submitForm(){
	document.forms.delform.submit();
	closeMessage();
}

function countsectors(id,formname,max,exception){
	var checked=0;

	for (var e = 0; e < document.forms[formname].elements.length; e++){
		el = document.forms[formname].elements[e];
		if (el.type == 'checkbox'){
			if((el.checked == true) && (el.id != exception)){
				checked++;
				if(checked > max){
					alert('You may choose only '+max+' sectors.');
					var el2 = document.getElementById('sector'+id);
					el2.checked = false;
	 				break;
				}
			}
		}
	}
}

var win=null;
function NewWin(mypage,myname,w,h,pos,infocus,scrollbars,location,directories,status,menubar,toolbar,resizable){
	if(pos=="random"){
 		myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
 		mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
 	}
 	if(pos=="center"){
 		myleft=(screen.width)?(screen.width-w)/2:100;
 		mytop=(screen.height)?(screen.height-h)/2:100;
 	}
 	else if((pos!='center' && pos!="random") || pos==null){
 		myleft=0;mytop=20
 	}
 	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars="+scrollbars+",location="+location+",directories="+directories+",status="+status+",menubar="+menubar+",toolbar="+toolbar+",resizable="+resizable;
 	win=window.open(mypage,myname,settings);
 	win.focus();
}