﻿//isIE = (document.all)? true : false
isIE = ((document.all && navigator.userAgent.indexOf("opera") == -1) ? true : false)
isOpera = ((document.all && navigator.userAgent.indexOf("Opera") >= 0) ? true : false)
//alert(isIE + "-" + isOpera);
//vrati vysku a sirku klientske oblasti okna prohlizece
//  vystup:
//      width,height    - vyska a sirka klientske oblasti okna prohlizece
function getWinSize() 
{
  var w = 0, h = 0;
  
  if( typeof( window.innerWidth ) == 'number' && (navigator.userAgent.indexOf("Firefox")==-1)) 
  {
    //Opera
    w = window.innerWidth;
    h = window.innerHeight;
  }   
  else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
  {
    //IE6,7,Firefox
    w = document.documentElement.clientWidth;
    h = document.documentElement.clientHeight;
  }    
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
  {
    //IE4
    w = document.body.clientWidth;
    h = document.body.clientHeight;
  }
  //if (w > 1400) w = 1400;
  //if (h > 1000) h = 1000;
  return {width:w, height:h};
}

/* funkce pro zmenu velikosti mapy */
function nastavVelikostMapy(levy, horni, odecet_sirka, odecet_vyska) {
    v = getWindowSize();
    mapComponentObj.left=levy;
    mapComponentObj.top=horni;
    if (v.width > 1400) sirka = 1400; else sirka = v.width;
    if (v.height > 1000) vyska = 1000; else vyska = v.height;
    mapComponentObj.resize(sirka-odecet_sirka, vyska-odecet_vyska);
}

function SestavGeneralXML(sqlSQL, sqlRed, sqlGreen, sqlBlue, sqlWidth, sqlStyle, sqlFirstPointImagePath, sqlLastPointImagePath, sqlOffset, bSqlDrawLabel, bSqlDirection)
{
    var selectXML = "";
    selectXML += "<GeneralSelectParameter>";
    selectXML += "<ConnectionStringIndex>1</ConnectionStringIndex>";
    selectXML += "<SQLSelect>" + sqlSQL + "</SQLSelect>";
    selectXML += "<Red>" + sqlRed + "</Red>";
    selectXML += "<Green>" + sqlGreen + "</Green>";
    selectXML += "<Blue>" + sqlBlue + "</Blue>";
    selectXML += "<Width>" + sqlWidth + "</Width>";
    selectXML += "<Style>" + sqlStyle + "</Style>";
    selectXML += "<FirstPointImagePath>" + sqlFirstPointImagePath + "</FirstPointImagePath>";
    selectXML += "<LastPointImagePath>" + sqlLastPointImagePath + "</LastPointImagePath>";
    selectXML += "<Offset>" + sqlOffset + "</Offset>";
    selectXML += "<DrawLabel>" + bSqlDrawLabel + "</DrawLabel>";
    selectXML += "<Direction>" + bSqlDirection + "</Direction>";
    selectXML += "</GeneralSelectParameter>";

    return selectXML;
}

function SestavGeneralXML_hlav(p)
{
    var selectXML = "";
    selectXML += "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
    selectXML += "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
    selectXML += "<soap:Body>";
    selectXML += "<GetGeneralSelect xmlns=\"http://tempuri.org/\">";
    selectXML += "<parameterCollection>";
    selectXML += p;
    selectXML += "</parameterCollection>";
    selectXML += "</GetGeneralSelect>";
    selectXML += "</soap:Body>";
    selectXML += "</soap:Envelope>";

    return selectXML;
}

function trim(str) { 
    str = str.replace(/^\s*/, '').replace(/\s*$/, ''); 
   return str;
} 

function doplnNulu(ret) {
	ret = ret + ""
	if (ret.length == 1)
		return "0" + ret;
	else
		return ret;
}
