ajaxCaller.shouldDebug = false;
var authURL = "/uporabniki/forms";

var TableSizeType=null;


var Xoffset=-120;        // modify these values to ...
var Yoffset=20;        // change the popup position.
var popwidth=200;       // popup width
var titlewidth=200;       // popup widt
var bcolor="darkgray";  // popup border color
var fcolor="black";     // popup font color
var fface="verdana";    // popup font face
	
	
//assign object
var skin;
var skin_title;
var iex;
var nav;
var old;
var n_6;
var yyy=-1000;


function LoadJS(theScript)
{
	var newElem = document.createElement("script");
	var elemJS = document.getElementById("dinamicJScontainer");
	
	
	newElem.setAttribute("language","JavaScript1.2");
	newElem.setAttribute("type","text/javascript");
	//IE is failing on following line.
	newElem.innerHTML = theScript;
	//alert(newElem.innerHTML );
	elemJS.appendChild(newElem);
	eliminar("dinamicJScontainer");
	
}
	
function eliminar(x){
	while(document.getElementById(x).childNodes.length>0){
	document.getElementById(x).removeChild(document.getElementById(x).childNodes
	[0]);}
}

function callForms() {
	
	 TableSizeType=null;
	 var vars = new Array();
	/*alert(document.getElementById("smer").value);
	alert(document.formaIskanje.smer.value);*/
	 
	 var FormsLabel = $("frm_right");
	 
	 if(document.formaIskanje.menu!=null)
	 	vars["menu"]=document.formaIskanje.menu.value;
	 if(document.formaIskanje.tip!=null)
	 	vars["tip"]=document.formaIskanje.tip.value;
	 if(document.formaIskanje.tipgost!=null)
	 	vars["tipgost"]=document.formaIskanje.tipgost.value;
	 if(document.formaIskanje.operater!=null)
	 	vars["operater"]=document.formaIskanje.operater.value;
	 if(document.formaIskanje.drzava!=null)
		vars["drzava"]=document.formaIskanje.drzava.value;
	/* if(smer!=null){
	 	TableSizeType=smer.value;
	 	vars["smer"]=smer.value;
	 }*/
	 if(document.formaIskanje.smer!=null)
	 {
	 	TableSizeType=document.formaIskanje.smer.value;
	 	vars["smer"]=document.formaIskanje.smer.value;
	 }
	 if(document.formaIskanje.obmocje!=null)
	 	vars["obmocje"]=document.formaIskanje.obmocje.value;
	 if(document.formaIskanje.customer!=null)
	 	vars["customer"]=document.formaIskanje.customer.value;
	 if(document.formaIskanje.paid!=null)
	 	vars["paid"]=document.formaIskanje.paid.value;
	 if(document.formaIskanje.kontinent!=null)
	 	vars["kontinent"]=document.formaIskanje.kontinent.value;
	 if(document.formaIskanje.mms!=null && document.formaIskanje.mms.checked)
	 	vars["check_mms"]=document.formaIskanje.mms.value;
	 
	    	
	 if(document.formaIskanje.sms!=null && document.formaIskanje.sms.checked)
	 	vars["check_sms"]=document.formaIskanje.sms.value;


	   var OK=true;
 	   op_selected=document.getElementById("op_sel");
	   
	   if(op_selected!=null )
	   {
	   		var sels = new Array();
	   		if(op_selected.length==0)
	   		{	
	   			alert("Nobeden operater ni izbran, prosim izberi operaterja (dvojni klik)!");
	   			OK=false;
	   		}
	   	 	for(var i = 0;i < op_selected.length;i++)
	 		{
				sels[i]=op_selected.options[i].value;
	 		}
	 		vars["op_selected"]=sels;
	   }
   
	   
	   //submit 
	   if(vars["menu"]=="isp" && vars["obmocje"]=="Vse" && vars["operater"]=="Vsi")
	   {
	     var c=String.fromCharCode(269);
	     var text="Obvezno izbrati je potrebno vsaj en kriterij - ob"+c+"ina ali ponudnik!";
         alert(text);
       }else if(vars["menu"]=="gost" && (vars["tipgost"]=="ns" || vars["drzava"]=="ns"))  
       {
       	 var z=String.fromCharCode(382);
	     var text="Obvezno izbrati je potrebno dva kriterija - vrsta gostovanja in tuja dr"+z+"ava!";
         alert(text);
       }else if(vars["menu"]=="smsmms" && vars["operater"]=="ns")  
       {
       	 var c=String.fromCharCode(269);
	     var text="Obvezno izbrati je potrebno doma"+c+"ega operaterja in vsaj eno storitev!";
         alert(text);
       }else if(vars["menu"]=="med" && vars["drzava"]=="ns")  
       {
       	 var z=String.fromCharCode(382);
	     var text="Obvezno izbrati je potrebno en kriterij - tuja dr"+z+"ava!";
         alert(text);
       }else if(OK) 
	   {
	   		ajaxCaller.postVars(authURL, vars, null, showForms, false, null);
	  	    FormsLabel.innerHTML="<center><img name='dodaj' border='0' src='/uporabniki/webfiles/themes/default/images/roller_big.gif'></center>";   
       }
}

	
function showForms(text, callingContext) {

 	//alert(text);
   	var FormsLabel = $("frm_right");
   	
   	
  	
  	// id browsers
	iex=(document.all);
	nav=(document.layers);
	old=(navigator.appName=="Netscape" && !document.layers && !document.getElementById);
    n_6=(window.sidebar);
 
 	if(iex){

 		var t = document.createElement("div");
 		
		t.innerHTML = text+"<div style='font-size: 12pt;' id='pup' class='pup'></div><div style='font-size: 12pt;' id='title' class='title'></div>";
	
  		if(FormsLabel.firstChild!=null)
  			FormsLabel.removeChild(FormsLabel.firstChild);
       FormsLabel.appendChild(t);
  	}
   	else{
   	
   	    FormsLabel.innerHTML ="";
   	
   	 	FormsLabel.innerHTML =  text+"<div style='font-size: 12pt;' id='pup' class='pup'></div><div style='font-size: 12pt;' id='title' class='title'></div>";
  	}
 
 
	if(nav){ 
		skin=document.pup;
		skin_title=document.title;
	}
	
	if(iex){ 
		skin=pup.style;
		skin_title=title.style;
	}
	
	if(n_6){ 
		skin=document.getElementById("pup").style;
		skin_title=document.getElementById("title").style;
	}
	
	skin.position="absolute";
	skin_title.position="absolute";
    // park modifier
	

	// capture pointer
	if(nav)document.captureEvents(Event.MOUSEMOVE);
	if(n_6) document.addEventListener("mousemove",get_mouse,true);
	if(nav||iex)document.onmousemove=get_mouse;
  
  	
  
 	paddingLeft = 1;
   	paddingRight = 1;
   	paddingTop = 1;
   	paddingBottom = 1;
   	
    var ScrollTable_width_new;
    //alert(document.getElementById("menu").value);
    var menu=document.getElementById("menu");
       	 //alert(menu.value+TableSizeType);
   	if(TableSizeType=="iz" && (menu.value=="nacional" || menu.value=="smsmms"))
    {	
   		ScrollTable_width_new=ScrollTable_width-210;
   		//TableSizeType=null;
   	}
   	/*else if(TableSizeType=="v" && menu.value=="nacional")
    {	
   		ScrollTable_width_new=ScrollTable_width-30;
   		//TableSizeType=null;
   	}*/
   	else if(menu.value=="isp")
   	{
   	    ScrollTable_width_new=ScrollTable_width-80;
   	}
   	else
   		ScrollTable_width_new=ScrollTable_width;
   		
//alert(ScrollTable_width_new);
    var tableScr=document.getElementById("scrollTable");
	if(tableScr!=null){
		//ScrollTableAbsoluteSize(document.getElementById("scrollTable"),550, 450);

               //ScrollTableAbsoluteSize(tableScr,ScrollTable_width_new, ScrollTable_height);
               ScrollTableAbsoluteSize(tableScr,ScrollTable_width_new, ScrollTable_height);
    }
	var scriptEle = document.getElementById('scriptFromAjax')
	if(scriptEle!=null){
		if(iex) 
	          eval(scriptEle.innerHTML)
	    else
	          LoadJS(scriptEle.innerHTML);
	}
}

function callRedirect(payload,type) {

 var vars = new Array();
 
 if(type=="nazaj")
 	vars["nazaj"]=payload;
  else if(type=="mobPaket")
 	vars["mobPaket"]=payload;
  else if(type=="fixPaket")
 	vars["fixPaket"]=payload;
  else if(type=="usergroup")
 	vars["usergroup"]=payload;
  else if(type=="nazajisp")
 	vars["nazajisp"]=payload;
  else if(type=="info")
 	vars["info"]=payload;
  else if(type=="first")
 	vars["first"]=payload;
  else if(type=="connections")
 	vars["connections"]=payload;
  else if(type=="helpText")
 	vars["helpText"]=payload;
  else if(type=="empty")
 	vars["empty"]=payload;
  else if(type=="cmp")
 	vars["cmp"]=payload;
 
 
   var OK=true;
  /*op_selected=document.getElementById("op_sel");
   if(op_selected!=null)
   {
   		var tmp="";
   		if(op_selected.length==0)
   		{	
   			alert("Nobeden operater ni izbran, prosim izberi operaterja (dvojni klik)!");
   			OK=false;
   		}
   	 	for(var i = 0;i < op_selected.length;i++)
 		{
			op_selected.options[i].selected = true;
			tmp=tmp+op_selected.options[i].value+","
 		}
 		var data="klic="+tmp+"&name=op_selected";
       	asynchGet("/uporabniki/session",data);
   }*/
  if(OK)
  
 	ajaxCaller.postVars(authURL, vars,null, showRedirect, false, null);

}

function callRedirectDam(payload1,type,payload2) {

 var vars = new Array();
 
 if(type=="ispPaket")
 {
 	vars["ispPaket"]=payload1;
 	vars["from"]=payload2;
 }
 
 ajaxCaller.postVars(authURL, vars,null, showRedirect, false, null);

}
	
function showRedirect(text, callingContext) {

 	//alert(text);
   	var FormsLabel = $("frm_right");
  	
  	// id browsers
	iex=(document.all);
	nav=(document.layers);
	old=(navigator.appName=="Netscape" && !document.layers && !document.getElementById);
    n_6=(window.sidebar);
 
 	if(iex){
 		var t = document.createElement('div');
		t.innerHTML = text+"<div style='font-size: 12pt;' id='pup' class='pup'></div><div style='font-size: 12pt;' id='title' class='title'></div>";
	
  		if(FormsLabel.firstChild!=null)
  			FormsLabel.removeChild(FormsLabel.firstChild);

  		FormsLabel.appendChild(t);
  	}
   	else{
   		FormsLabel.innerHTML="";
   	 	FormsLabel.innerHTML =  text+"<div style='font-size: 12pt;' id='pup' class='pup'></div><div style='font-size: 12pt;' id='title' class='title'></div>";
  	}
 
 
	if(nav){ 
		skin=document.pup;
		skin_title=document.title;
	}
	
	if(iex){ 
		skin=pup.style;
		skin_title=title.style;
	}
	
	if(n_6){ 
		skin=document.getElementById("pup").style;
		skin_title=document.getElementById("title").style;
	}
	
	skin.position="absolute";
	skin_title.position="absolute";
    // park modifier
	

	// capture pointer
	if(nav)document.captureEvents(Event.MOUSEMOVE);
	if(n_6) document.addEventListener("mousemove",get_mouse,true);
	if(nav||iex)document.onmousemove=get_mouse;
	
	paddingLeft = 1;
   	paddingRight = 1;
   	paddingTop = 1;
   	paddingBottom = 1;
   	
   	 var ScrollTable_width_new;
   	 //alert(TableSizeType);
   	 //alert(document.getElementById("menu").value);
   	 var menu=document.getElementById("menu");
   	 //alert(menu.value+TableSizeType);
   	if(TableSizeType=="iz" && (menu.value=="nacional" || menu.value=="smsmms"))
   	{	
   		ScrollTable_width_new=ScrollTable_width-210;
   		//TableSizeType=null;
   	}
   	/*else if(TableSizeType=="v" && menu.value=="nacional")
    {	
   		ScrollTable_width_new=ScrollTable_width-30;
   		//TableSizeType=null;
   	}*/
   	else if(menu.value=="isp")
   	{
   	    ScrollTable_width_new=ScrollTable_width-80;
   	}	
   	else
   	
   		ScrollTable_width_new=ScrollTable_width;
   	
   	//alert(ScrollTable_width_new);
   	var tableScr=document.getElementById("scrollTable");
	if(tableScr!=null){
		//ScrollTableAbsoluteSize(document.getElementById("scrollTable"),550, 450);

     //ScrollTableAbsoluteSize(tableScr,ScrollTable_width_new, ScrollTable_height);
     ScrollTableAbsoluteSize(tableScr,ScrollTable_width_new, ScrollTable_height);
    }   
	var scriptEle = document.getElementById('scriptFromAjax')
	
	if(scriptEle!=null){
   	if(iex) 
          eval(scriptEle.innerHTML)
    else
          LoadJS(scriptEle.innerHTML);
	}
     
}


