var g_sLang = "SI";

if (!theForm) {
    var theForm = document.forms['aspnetForm'];
    if (!theForm) {
        theForm = document.aspnetForm;
    }
}


/***********
Input filter
***********/
function InputFilter() {
}

InputFilter.generalKeyPressed = function(eventObj) {
    if (/IE/.test(navigator.userAgent))
        return false;

    var keyCode;
    if (window.event)
        keyCode = window.event.keyCode;
    else
        keyCode = eventObj.keyCode;

    var isAllowed = (keyCode == 8    // backspace
        || keyCode == 9     // tab
        || keyCode == 35    // end
        || keyCode == 36    // home
        || keyCode == 37    // arrow left
        || keyCode == 38    // arrow up
        || keyCode == 39    // arrow right
        || keyCode == 40    // arrow down
        || keyCode == 46);  // del

    return isAllowed;
};

InputFilter.extendsToValidRegExp = function(regExp, inputObj, eventObj) {
    var charCode;
    if (window.event)
        charCode = window.event.keyCode;
    else
        charCode = eventObj.charCode;

    return regExp.test(inputObj.value + String.fromCharCode(charCode));
}
// Keyboard - END


function bookmarksite(title, url)
{
    if (window.external)
	    window.external.AddFavorite(url, title);
    else if (window.sidebar)
	    window.sidebar.addPanel(title, url, "");
}

function checkEmail(email) 
{
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email))
        return true;

    return false;
}

function checkGSM(number) {
    if (/^[0-9]{9}$/.test(number))
        return true;

    return false;
}

function formatPrice(value) 
{ 
    var ret = Math.round(value * 100).toString(); 
    var len = ret.length; 
    if (len == 1) {ret = "00" + ret; len = 3} 
    if (len == 2) {ret =  "0" + ret; len = 3} 
    return ret.substring(0,len-2) + "," + ret.substring(len-2,len); 
} 

function moveLogo()
{
    offsetx = ((document.body.clientWidth - 800) / 2) + 193;
    imgwidth = document.getElementById("logoimg"+lastOpenedImageId).width;

    if (offsetx +  imgwidth > document.body.clientWidth)
         document.getElementById("logodiv"+lastOpenedImageId).style.left = document.body.clientWidth - (offsetx + imgwidth) + "px";
}
function openLogo(path, logo, id)
{
    document.getElementById("logoimg"+id).src= path + "/" + logo+".gif";
    document.getElementById("logodiv"+id).style.display="";
    document.getElementById("logodiv"+id).style.left = "0px";
    
    lastOpenedImageId = id;
    
    xmlStatHttp = false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
        try 
        {
            xmlStatHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) 
        {
            try
            {
                xmlStatHttp = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (e2) 
            {
                xmlStatHttp = false;
            }
        }
    @end @*/

    if (!xmlStatHttp && typeof XMLHttpRequest != 'undefined') {
        xmlStatHttp = new XMLHttpRequest();
    }

    D = new Date();
    
    xmlStatHttp.open("GET", "StatsUpdate.aspx?" + encrypt("TYPE=LOGO&ID=" + logo + "&RND=" + D.getTime() + D.getMilliseconds()), true);
   // xmlStatHttp.onreadystatechange = moveLogo;
    xmlStatHttp.send(null);
    
    img = new Image;
    img.onload = moveLogo;
    img.src = path + "/" + logo+".gif";
}
    
function logoOut(logo)
{   
    tid = setTimeout("hideLogo(" + logo+");", 2000);
    eval ("tid"+logo+"=" + tid + ";");
}

function logoIn(logo)
{   
    try
    {
        eval ("if (tid"+logo+") clearTimeout(tid"+logo+");");
    }catch(exc)
    {
    }
}

function hideLogo(logo)
{
    document.getElementById("logodiv"+logo).style.display="none";
}
function hideLogoEx(logo, url)
{
    comwnd = window.open(url, "commercial", '');	
    comwnd.focus();
    document.getElementById("logodiv"+logo).style.display="none";
}
function openmaphelp(name)
{
	helpwindow=window.open(name, "help", 'scrollbars=no,toolbar=no,location=no,status=yes,width=500,height=600');	
	helpwindow.focus();
}
function openhelp(name)
{
	helpwindow=window.open(name, "help", 'scrollbars=yes,toolbar=no,location=no,status=yes,width=500,height=600');	
	helpwindow.focus();
}
function openhelpActivity(name)
{
	helpwindow=window.open(name, "helpActivity", 'scrollbars=yes,toolbar=no,location=no,status=yes,width=500,height=445');	
	helpwindow.focus();
}	function FictualButton(sName, sHref)
{
	
	var name = sName.replace(/_/g, " ");    //Replace " " with "_".
	document.write("<img id=\""+sName+"\" src=\"_images/link_off.gif\" width=11 height=11 border=0><font class=button>&nbsp;"+sName.toUpperCase()+"</font>");
}






function TurnPKs(bValue)
{
	if (document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS01")) 
	{
		document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS01").checked = bValue;
		document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS02").checked = bValue;
		document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS03").checked = bValue;
		document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS04").checked = bValue;
		document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS05").checked = bValue;
		document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS07").checked = bValue;
	}
}

function SetPKs(x)
{
	if (x=="MOBIL")
	{
	    document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS080").checked = false;
	    document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS090").checked = false;
		SetPKsEnabled(!document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMSMOBIL").checked);
	}
	else if (x=="080")
	{
	    document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMSMOBIL").checked = false;
	    document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS090").checked = false;
		SetPKsEnabled(!document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS080").checked);
	}
	else if (x=="090")
	{
    	document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMSMOBIL").checked = false;
	    document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS080").checked = false;
		SetPKsEnabled(!document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS090").checked);
		
	}
	else
	{
	    document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMSMOBIL").checked = false;
	    document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS080").checked = false;
	    document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS090").checked = false;

		if (x=="on")
			SetPKsEnabled(true);
		else if (x=="off")
			SetPKsEnabled(false); 			
	}
}

function SetPKsEnabled(what)
{		
	if (document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS01")) 
	{
		document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS01").checked = what;
		document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS02").checked = what;
		document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS03").checked = what;
		document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS04").checked = what;
		document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS05").checked = what;
		document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS07").checked = what;
	}
}


function Clear()
{
	SetPKs("on");
	document.MASKA.KOREN.checked = true;
	document.MASKA.SPLOSNO.value = "";
	document.MASKA.NAZIV.value = "";
	document.MASKA.IME.value = "";
	document.MASKA.OPIS.value = "";
	document.MASKA.ULICA.value = "";
	document.MASKA.HISNA.value = "";
	document.MASKA.KRAJ.value = "";
	document.MASKA.TELEFON.value = "";
}




function Dej()
{
    chkYellowPages = document.getElementById("ctl00_ContentPlaceHolderRightContainer_YellowPages");
    
    // alert if YellowPages checkbox exists and is NOT checked
	if(null != chkYellowPages && false == chkYellowPages.checked)
	{
		alert("Po dejavnostih lahko iščete samo v Rumenih straneh!");
		return;
	}
	
	dejwindow=window.open("ActivityH_exw.aspx", "dejavnosti", 'scrollbars=1,toolbar=no,location=no,status=yes,width=620,height=500');				
	dejwindow.focus();
}

function SimpleDej()
{
    chkYellowPages = document.getElementById("ctl00_ContentPlaceHolderRightContainer_Yellow");
    
    // alert if YellowPages checkbox exists and is NOT checked
	if(null != chkYellowPages && false == chkYellowPages.checked)
	{
		alert("Po dejavnostih lahko iščete samo v Rumenih straneh!");
		return;
	}
	
	url = "ActivityH_exw.aspx?" + encrypt("DirType=GEN&Ac=TIS&CtrlID=ctl00_ContentPlaceHolderRightContainer_SimpleActivity");
	
	dejwindow=window.open(url, "dejavnosti", 'scrollbars=1,toolbar=no,location=no,status=yes,width=620,height=500');				
	dejwindow.focus();
}

function DejGeneralTis(ctrlId)
{
    url = "ActivityH_exw.aspx?" + encrypt("DirType=GEN&Ac=TIS&CtrlID="+ctrlId);
    
	dejwindow=window.open(url, "dejavnosti", 'scrollbars=1,toolbar=no,location=no,status=yes,width=620,height=500');				
	dejwindow.focus();
}


function printDej(sTextPrefix, sText)
{
	if (document.MASKA.PAGE.value != 'WHITE')
	{
		var sLink;
		if (navigator.appName == "Microsoft Internet Explorer")
		{
			sLink = "href='#DEJAVNOST' onClick='dej();'";
		}
		else
		{
			sLink = "href='ActivityH.aspx' target='Main'";
		}
		document.write(sTextPrefix + "<A tabindex=1 "+sLink+">" + sText + "</A>");
	}
}

function Add(odj1,sIme)
{
	var re;
	re = /%20/g;
	sIme = sIme.replace(re," ");
	
	if (parent.Main.document.MASKA.IME.value.search(sIme)==-1)
	{
		if (parent.Main.document.MASKA.IME.value=="")
			parent.Main.document.MASKA.IME.value = sIme;
		else
			parent.Main.document.MASKA.IME.value +=", "+sIme;

		parent.Main.document.MASKA.IME.value = parent.Main.document.MASKA.IME.value.replace(re," ");
	}

	parent.frames.Center.cols = "200,*,0";
}







mapWnd = null;
needsOldMap = /(MSIE 5.0)|(MSIE 5.5)|(Opera)/.test(navigator.userAgent) && navigator.platform == "Win32";

function openMap(x,y,n,a,p,t, pid) {
    // alert(pid);
    rndNum = Math.random();
    if (pid == undefined)
        strLink = "Page_Map.aspx?X=" + x + "&Y=" + y + "&n=" + n + "&a=" + a + "&p=" + p + "&t=" + t + "&r=" + rndNum;
    else
        strLink = "Page_Map.aspx?X=" + x + "&Y=" + y + "&n=" + n + "&a=" + a + "&p=" + p + "&t=" + t + "&r=" + rndNum + "&pid=" + pid;    
    
    
    window.location = strLink;
    
    /*
	
	
	
	if (needsOldMap == false)
	{
	    if (mapWnd == null)
	    {
	        strLink = "newmap.aspx?" + encrypt("X="+x+"&Y="+y+"&n="+n+"&a="+a+"&p="+p+"&t="+t+"&r="+rndNum);
	        if (glbUserType == 'N')
	            mapWnd=window.open(strLink,'karta','toolbar=no,location=yes,status=yes,width=1024,height=768,resizable=no');
	        else
	            mapWnd=window.open(strLink,'karta','toolbar=no,location=yes,status=yes,width=1024,height=768,resizable=yes');
	    }
	    else
	    {
	        try 
	        {
	            mapWnd.addNewLocation(x, y, n, a, p, t, 0);
	        }
	        catch(exc)
	        {
	            mapWnd = null;
	            openMap(x,y,n,a,p,t); //do it again
	        }
		    
	    }
	}
	else
	{
	    strLink = "map.aspx?" + encrypt("X="+x+"&Y="+y+"&n="+n+"&a="+a+"&p="+p+"&t="+t+"&r="+rndNum);
	    mapWnd=window.open(strLink,'karta','toolbar=no,location=no,status=yes,width=800,height=600,resize=no');
	}
	mapWnd.focus();*/
}



function openMapForTrajekt(x,y,n,a,hhid,whatever)
{
    if (needsOldMap == false)
	{
	    if (mapWnd == null)
	    {
	        strLink = "newmap.aspx?" + encrypt("X="+x+"&Y="+y+"&n="+n+"&a="+a+"&t=trajekt&hhid="+hhid);
	        if (glbUserType == 'N')
	            mapWnd=window.open(strLink,'karta','toolbar=no,location=no,status=yes,width=1024,height=768,resizable=no');
	        else
	            mapWnd=window.open(strLink,'karta','toolbar=no,location=no,status=yes,width=1024,height=768,resizable=yes');
	    }
	    else
	    {
	        try 
	        {
	            mapWnd.addNewLocation(x, y, n, a, "", "trajekt");
	        }
	        catch(exc)
	        {
	            mapWnd = null;
	            openMapForTrajekt(x,y,n,a,hhid,whatever); //do it again
	        }
		    
	    }
	}
	else
	{
	    strLink = "map.aspx?" + encrypt("X="+x+"&Y="+y+"&n="+n+"&a="+a+"&hhid="+hhid);
	    mapWnd=window.open(strLink,'karta','toolbar=no,location=no,status=yes,width=800,height=600,resize=no');
	}
	
	mapWnd.focus();
}


function checkString(sStr, sAllow)
{  
  var nAllowLen = sAllow.length;
  var nLen      = sStr.length;
  var nCnt = 0;
  var bIsChar = true;
  for(i=0; i<nLen; i++)
  {
    ch=sStr.charAt(i);
    nCnt = 0;
    do
    {
      ch2 = sAllow.charAt(nCnt);
      nCnt++;
    }
    while ((nCnt<nAllowLen) && (ch!=ch2));
    if(ch!=ch2)
      bIsChar = false;
  }
  return bIsChar;  
}



function checkpages(which)
{
	if (which=="pagewhite")			
	{
		if (theForm.ctl00_ContentPlaceHolderRightContainer_WhitePages.checked==false)
			(theForm.ctl00_ContentPlaceHolderRightContainer_YellowPages.checked=true);
	}
	else if (which=="pageyellow")
	{
		if (theForm.ctl00_ContentPlaceHolderRightContainer_YellowPages.checked==false)
			(theForm.ctl00_ContentPlaceHolderRightContainer_WhitePages.checked=true);
	}
	if (theForm.ctl00_ContentPlaceHolderRightContainer_YellowPages.checked==false)
	{
		document.getElementById("dej").style.display="none";
	}
	else
	{
		document.getElementById("dej").style.display="";
	}
}

function checkpagesSimple(which)
{
	if (which=="pagewhite")			
	{
		if (theForm.ctl00_ContentPlaceHolderRightContainer_White.checked==false)
			(theForm.ctl00_ContentPlaceHolderRightContainer_Yellow.checked=true);
	}
	else if (which=="pageyellow")
	{
		if (theForm.ctl00_ContentPlaceHolderRightContainer_Yellow.checked==false)
			(theForm.ctl00_ContentPlaceHolderRightContainer_White.checked=true);
	}
	if (theForm.ctl00_ContentPlaceHolderRightContainer_Yellow.checked==false)
	{
		document.getElementById("ctl00_ContentPlaceHolderRightContainer_simpleDej").style.display="none";
	}
	else
	{
		document.getElementById("ctl00_ContentPlaceHolderRightContainer_simpleDej").style.display="";
	}
}

function ShowChildTree(sID, isExW, showCnt, tipUpor) 
{
	var zamik;
	
	zamik = 'blank'+sID;
	var imgZamik = window.document.getElementById(zamik);
	if(imgZamik.style.width=="") 
	{
		imgZamik.style.width="1px";
	}
	
	var ifrmObj = window.document.getElementById('tempListFrame');
	ifrmObj.src = 'IFrameTmp.asp?SHOWCHILD=' + sID + '&ZAMIK='+ imgZamik.style.width + '&ISEXW=' + isExW + '&CNTCHILD=' + showCnt + '&cTip='+tipUpor;
	
}

function HideShow(sIDTag)
{
	
	var objectTag = window.document.getElementById(sIDTag)
	var ifrmObj = window.document.getElementById('tempListFrame')
	if ((objectTag.style.display == '')&&(ifrmObj!=null))
	{
		objectTag.innerHTML ="";
		objectTag.style.display = 'none';
		
	}
	else
	{
		objectTag.style.display = '';
	}
}

function ChangePic(sID, sImg1, sImg2, sImgFNN, sImgFNA)
{
	var object = window.document.getElementById(sID)
	var image1 = window.document.getElementById(sImg1)
	if (object.style.display == 'none')
	{
		image1.src = sImgFNN;
	}
	else
	{
		image1.src = sImgFNA;
	}
}



function activityStartSearch(actObject, isExW, isLogON, tipU, ctrlID)
{
    // two cases:
    // external window case
    // tab page case
    if (isExW==1)
    {
        // this is external window case
        // two cases must be handeled
        // TIS: activity text is replaced by a new one and search starts automatically
        // PIS: activity entries are concatenated with ',' search does NOT start automatically
        
        var ac;
        var btn = opener.document.getElementById('ctl00_ContentPlaceHolderRightContainer_ImageButton2');
        
        if (ctrlID != null && ctrlID != "")
        {
            var cid = new String(ctrlID);
            ac = opener.document.getElementById(cid );
           
           	            
            if (ac)
            {
                if (ac.nodeName == "SELECT")
                {
                    var obj = opener.document.createElement("OPTION");
                    ac.options.add(obj);
                    obj.value = GetInnerText(actObject.innerHTML);
                    obj.text = GetInnerText(actObject.innerHTML); 
                    obj.selected = true;
                }
                else
                {
                    ac.value = GetInnerText(actObject.innerHTML);
                    ac.style.color = objDefaultField.style.color;
                    ac.style.fontSize = objDefaultField.style.fontSize;
                }
                
                window.close();
                return;
            }
        }
       
        
        // first name and activity share the same input field in TIS
        ac = opener.document.getElementById('ctl00_ContentPlaceHolderRightContainer_FirstName');
        if(ac)
        {
            ac.value = GetInnerText(actObject.innerHTML);
            ac.style.color = objDefaultField.style.color;
            ac.style.fontSize = objDefaultField.style.fontSize;
            if(btn) btn.click();
            window.close();
            return;
        }            
        
        // activity is a separate field in PIS
        ac = opener.document.getElementById('ctl00_ContentPlaceHolderRightContainer_Activity');
        if(ac)
        {
            if('' != ac.value) ac.value += ',';
            ac.value += GetInnerText(actObject.innerHTML);
            //if(btn) btn.click();
            window.close();
            return;
        }
        
         // activity is a separate field in ReportChangesCorrect.aspx
        ac = opener.document.getElementById('ctl00_ContentPlaceHolder1_ActivityTIS');
        if(ac)
        {
            if('' != ac.value) ac.value += ',';
            ac.value += GetInnerText(actObject.innerHTML);
            //if(btn) btn.click();
            window.close();
            return;
        }
    }
    else
    {
        // this is tab page case (exists in TIS only)
        newloc = "ACTIVITY=" + GetInnerText(actObject.innerHTML);
	    
        if (isLogON == 1)
        {
            if (theForm.ctl00_ContentPlaceHolderRightContainer_OMS01.checked == true)
                newloc += "&OMS01=1";
            if (theForm.ctl00_ContentPlaceHolderRightContainer_OMS02.checked == true)
                newloc += "&OMS02=1";
            if (theForm.ctl00_ContentPlaceHolderRightContainer_OMS03.checked == true)
                newloc += "&OMS03=1";
            if (theForm.ctl00_ContentPlaceHolderRightContainer_OMS04.checked == true)
                newloc += "&OMS04=1";
            if (theForm.ctl00_ContentPlaceHolderRightContainer_OMS05.checked == true)
                newloc += "&OMS05=1";
            if (theForm.ctl00_ContentPlaceHolderRightContainer_OMS07.checked == true)
                newloc += "&OMS07=1";            
        }
        
        newloc = "default.aspx?" + encrypt(newloc);
        
        document.location = newloc;
        return;
    }
}

function ClearAllPK(formObj)
{		
    
	var sObj = window.document.getElementById('Clear');
	
	if(sObj)
	{
	    
	    var sText = new String();
		sText = GetInnerText(sObj.innerHTML);


		if (formObj)	
		{	
		   	if(sText == "briši vse"||sText=="deselect all")
			{
				formObj.ctl00_ContentPlaceHolderRightContainer_OMS01.checked = false;
				formObj.ctl00_ContentPlaceHolderRightContainer_OMS02.checked = false;
				formObj.ctl00_ContentPlaceHolderRightContainer_OMS03.checked = false;
				formObj.ctl00_ContentPlaceHolderRightContainer_OMS04.checked = false;
				formObj.ctl00_ContentPlaceHolderRightContainer_OMS05.checked = false;
				formObj.ctl00_ContentPlaceHolderRightContainer_OMS07.checked = false;
				if (g_sLang=="EN")
					sObj.innerHTML = "select all";
				else
					sObj.innerHTML = "izberi vse";
			}
			else if(sText=="izberi vse"||sText=="select all")
			{
				formObj.ctl00_ContentPlaceHolderRightContainer_OMS01.checked = true;
				formObj.ctl00_ContentPlaceHolderRightContainer_OMS02.checked = true;
				formObj.ctl00_ContentPlaceHolderRightContainer_OMS03.checked = true;
				formObj.ctl00_ContentPlaceHolderRightContainer_OMS04.checked = true;
				formObj.ctl00_ContentPlaceHolderRightContainer_OMS05.checked = true;
				formObj.ctl00_ContentPlaceHolderRightContainer_OMS07.checked = true;
				if (g_sLang=="EN")
					sObj.innerHTML = "deselect all";
				else
					sObj.innerHTML = "briši vse";
			}
			
			try
			{
			    formObj.ctl00_ContentPlaceHolderRightContainer_OMSMOBIL.checked=false;
			    formObj.ctl00_ContentPlaceHolderRightContainer_OMS080.checked=false;
			    formObj.ctl00_ContentPlaceHolderRightContainer_OMS090.checked=false;
			}catch(e){}
			
		}
	}

}

  
  function GetInnerText(xStr)
  {
  	var regExp = /<\/?[^>]+>/gim;
    xStr = xStr.replace(regExp,"");
    regExp = /\s\s/igm;
    xStr = xStr.replace(regExp,"");
    regExp = /^\s/gim;
    xStr = xStr.replace(regExp,"");
    
    return xStr;
  }


function UpDateCount(isChild, startID, tipUpor)
{
  	var strPK = "";
  	
  	if (tipUpor=='N')
  	{
  		strPK = '123457';
  	}
	else
	{
	  	if (isChild == "1")
	  	{
	  	    if(opener.document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS01").checked == true) {strPK += "1";}
			if(opener.document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS02").checked == true) {strPK += "2";}
			if(opener.document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS03").checked == true) {strPK += "3";}
			if(opener.document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS04").checked == true) {strPK += "4";}
			if(opener.document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS05").checked == true) {strPK += "5";}
			if(opener.document.getElementById("ctl00_ContentPlaceHolderRightContainer_OMS07").checked == true) {strPK += "7";}
		}
		else if (isChild == "0")
		{

			if(theForm.ctl00_ContentPlaceHolderRightContainer_OMS01.checked == true) {strPK += "1";}
			if(theForm.ctl00_ContentPlaceHolderRightContainer_OMS02.checked == true) {strPK += "2";}
			if(theForm.ctl00_ContentPlaceHolderRightContainer_OMS03.checked == true) {strPK += "3";}
			if(theForm.ctl00_ContentPlaceHolderRightContainer_OMS04.checked == true) {strPK += "4";}
			if(theForm.ctl00_ContentPlaceHolderRightContainer_OMS05.checked == true) {strPK += "5";}
			if(theForm.ctl00_ContentPlaceHolderRightContainer_OMS07.checked == true) {strPK += "7";}	
		}
	}	
	

	var nLen = strPK.length;
	var nSum = 0;
	var i =0
	var objSuma
	var sCValueList="";
	var arrayNum
	var objX;
	
	nCnt = startID;
	nCValue = 0;
	endLoop = true;
	
	
	
	do
	{	
		objX = window.document.getElementById('PK'+nCnt);
		
	 	if ((objX))
	 	{
	 		sCValueClean =GetInnerText(objX.innerHTML);
	 		sCValueList = new String(sCValueClean);
	   		objArray = sCValueList.split(';');
	   			
	 		
	 		for(i=0; i<nLen; i++)
			{
    				pk=strPK.charAt(i);
 
   				if(pk == "7") 
   				{
   					k = eval(pk) - 1;
   				}
   				else
   				{
   					k = eval(pk) ;
   				}
				arrayNum = objArray[k];
				nCValue += eval(arrayNum);
   			
	   			nSum += nCValue;
	   			nCValue = 0;
	   		}
	   		
	   		sumName = "SUMA_" + objArray[0];
	 
	   		objSuma = document.getElementById(sumName);
	   		
	   		if (isChild == "1")
	   		    objSuma.innerHTML = "";
	   		else
	   		    objSuma.innerHTML = "(" + nSum + ")";
	   		    
	   		nSum =0;
	   			
	   	}
		else
		{
			endLoop = false;
		}
		nCnt++;
			
	}
	while (endLoop);	
}


function openCenik(tip, oglas)
{
	
	openOglasCenik("AdvertisingPriceListTypes.aspx?" + encrypt("Type=" + tip + "&AdvType="+ oglas),'C', '');
}

function openOglas(AdvType)
{	
	if(AdvType== 'bRS')
	{
		medij = 'K'
	}
	else
	{
		medij = 'E'
	}
	openOglasCenik("AdvertisingAdvertisement.aspx?" + encrypt("AdvType=" + AdvType), medij, AdvType);
}

function openOglasCenik(sUrl, medij, tip)
{
    var pricewindow;
    if(tip == 'PV')
	{
	    pricewindow=window.open(sUrl, "Oglas_cenik", 'toolbar=no,location=no,status=on,scrollbars=yes,width=500,height=755');
	}
	else if (medij == 'E')
	{
		pricewindow=window.open(sUrl, "Oglas_cenik", 'toolbar=no,location=no,status=on,scrollbars=yes,width=430,height=600');				
	}
	else if( medij== 'K')
	{
		pricewindow=window.open(sUrl, "Oglas_cenik", 'toolbar=no,location=no,status=on,scrollbars=yes,width=650,height=530');				
	}
	else
	{
		pricewindow=window.open(sUrl, "Oglas_cenik", 'toolbar=no,location=no,status=on,scrollbars=yes,width=650,height=300');				
	}
	pricewindow.focus();
}

function urlencode(str) {
    //str = escape(str);
    str = str.replace('+', '%2B');
    str = str.replace('%20', '+');
    str = str.replace('*', '%2A');
   // str = str.replace('/', '%2F');
    str = str.replace('@', '%40');
    str = str.replace('=', '%3D');
    return str;
}

function urldecode(str) {
    str = str.replace('+', ' ');
    str = unescape(str);
    return str;
}

function openBiziCard(url)
{
    url = urlencode(url);
    url = urlencode(url);
    url = urlencode(url);
    url = urlencode(url);
    var vizitkabiziWindow;
	if (screen.availWidth < 800)
		vizitkabiziWindow=window.open(url, "bizisi",'width=600,height='+(screen.availHeight-30));
	else if (screen.availWidth<1024)
		vizitkabiziWindow=window.open(url, "bizisi",'width=800,height=600');
	else 
		vizitkabiziWindow=window.open(url, "bizisi",'scrollbars=yes,location=yes,status=on,width=1024,height=768');
	
	vizitkabiziWindow.focus();
}

function openCard(id, tid, pvplus)
{
    openCardEx("ShowCard.aspx", id, tid, pvplus);
}



function openCardEx(pageURL, id, tid, pvplus)
{
	sUrl = pageURL + "?" + encrypt("RID=" + id + "&TID=" + tid);
	var vizitkaWindow;
	if (pvplus)
	{
		if (screen.availHeight<800)
			vizitkaWindow=window.open(sUrl, "BusinessCard",'scrollbars=yes,toolbar=no,location=no,status=on,width=600,height='+(screen.availHeight-30));
		else
			vizitkaWindow=window.open(sUrl, "BusinessCard",'scrollbars=yes,toolbar=no,location=no,status=on,width=600,height=800');
	}
	else
	    vizitkaWindow=window.open(sUrl, "BusinessCard", 'scrollbars=yes,toolbar=no,location=no,status=on,width=600,height=450');
	    
	vizitkaWindow.focus();
}

function openBanners()
{
    //window.open(/*"AllBanners.aspx"*/"http://adserver.iprom.net/adserver/tisAllBanners.pl","Seznam_bannerjev",'scrollbars=yes,toolbar=no,location=no,status=on,width=520,height=600')
    window.document.write('<html><head></head><body><script language="javascript1.1" src="http://teledat.iprom.net/adserver/Event/Impression?z=25&t=js&sid=puscica"></script><noscript>  <a href="http://teledat.iprom.net/adserver/Event/Click?z=25&sid=puscica">  <img src="http://teledat.iprom.net/adserver/Event/Impression?z=25&sid=puscica" border="0"></a></noscript></body></html>');
}




//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Functions needed for printing page
// zamenjaj - header_start.htm, print.htm
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function openPrint(sUrl)  
{ 
    var printWindow;  
    printWindow=window.open(sUrl, "Predogled_tiskanja", 'toolbar=no,location=no,status=on,width=750, height=699, scrollbars=yes'); 
    //printWindow=window.open(sUrl, "Predogled_tiskanja", 'toolbar=yes,location=yes,status=yes,width=610, height=699, scrollbars=yes'); 
    printWindow.focus(); 
}

function showActivityHeader(activityHeaderID, currentCheckboxStatus)
{
    var activityHeader = window.document.getElementById(activityHeaderID);
    
    // show if necessary
    if (currentCheckboxStatus)
    {
        activityHeader.value = parseInt(activityHeader.value) + 1;
        if (activityHeader.value > 0)
        {
            activityHeader.previousSibling.className = "";    // previous sibling element is table containing specified region
        }
    }
    else    // hide if necessary
    {
        activityHeader.value = parseInt(activityHeader.value) - 1;
        if (activityHeader.value == 0)
        {
            activityHeader.previousSibling.className = "noprint";    // previous sibling element is table containing specified region
        }
    }
}

function showPrintingRecord(divName, divRecordControls, divCard, divRecordCheckbox, cardCheckBox, visible)
{
	if (document.getElementById(divName) == null)
		return;		
		
	document.getElementById(divName).className = (visible ? '' : 'noprint');
	document.getElementById(divName).style.backgroundColor = (visible ? '#FFFFFF' : '#888888');
	
	document.getElementById(divRecordControls).style.backgroundColor = (visible ? '#F6F6F6' : '#888888');

	if ((divCard != null) && (divCard != '') && (document.getElementById(divCard) != null))
	{
		if (visible)
		{
			showPrintingCard(divCard, divRecordCheckbox, document.getElementById(cardCheckBox).checked);
		}
		else
		{
			showPrintingCard(divCard, divRecordCheckbox, false);
		}
	}
}	

function showPrintingCard(cardDivName, divRecordCheckbox, visible)
{
	if (document.getElementById(cardDivName) == null)
		return;
	if (document.getElementById(divRecordCheckbox).checked == false)	// if record is print-disabled, don't show card
		document.getElementById(cardDivName).style.display = 'none';
	else	
		document.getElementById(cardDivName).style.display = (visible ? 'block' : 'none');
}	

function toggleAllPrintingRecords()
{
    els = document.forms[0].elements;
    
    bFirst = true;
    bCheckValue = false;
    for (i = 0; i < els.length; i++)
    {
        if(els[i].id.indexOf('RecordCB') > -1)
        {
            if (bFirst)
            {
                bFirst = false;
                bCheckValue = ! els[i].checked;
            }
            if (els[i].checked != bCheckValue)
                els[i].click();
        }
    }
	
	if (document.getElementById("skrijVseBtn") != null)
	{
		document.getElementById("skrijVseBtn").style.display = (bCheckValue ? 'block' : 'none');
		document.getElementById("prikaziVseBtn").style.display = (bCheckValue ? 'none' : 'block');
	}	    
}

function toggleAllPrintingCards()
{
    els = document.forms[0].elements;
    
    bFirst = true;
    bCheckValue = false;
    for (i = 0; i < els.length; i++)
    {
        if(els[i].id.indexOf('CardCB') > -1)
        {
            if (bFirst)
            {
                bFirst = false;
                bCheckValue = ! els[i].checked;
            }
            if (els[i].checked != bCheckValue)
                els[i].click();
        }
    }
    
    if (bFirst)
    {
		if (g_sLang == "SI")
			alert('Med zadetki ni nobene vizitke.');	    
		else
		    alert('There are no business cards.');
			
    }
    else
    {
		if (document.getElementById("prikaziVizBtn") != null)
		{
		    document.getElementById("skrijVizBtn").style.display = (bCheckValue ? 'block' : 'none');
		    document.getElementById("prikaziVizBtn").style.display = (bCheckValue ? 'none' : 'block');
		}
    }
}		

function GetAttrVal(e,n){var s;s='';if(e.attributes&&e.attributes[n])s=e.attributes[n].nodeValue;return s;}
function GetSubEltByID(e,s){return GSERZXX(e,s,1);}
function GSERZXX(e,s,i){if(i>60||!e||!e.childNodes)return null;var j,c,x,y;for(j=0;j<e.childNodes.length;j+=1){c=e.childNodes[j];x=GetAttrVal(c,'id');if(x==s){return c;}if(c.childNodes&&c.childNodes.length){y=GSERZXX(c,s,i+1);if(y){return y;}}}return null;}
function GetSubEltByAttr(e,n,s){return GSERZXY(e,n,s,1);}
function GSERZXY(e,n,s,i){if(i>60||!e||!e.childNodes)return null;var j,c,x,y;for(j=0;j<e.childNodes.length;j+=1){c=e.childNodes[j];x=GetAttrVal(c,n);if(x==s){return c;}if(c.childNodes&&c.childNodes.length){y=GSERZXY(c,n,s,i+1);if(y){return y;}}}return null;}

function showHideElement(idString, visible)
{
	if (document.getElementById(idString) == null)
		return;
	if (document.getElementById(idString).style == null)
		return;
	document.getElementById(idString).style.display = (visible ? 'block' : 'none');
}

function toggleElement(idString)
{
	if (document.getElementById(idString) == null)
		return;
	if (document.getElementById(idString).style == null)
		return;
	document.getElementById(idString).style.display = 
		(document.getElementById(idString).style.display == 'block' ? 'none' : 'block');
}	

function goToSearch()
{
	x=new String(document.location);
	if (x.indexOf("Default.aspx")==-1)
		document.location="Default.aspx";
	focus();
}



/******************************
URLQueryString, parameters, ...
******************************/

// constructor
function URLQueryString() {
    this.parameters = null;
    
    // parse query string and convert it to object where fields represent query parameters
    // (e.g. url Page_Map.aspx?a=bla&b=ck -> URLQueryString object instance urlQueryString.parameters = {a: "bla", b: "ck";})
    try {
        var query = decodeURI(window.document.location.toString()).split("?");

        // no parameters
        if (query.length < 2) {
            return;
        }

        // create object with parameters' names as fields and fill in corresponding values
        this.parameters = new Object();
        var params = query[1].split("&");
        for (var i = 0; i < params.length; i++) {
            var pair = params[i].split("=");
            this.parameters[pair[0]] = (pair.length > 0) ? pair[1] : null;
        }
    } catch (exception) {
        // malformed URL
        this.parameters = null;
    }
}

URLQueryString.prototype = {
    // only field
    parameters: null
}
// end - URLQueryString, parameters, ...
	
	
	


//Hex to Dec converter
var hD="0123456789ABCDEF";
function d2h(d) 
{
    var h = hD.substr(d&15,1);
    while(d>15) {d>>=4;h=hD.substr(d&15,1)+h;}
    return h;
}
function h2d(h) 
    {return parseInt(h,16);} 


function getCrc(input, crclen)
{
    var lcrc = 0;
    for (var counter = 0; counter < input.length; counter++) 
    {
        lcrc += input.charCodeAt(counter);
    }
    
    var hcrc = d2h(lcrc);
    var scrc = new String();
    for (var i = hcrc.length; i < crclen; i++)
        scrc += "0";
    
    scrc += hcrc;
    return scrc;
}


// This code was written by Tyler Akins and has been placed in the
// public domain.  It would be nice if you left this header intact.
// Base64 code from Tyler Akins -- http://rumkin.com

var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

function encode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   do {
      chr1 = input.charCodeAt(i++);
      chr2 = input.charCodeAt(i++);
      chr3 = input.charCodeAt(i++);

      enc1 = chr1 >> 2;
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
      enc4 = chr3 & 63;

      if (isNaN(chr2)) {
         enc3 = enc4 = 64;
      } else if (isNaN(chr3)) {
         enc4 = 64;
      }

      output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + 
         keyStr.charAt(enc3) + keyStr.charAt(enc4);
   } while (i < input.length);
   
   return output;
}

function decode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

   do {
      enc1 = keyStr.indexOf(input.charAt(i++));
      enc2 = keyStr.indexOf(input.charAt(i++));
      enc3 = keyStr.indexOf(input.charAt(i++));
      enc4 = keyStr.indexOf(input.charAt(i++));

      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;

      output = output + String.fromCharCode(chr1);

      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }
   } while (i < input.length);

   return output;
}



function encrypt(input) 
{
    if (!glbEncoding)
        return input;
    input += getCrc(input, 8);
    
    var encrypted_string = ""
    
    var keyarray = new Array();
    keyarray[0] = 116;
    keyarray[1] = 0;
    keyarray[2] = 105;
    keyarray[3] = 0;
    keyarray[4] = 115;
    keyarray[5] = 0;
    

    var keycounter = 0;
    adnull = false;
    for (var counter = 0; counter < input.length; counter++) 
    {
        // Get the current cookie character
        do
        {
            if(!adnull)
                icharacter = input.charCodeAt(counter) % 256;
            else
                icharacter = Math.floor(input.charCodeAt(counter) / 256);
        
            key_character = keyarray[keycounter];
            
            keycounter++;
            if (keycounter == keyarray.length)
                keycounter = 0;

            encChar = (icharacter ^ key_character)%256;


            encrypted_string += String.fromCharCode(encChar); 
            
            adnull = !adnull;
        }
        while (adnull);
    }
    
    return encode64(encrypted_string);
}



/******************************************
From fields & submit functionality
******************************************/

var objDefaultField = new defaultField();
var objEmptyField = new emptyField();

function onFocusSearchField(obj)
{
 /*   if (obj.style.color == objEmptyField.style.color &&
    obj.style.fontSize == objEmptyField.style.fontSize)
    {
        obj.value = '';
        obj.style.color = objDefaultField.style.color;
        obj.style.fontSize = objDefaultField.style.fontSize;
    }*/
}

function onBlurSearchField(obj, fieldType)
{
  /*  if (obj.value == "")
    {
        var typedField = getEmptyFieldValueFor(fieldType);
        obj.style.color = typedField.style.color;
        obj.style.fontSize = typedField.style.fontSize;
        obj.value = typedField.text;
        
    }*/
}

function defaultField()
{
    this.style = new Object();
    if (/(Opera)/.test(navigator.userAgent))
        this.style.color = "#000000";
    else
        this.style.color = "black";
    this.style.fontSize = "small";
}

function emptyField(text)
{
    this.text = text;
    this.style = new Object();
        if (/(Opera)/.test(navigator.userAgent))
        this.style.color = "#c0c0c0";
    else
        this.style.color = "silver";
    this.style.fontSize = "smaller";
}

function getEmptyFieldValueFor(fieldType)
{
    if (fieldType == "SimpleActivity")
        return (new emptyField("npr. Računovodstvo / Trgovina"));
    else if (fieldType == "SimpleWhere")
        return (new emptyField("npr. Ljubljana / Maribor / Cigaletova"));
    else if (fieldType == "SimpleWhat")
        return (new emptyField("npr. Novak / trgovina"));
    else if (fieldType == "GeneralAdvanced")
        return (new emptyField("npr. Zdravstveni dom / Novak / trgovina"));
    else if (fieldType == "Surname")
        return (new emptyField("npr. Novak / Janez / Telekom Slovenije"));
    else if (fieldType == "FirstName")
        return (new emptyField("npr. Računovodstvo / trgovina"));
    else if (fieldType == "Street")
        return (new emptyField("npr. Cigaletova"));
    else if (fieldType == "HouseNumber")
        return (new emptyField("npr. 15"));
    else if (fieldType == "Post")
        return (new emptyField("npr. Ljubljana / Maribor / 3000"));
    else if (fieldType == "Phone")
        return (new emptyField("npr. 2345698 / 123456"));
    else if (fieldType == "TaxNumber")
        return (new emptyField("npr. 12345679"));
    else if (fieldType == "Title")
        return (new emptyField("npr. TSmedia"));
    else if (fieldType == "Maticna")
        return (new emptyField("npr. 1234567890"));
    else if (fieldType == "TRR")
        return (new emptyField("npr. SI56 xxxx xxxx xxxx xxx"));
    else if (fieldType == "Activity")
        return (new emptyField("npr. 64.200 (TELEKOMUNIKACIJE) / TELEKOMUNIKACIJE"));
    else
        return (new emptyField("npr. ?"));
}

function onFormSubmit()
{
    var formField;
    
    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_SimpleActivity");
    if (formField != null && formField.style.color == objEmptyField.style.color)    // sufficient; no need to check fontSize
    {
        formField.value = "";
    }

    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_SimpleWhere");
    if (formField != null && formField.style.color == objEmptyField.style.color)
    {
        formField.value = "";
    }

    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_SimpleWhat");
    if (formField != null && formField.style.color == objEmptyField.style.color)
    {
        formField.value = "";
    }

    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_GeneralAdvanced");
    if (formField != null && formField.style.color == objEmptyField.style.color)
    {
        formField.value = "";
    }

    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_Surname");
    if (formField != null && formField.style.color == objEmptyField.style.color)
    {
        formField.value = "";
    }

    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_FirstName");
    if (formField != null && formField.style.color == objEmptyField.style.color)
    {
        formField.value = "";
    }

    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_Street");
    if (formField != null && formField.style.color == objEmptyField.style.color)
    {
        formField.value = "";
    }

    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_HouseNumber");
    if (formField != null && formField.style.color == objEmptyField.style.color)
    {
        formField.value = "";
    }

    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_Post");
    if (formField != null && formField.style.color == objEmptyField.style.color)
    {
        formField.value = "";
    }

    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_Phone");
    if (formField != null && formField.style.color == objEmptyField.style.color)
    {
        formField.value = "";
    }
}

function onPageBodyLoad()
{
    var formField;
    var oef;
    
    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_SimpleActivity");
    oef = getEmptyFieldValueFor("SimpleActivity");
    if (formField != null && (formField.value == "" || formField.value == oef.text))
    {
        formField.style.color = oef.style.color;
        formField.style.fontSize = oef.style.fontSize;
        formField.value = oef.text;
    }

    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_SimpleWhere");
    oef = getEmptyFieldValueFor("SimpleWhere");
    if (formField != null && (formField.value == "" || formField.value == oef.text))
    {
        formField.style.color = oef.style.color;
        formField.style.fontSize = oef.style.fontSize;
        formField.value = oef.text;        
    }

    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_SimpleWhat");
    oef = getEmptyFieldValueFor("SimpleWhat");
    if (formField != null && (formField.value == "" || formField.value == oef.text))
    {
        formField.style.color = oef.style.color;
        formField.style.fontSize = oef.style.fontSize;
        formField.value = oef.text;
    }

    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_GeneralAdvanced");
    oef = getEmptyFieldValueFor("GeneralAdvanced");
    if (formField != null && (formField.value == "" || formField.value == oef.text))
    {
        formField.style.color = oef.style.color;
        formField.style.fontSize = oef.style.fontSize;
        formField.value = oef.text;       
    }

    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_Surname");
    oef = getEmptyFieldValueFor("Surname");
    if (formField != null && (formField.value == "" || formField.value == oef.text))
    {
        formField.style.color = oef.style.color;
        formField.style.fontSize = oef.style.fontSize;
        formField.value = oef.text;        
    }

    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_FirstName");
    oef = getEmptyFieldValueFor("FirstName");
    if (formField != null && (formField.value == "" || formField.value == oef.text))
    {
        formField.style.color = oef.style.color;
        formField.style.fontSize = oef.style.fontSize;
        formField.value = oef.text;
    }

    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_Street");
    oef = getEmptyFieldValueFor("Street");
    if (formField != null && (formField.value == "" || formField.value == oef.text))
    {
        formField.style.color = oef.style.color;
        formField.style.fontSize = oef.style.fontSize;
        formField.value = oef.text;        
    }

    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_HouseNumber");
    oef = getEmptyFieldValueFor("HouseNumber");
    if (formField != null && (formField.value == "" || formField.value == oef.text))
    {
        formField.style.color = oef.style.color;
        formField.style.fontSize = oef.style.fontSize;
        formField.value = oef.text;       
    }

    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_Post");
    oef = getEmptyFieldValueFor("Post");
    if (formField != null && (formField.value == "" || formField.value == oef.text))
    {
        formField.style.color = oef.style.color;
        formField.style.fontSize = oef.style.fontSize;
        formField.value = oef.text;
    }

    formField = window.document.getElementById("ctl00_ContentPlaceHolderRightContainer_Phone");
    oef = getEmptyFieldValueFor("Phone");
    if (formField != null && (formField.value == "" || formField.value == oef.text))
    {
        formField.style.color = oef.style.color;
        formField.style.fontSize = oef.style.fontSize;
        formField.value = oef.text;
    }

    // finally register event listener for forms's onsubmit event
    var form = window.document.getElementById("aspnetForm");
    if (form == null)
        return;
    if (form.addEventListener)
    {
        form.addEventListener('submit', onFormSubmit, false); 
    }
    else if (window.attachEvent)
    {
        form.attachEvent('onsubmit', onFormSubmit);
    }
}



var continueHref;
function ReportClickedHitStat(obj, id, pos, type) {
   // alert(id + "-" + pos + "-" + type);
    //alert(this);
    continueHref = obj.href;
    TisSearch.ReportClickedHit(id, pos, type, ReportClickedHitStatSucced);
   // alert(continueHref);
    return false;
}


function ReportClickedHitStatSucced(result) {
   // alert(continueHref);
    window.location = continueHref;
    //window.open(continueHref, "_self", "", false);
    //document.location = continueHref;
}

function UpdateMiniMapDetails(wx, wy) {
    obj = document.getElementById("miniMapCross");
    //width 200 height 129
    // x1 360000 x2 650000  y1 20000 y2 200000

    wposx = wx - 360000;
    wposy = wy - 20000;

    x = (148 * wposx) / 290000;
    y = 104 - ((104 * wposy) / 180000);
    y = y - 10;
    x = x - 4;


    if (x < 0)
        x = 0;
    if (x > 148)
        x = 148;
    if (y < -2)
        y = -2;
    if (y > 105)
        y = 105;
    obj.style.top = y + "px";
    obj.style.left = x + "px";
}


/* Company details - Organigram, Branches */
function Organigram() {
}

Organigram.toggle = function(sectionId) {
    var section = window.document.getElementById(sectionId);
    if (section != null) {
        if (section.className.indexOf("opened") > -1)
            section.className = section.className.replace("opened", "closed");
        else
            section.className = section.className.replace("closed", "opened");
    }
}
