/*ta funlkcija se uporablja za izpsis podrobnosti o dogodkih v koledarju*/
function openWinKoledar(page)
{
        //alert(page);
        wind=window.open("koledar.php?dogodek="+page+"", "Koledar","toolbar=No,menubar=No,location=No,scrollbars=yes,resizable=Yes,status=No,width=450,height=300,left=100,top=150,border=0");
        wind.focus();
}

function favorites() { 
   if (window.external) { 
      window.external.AddFavorite(document.URL, document.title); 
   } else if (window.sidebar) { 
      window.sidebar.addPanel(document.title, document.URL, ''); 
   } 
}

function menjajklas(klas)
{
 event.srcElement.className=klas; 
  
    
}
function openPosta()
{
        //alert(page);
        wind=window.open("modules/pzen/", "Aurora","toolbar=No,menubar=No,location=No,scrollbars=yes,resizable=Yes,status=No,width=800,height=600,left=100,top=150,border=0");
        wind.focus();
}
function openWhois()
{
        //alert(page);
        we=window.open("whois/whois.php", "Whois","toolbar=No,menubar=No,location=No,scrollbars=yes,resizable=Yes,status=No,width=1024,height=600,left=10%,top=10%,border=0");
        we.focus();
}
function openWind(w,h,pos,url)
{
   
    if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
    if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
    else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
    settings='width='+(w+50)+',height='+(h+50)+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
    win=window.open(url,"izdelek",settings);
   
    win.focus();
}
function openWinPrint()
{
	   
	    wind=window.open("print.php", "Aurora","toolbar=No,menubar=No,location=No,scrollbars=yes,resizable=Yes,status=No,width=800,height=600,left=100,top=150,border=0");
        wind.focus();
     
}

function whoisDetails(w,h,scroll,pos,url)
{
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(url,"whoisWindow",settings);
}
var id_domen=new Array();
var dom_=new Array();
var domena;

function shrani_narocilo(domen,tld,id)
{

	
	if(id_domen[id]!=1)
	{
		id_domen[id]=1;
		dom_.push(id);
	}
	else
	id_domen[id]=0;
	
	//id_domen.sort();
	domena=domen;
	
}

function registriraj_narocilo()
{
	//id_domen.sort();
	izpis = '';
	for (i = 0; i < dom.length; i++)
	{
		if (id_domen[dom[i]] == 1)
		{
			izpis = izpis + '-' + dom[i];	
		}	
	}
	//alert("?addtocart=1&domena=" + domena + "&product=" + izpis);
	Loader.loadUrl("podatki.php?path=ponudba&addtocart=1&domena=" + domena + "&product=" + izpis);
}

if(Ext){
	FckWindow = function(config){
		config = config || {};		
		
		Ext.applyIf(config, {						
			hidden: true,
			renderTo: Ext.getBody(),
			buttonAlign: 'left',
			width: 700,
			height: 400,
			maximizable: true,			
			layout: 'fit',
			closeAction: 'hide',
			title: 'Uredi vsebino',
			buttons: [{
				text: 'Shrani',
				scope: this,
				handler: function(){this.saveContent();}
			},{
				text: 'Prekliči',
				scope: this,
				handler: function(){this.hide();}
			}]
		});
		
		FckWindow.superclass.constructor.call(this, config);
	}
	
	Ext.extend(FckWindow, Ext.Window, {
		saveContent: function(){
			var value = this.getEditorHTML();			
	        Ext.Ajax.request({
	            url: "save_data.php",
				scope: this,
	            params: {
					id: this.moduleId,
	                content:value    
	            },
	            callback:function(r,success,response){	                
	                if(success){						
						this.updateElement(value);
						this.hide();
	                } else {
	                    Ext.MessageBox.alert('napaka',response.status);
	                }
	            }        
	        });
		},
		getEditorHTML: function(){			
			return this.getEditorInstance().GetHTML();
		},
		setEditorHTML : function(html){
			return this.getEditorInstance().SetHTML(html);
		},
		getEditorInstance: function(){
			return this.body.select('iframe').elements[0].contentWindow.FCK;
		},
		updateElement: function(html){			
			var link = Ext.get(this.targetLink);			
			var el = link.dom.parentNode;
			el.innerHTML = html + link.dom.outerHTML;
			this.setAnimateTarget(this.targetLink);
		}
	});
	
	EditorMgr = function(){
		var editors = [];
		var destroyable = [];
		
		// private
		Loader.onBeforeNavigate(function(){
			Ext.each(destroyable, function(el){					
				
				editors.remove(el.editEl);
				delete editors[el.editEl];
				
				el.el.stopFx();
				el.destroy();
			});			
			destroyable = [];
		});
		
		return {
			showEditor: function(config){				
				EditorMgr.registerEditor(config);
				editors[config.editEl].show();
			},
			registerEditor: function(config){				
				if(EditorMgr.isEditorRegistered(config.editEl)){
					return;
				}
				
				var id = config.editEl;
				var windowId = 'window_' + id;				
				var destroy = Ext.get(config.targetLink).up('div.content-panel') != null;
				
				var editor = new FckWindow({
					contentEl: 'div_' + id,
					animateTarget: 'link_' + id,
					id: windowId,					
					isContentEditor: destroy
				});	
				Ext.apply(editor, config);
				
				editors[id] = editor;
				
				if(destroy){
					destroyable.push(editor);
				}
			},
			unregisterEditor: function(id){
				editors.remove(id);
			},
			isEditorRegistered: function(id){
				return editors[id] != null;
			}
		};
	}();
}

