﻿// JScript File

/*
    Summury: Извършва скриване / показване на подменю при натискане на root елемент от менюто.
    Developer: Марио Ангелов
*/
function MenuItemControl(subMenuId)
{      
    if(document.getElementById(subMenuId).style.display != 'none')
    {
        document.getElementById(subMenuId).style.display = 'none';        
    }
    else
    {               
        if(navigator.appName != 'Microsoft Internet Explorer')
        {
            document.getElementById(subMenuId).style.display = 'table-row';
        }
        else
        {
            document.getElementById(subMenuId).style.display = 'block';
        } 
           
    }
}

/*
    Summury: Обслужва анимацията на картата.
    Developer: Марио Ангелов
*/
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

/*
    Summury: Обслужва анимацията на картата.
    Developer: Марио Ангелов
*/
function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

/*
    Summury: Обслужва анимацията на картата.
    Developer: Марио Ангелов
*/
var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		map_01_Plovdiv_over = newImage("App_Themes/images/map_01-Plovdiv_over.jpg");
		map_01_drugi_over = newImage("App_Themes/images/map_01-drugi_over.jpg");
		map_01_Stara_Zagora_over = newImage("App_Themes/images/map_01-Stara-Zagora_over.jpg");
		map_01_Blagoevgrad_over = newImage("App_Themes/images/map_01-Blagoevgrad_over.jpg");
		map_01_Ruse_over = newImage("App_Themes/images/map_01-Ruse_over.jpg");
		map_01_Veliko_Tyrnovo_over = newImage("App_Themes/images/map_01-Veliko-Tyrnovo_over.jpg");
		map_01_Pleven_over = newImage("App_Themes/images/map_01-Pleven_over.jpg");
		map_01_Burgas_over = newImage("App_Themes/images/map_01-Burgas_over.jpg");
		map_01_Sofia_over = newImage("App_Themes/images/map_01-Sofia_over.jpg");
		map_01_Varna_over = newImage("App_Themes/images/map_01-Varna_over.jpg");
		map_01_Sofia_oblast_over = newImage("App_Themes/images/map_01-Sofia-oblast_over.jpg");
		preloadFlag = true;
	}
}

function CalculateResolution()
{
    document.getElementById('screenWidth').value = window.screen.width;
    document.getElementById('screenHeight').value = window.screen.height;        
}

/*
* Summury: Функция за проверка на процента кирилица в текста на нова обява.
*          При наличие на текст по дълъг от 20 символа, при кирилица под 50%, 
*          извежда съобщение.
* Developer: Марио Ангелов
*/
function countLatin(txtAreaId, messageObjId, messageText)
{
    var txtArea = document.getElementById(txtAreaId);
	var messageObj = document.getElementById(messageObjId);		    
	var latinCounter = 0;

	for (i=0; i < txtArea.value.length; i++)
	{                
	    if(((txtArea.value.charCodeAt(i) >= 65) && (txtArea.value.charCodeAt(i) <= 90)) || 
		((txtArea.value.charCodeAt(i) >= 97) && (txtArea.value.charCodeAt(i) <= 122)))
		{				
		    latinCounter++;
	    }				
    }			

	if((txtArea.value.length / 2) < latinCounter  && txtArea.value.length > 20)
	{				
	    messageObj.innerText = messageText;
    }
	else
	{
	    messageObj.innerText = '';
    }

}

/*
* Summury: Функция за показване на Flash банери чрез която се избягва "Click to activate" 
* проблема.
*/
function ShowFlashBanner(bannerPath, width, height)
{        
     document.write('<object type="application/x-shockwave-flash" data=' + bannerPath + ' width="' + width + '" height="' + height + '"><param name="wmode" value="opaque" /><param name="allowscriptaccess" value="samedomain"><param name="movie" value="' + bannerPath + '" /><param name="quality" value="high" /><embed src="' + bannerPath + '" width="' + width + '" height="' + height + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" swliveconnect="true" allowscriptaccess="samedomain" wmode="opaque"></embed></object>');
}



/*
 * Summury: Изчислява резолюцията на клиентския браузър.
 */
function getScreenResolution(screenWidth, screenHeight)
{            
    screenWidth.value = window.screen.width;
    screenWidth.value = window.screen.height;
}
