 var indexadengineui = Math.round(Math.random()*10000000);
 var same = indexadengineui;

function Is() { //browser leválogatás
  agent = navigator.userAgent.toLowerCase();
  this.agent = navigator.userAgent.toLowerCase();
  this.major = parseInt(navigator.appVersion);
  this.minor = parseFloat(navigator.appVersion);
  this.ns = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1)));
  this.ns4 = (this.ns && (this.major <= 4) && (this.minor < 5));
  this.ns6 = (this.ns && (this.major >= 5));
  this.ie = (agent.indexOf("msie") != -1);
  this.ie4 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") == -1));
  this.ie5 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5") != -1));
  this.ie6 = (this.ie && (this.major == 4) && (agent.indexOf("msie 6") != -1));
  this.iframe = (this.ie || this.ns6) ;
}
var is = new Is();

function OWP(Title, URL, wWidth, wHeight, wScroll)
{
  try {
  if (document.all) 
  {
    screenWidth = document.body.offsetWidth;
    screenHeight = document.body.offsetHeight;
  }
  else 
  {
    screenWidth = window.innerWidth;
    screenHeight = window.innerHeight;
  } 
  var wLeft = (window.screenLeft * 2 + screenWidth - wWidth)/2;
  var wTop = (window.screenTop * 2 + screenHeight - wHeight)/2;
  try {
    Win = window.open(URL,Title,'toolbar=no,location=no,directories=no,menubar=no,status=no,left='+wLeft+',top='+wTop+',width='+wWidth+',height='+wHeight+',scrollbars='+wScroll); Win.focus(); return void(0); 
  }
  catch (ex)
  {
    window.showModalDialog(URL,'','center=no;toolbar=no;location=no;directories=no;menubar=no;status=no;dialogLeft='+wLeft+'px;dialogTop='+wTop+'px;dialogWidth='+wWidth+'px;dialogHeight='+wHeight+'px;resizable=no;help=no;scroll=no'); return void(0); 
  }
  }
  catch(exception) {};

}

function OWU(Title, URL, wWidth, wHeight, wScroll)
{
  try {
  if (document.all) 
  {
    screenWidth = document.body.offsetWidth;
    screenHeight = document.body.offsetHeight;
  }
  else 
  {
    screenWidth = window.innerWidth;
    screenHeight = window.innerHeight;
  } 
  var wLeft = (window.screenLeft * 2 + screenWidth - wWidth)/2;
  var wTop = (window.screenTop * 2 + screenHeight - wHeight)/2;
  Win = window.open(URL,Title,'toolbar=no,location=no,directories=no,menubar=no,status=no,left='+wLeft+',top='+wTop+',width='+wWidth+',height='+wHeight+',scrollbars='+wScroll); window.focus(); return void(0); 
  }
  catch(exception) {};
}

function OWPF(Title, URL)
{
    try {
    var screenWidth;
    var screenHeight;
    var wHeight;
    var wWidth;
    var wLeft;
    var wTop;
    var Win;
    if (document.all)
    {
      screenWidth = document.body.offsetWidth;
      screenHeight = document.body.offsetHeight;
    }
    else 
    {
        screenWidth = window.innerWidth;
        screenHeight = window.innerHeight;
    }
    wHeight = screen.Height;
    wWidth = screen.Width;
    wLeft = 0;
    wTop = 0;
    try {
	Win = window.open(URL,Title,'toolbar=yes,location=yes,directories=yes,menubar=yes,status=yes,left='+wLeft+',top='+wTop+',width='+wWidth+',height='+wHeight+',scrollbars=yes');
	if (Win!=null) Win.focus();
    }
    catch (ex)
    {
	window.showModalDialog(URL,'','center=no;toolbar=no;location=no;directories=no;menubar=no;status=no;dialogLeft='+wLeft+'px;dialogTop='+wTop+'px;dialogWidth='+wWidth+'px;dialogHeight='+wHeight+'px;resizable=no;help=no;scroll=no'); return void(0); 
    }
    }
    catch(exception) {}
    return void(0);
}
							
    
function RollOver(Window, wWidth, wHeight)
{
    Window.width=wWidth;
    Window.height=wHeight;
}

function getObj(dname)
{
    if (ppcIE)
    {
	d=document.all[dname];
    }
    else if (ppcNN)
    {
	d=document.layers[dname];
    }
    else
    {
	d=document.getElementById(dname);
    }
    return d;
}

function DivFlip(dname)
{
    if (ppcIE)
    {
	d=document.all[dname];
    }
    else if (ppcNN)
    {
	d=document.layers[dname];
    }
    else
    {
	d=document.getElementById(dname);
    }
    d.style.display=d.style.display=="none"?"":"none";
    var name=d.id;
    name=name.substring(name.indexOf("_O_")+3);
    var id=parseInt(name);
    if (isNaN(id))
    {
    }
    else
    {
	if (d.style.display!="none")
	{
	    setCookie("Container_"+id+"_Closed","0");
	}
	else
	{
	    setCookie("Container_"+id+"_Closed","1");
	}
    }
    
}

function DivShow(dname)
{
    if (ppcIE)
    {
	d=document.all[dname];
    }
    else if (ppcNN)
    {
	d=document.layers[dname];
    }
    else
    {
	d=document.getElementById(dname);
    }
    if (d!=null)
    {
        d.style.display="";
    }
}

function DivHide(dname)
{
    if (ppcIE)
    {
	d=document.all[dname];
    }
    else if (ppcNN)
    {
	d=document.layers[dname];
    }
    else
    {
	d=document.getElementById(dname);
    }
    if (d!=null)
    {
	d.style.display="none";
    }
}

function showTab( tab, formName, link )
{
    
	form=document.getElementById(formName);
	formlen=form.childNodes.length;

	for (i=0;i<formlen;i++)
	{
	    list=form.childNodes;
	    inp=list[i];
	    if ((inp.tagName=="DIV")&&(inp.className=="tabContent"))
	    {
		inp.style.display="none";
	    }
	}

    var obj = document.getElementById(tab);
    obj.style.display = "block";

    formlen=obj.getElementsByTagName('div').length;
    for (i=0;i<formlen;i++)
    {
	list=obj.getElementsByTagName('div');
	inp=list[i];
	if (inp.className=="cps_htmled_val")
	{
	    fieldName=inp.id.replace("_val","");
	    parent=inp.parentNode;
	    while (parent.tagName!="FORM")
	    {
		parent=parent.parentNode;	    
	    }
	    InitHtmlEditor(parent.name,fieldName);
	}
	
    }

    formlen=link.parentNode.getElementsByTagName('a').length;
    for (i=0;i<formlen;i++)
    {
	list=link.parentNode.getElementsByTagName('a');
	inp=list[i];
	inp.className="tab";
    }


    link.className="activeTab";
}


  var http_request = false;
  var http_callback = null;
  
   function makePOSTRequest(url, parameters, callback) {
      http_request = false;
    http_callback=callback;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            // set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }     
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
//      alert(url);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
//      alert(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            result = http_request.responseText;
	    if (http_callback!=null)
		http_callback(result);
//	    else
//		alert(result);
         } else {
            alert('There was a problem with the request: '+http_request.status+", "+http_request.responseText );
         }
      }
   }

function getLocalPath(originalPath)
{
	// Remove any location or query part of the URL
	var argPos = originalPath.indexOf("?");
	if(argPos != -1)
		originalPath = originalPath.substr(0,argPos);
	var hashPos = originalPath.indexOf("#");
	if(hashPos != -1)
		originalPath = originalPath.substr(0,hashPos);
	// Convert file://localhost/ to file:///
	if(originalPath.indexOf("file://localhost/") == 0)
		originalPath = "file://" + originalPath.substr(16);
	// Convert to a native file format assuming
	// "file:///x:/path/path/path..." - pc local file --> "x:\path\path\path..."
	// "file://///server/share/path/path/path..." - FireFox pc network file --> "\\server\share\path\path\path..."
	// "file:///path/path/path..." - mac/unix local file --> "/path/path/path..."
	// "file://server/share/path/path/path..." - pc network file --> "\\server\share\path\path\path..."
	var localPath;
	if(originalPath.charAt(9) == ":") // pc local file
		localPath = unescape(originalPath.substr(8)).replace(new RegExp("/","g"),"\\");
	else if(originalPath.indexOf("file://///") == 0) // FireFox pc network file
		localPath = "\\\\" + unescape(originalPath.substr(10)).replace(new RegExp("/","g"),"\\");
	else if(originalPath.indexOf("file:///") == 0) // mac/unix local file
		localPath = unescape(originalPath.substr(7));
	else if(originalPath.indexOf("file:/") == 0) // mac/unix local file
		localPath = unescape(originalPath.substr(5));
	else if(originalPath.indexOf("http://") == 0) // mac/unix local file
		localPath = originalPath;
	else // pc network file
		localPath = "\\\\" + unescape(originalPath.substr(7)).replace(new RegExp("/","g"),"\\");
	return localPath;
}

