var isScroll = false;
function StartScroll(isDown, ControlUp, ControlDown, divContainer, divScroll)
{
	isScroll = true;
	ScrollContent(isDown, ControlUp, ControlDown, divContainer, divScroll);
}

function ScrollContent(isDown, ControlUp, ControlDown, divContainer, divScroll)
{
	elUp = document.getElementById(ControlUp);
	elDown = document.getElementById(ControlDown);
	elContainer = document.getElementById(divContainer);
	elScroll = document.getElementById(divScroll);
	
	
	CanGo = true;
	
	if (isDown)
	{
		if (parseInt(elScroll.style.top) == 0)  
		{	
			CanGo = false;
		}
	}
	else
	{
		if (elScroll.offsetHeight + parseInt(elScroll.style.top) < elContainer.offsetHeight)
		{
			CanGo = false;
		}
	}
	
	
	
	if (isScroll && CanGo)
	{
		if (isDown)
		{
			elScroll.style.top = parseInt(elScroll.style.top) + 3;	
		}
		else
		{	
			elScroll.style.top = parseInt(elScroll.style.top) - 3;	
		}
		setTimeout("ScrollContent(" + isDown + ", '" + elUp.id + "','" + elDown.id + "', '" + elContainer.id + "','" + elScroll.id + "')", 50);
	}
	
}

function MouseOut()
{
	isScroll = false;
}


function StartScrollH(isLeft, ControlUp, ControlDown, divContainer, divScroll)
{
	isScroll = true;
	ScrollContentH(isLeft, ControlUp, ControlDown, divContainer, divScroll);
}

function ScrollContentH(isLeft, ControlUp, ControlDown, divContainer, divScroll)
{
	elUp = document.getElementById(ControlUp);
	elDown = document.getElementById(ControlDown);
	elContainer = document.getElementById(divContainer);
	elScroll = document.getElementById(divScroll);
	
	CanGo = true;
	
	if (isLeft)
	{
		if (parseInt(elScroll.style.left) == 0)  
		{	
			CanGo = false;
		}
	}
	else
	{
		if (elScroll.offsetWidth + parseInt(elScroll.style.left) < elContainer.offsetWidth)
		{
			CanGo = false;
		}
	}
	
	
	
	if (isScroll && CanGo)
	{
		if (isLeft)
		{
			elScroll.style.left = parseInt(elScroll.style.left) + 2;	
		}
		else
		{	
			elScroll.style.left = parseInt(elScroll.style.left) - 2;	
		}
		
		setTimeout("ScrollContentH(" + isLeft + ", '" + elUp.id + "','" + elDown.id + "', '" + elContainer.id + "','" + elScroll.id + "')", 25);
	}
	
}




function CreateFlashObject(LangID, FilePath, Width, Height, ClassName)
{
   
    document.write("<object " + (ClassName != "" ? "class='" + ClassName + "'" : "") + " classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='" + Width + "' height='" + Height + "' align='middle'>");
    document.write("<param name='allowScriptAccess' value='sameDomain'>");
    if (LangID != "")   document.write("<param name='flashvars' value='LangID=" + LangID + "'>"); 
    document.write("<param name='wmode' value='transparent'>");
    document.write("<param name='movie' value='" + FilePath + "'>");
    document.write("<param name='quality' value='high'>");
    document.write("<embed src='" + FilePath + "' quality='high' flashvars='LangID=" + LangID + "' width='" + Width + "' height='" + Height + "' align='middle' wmode='transparent' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
    document.write("</object>");

}

function CreateFlashObject2(FlashVars, FilePath, Width, Height, ClassName)
{
   
    document.write("<object " + (ClassName != "" ? "class='" + ClassName + "'" : "") + " classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='" + Width + "' height='" + Height + "' align='middle'>");
    document.write("<param name='allowScriptAccess' value='sameDomain'>");
    document.write("<param name='flashvars' value='" + FlashVars + "'>"); 
    document.write("<param name='wmode' value='transparent'>");
    document.write("<param name='movie' value='" + FilePath + "'>");
    document.write("<param name='quality' value='high'>");
    document.write("<embed src='" + FilePath + "' quality='high' flashvars='" + FlashVars + "' width='" + Width + "' height='" + Height + "' align='middle' wmode='transparent' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
    document.write("</object>");

}

function CreateFlashObjectForIndex()
{
   
 document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='460' height='210' id='banner_index' align='middle'>" +
                        "<param name='movie' value='resources/banners/banner_index.swf' />" +
                        "<param name='quality' value='high' />" +
                        "<param name='bgcolor' value='#000000' />" +
                        "<embed src='resources/banners/banner_index.swf' quality='high' bgcolor='#000000' width='460' height='210' name='banner_index' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>");

}

function ClearElements()
{
    var i = 0;
    for (i = 0; i < arguments.length; i++)
    {
        var el = document.getElementById(arguments[i]);
        el.value = "";
    }
}
		
		
function Trim(str)
{
    var s = new String(str);
    var reg = new RegExp("[ ]+", "g");
    return s.replace(reg, "");
}

function ShowErrorMessage(elError, msgError)
{
    elError.style.visibility = "visible";
    elError.innerText = msgError;
}

function Trim(str)
{
    return str.replace(/^\s*|\s*$/g,"");
}



// functions for moving blocks

function GetElementX(ElementID)
{
    var el = document.getElementById(ElementID);
    var posX = el.offsetLeft;
    while (el.tagName != "BODY")
    {
        el = el.offsetParent;
        posX += el.offsetLeft;
    }
    return posX;
}

function GetElementY(ElementID)
{
    var el = document.getElementById(ElementID);
    var posY = el.offsetTop;
    while (el.tagName != "BODY")
    {
        el = el.offsetParent;
        posY += el.offsetTop;
    }
    return posY;
}


var MouseInBlock = false;
var BlockElemementID = "";
var StartPosOfBlock = -5;
var EndPosOfBlock = 120;

		
function HideBlock(e)
{
    var targ;
    if (!e) var e = window.event;
    
    var posx = 0;
    var posy = 0;
    if (e.pageX || e.pageY) 	
    {
        posx = e.pageX;
        posy = e.pageY;
    }
    else if (e.clientX || e.clientY) 	
    {
        posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
        posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
    }
    
    var el = document.getElementById(BlockElemementID);
    
    
    var elWidth = new String(el.style.width);
    elWidth = Math.round(elWidth.substring(0, elWidth.length - 2));
    var elHeight = new String(el.style.height);
    elHeight = Math.round(elHeight.substring(0, elHeight.length - 2));
    var elTop = GetElementY(el.id);
    var elLeft = GetElementX(el.id);

    var TuchBorder = 10;

    if (!(posx > elLeft + TuchBorder && posx < (elLeft + elWidth - TuchBorder) && posy > elTop + TuchBorder && posy < elTop + elHeight - TuchBorder))
    {
        MouseInBlock = false;
        MoveBlock(false); 
    }
} 

function ShowBlock()
{
    MouseInBlock = true;
    MoveBlock(true);
}

function MoveBlock(MoveRight)
{
    var el = document.getElementById(BlockElemementID);
    var left = new String(el.style.left);
    left = left.substring(0, left.length - 2);
    left = Math.round(left);
    
    if (MoveRight)
    {
        if (left < StartPosOfBlock)
        {
            left = left + 10;
            el.style.left = left;
        }
        else
        {
            el.style.left = StartPosOfBlock;
        }
        
        if (MouseInBlock && left < StartPosOfBlock)
        {
            setTimeout('MoveBlock(true)',50); 
        }
    }
    else
    {
        if (left > -EndPosOfBlock)
        {
            left = left - 10;
            el.style.left = left;
        }

       
        if (!MouseInBlock && left > -EndPosOfBlock)
        {
           setTimeout('MoveBlock(false)',50);  
        }  
    }
}

function FindElementWithTag(ElementID, TagName)
{
    var arr = document.getElementsByTagName(TagName);
    for (i = 0; i < arr.length; i++)
    {
        if (arr[i].id.indexOf('_' + ElementID) > -1)
        {
            return arr[i];
        }
    }
    return null;
}

function CreateMediaFlash(isMain)
{
    if (isMain)
    {
        document.write("<object width='425' height='344'><param name='movie' value='http://www.youtube.com/v/bYsb5uyt-lE&hl=en&fs=1&amp;ap=%2526fmt%3D18'></param><param name='allowFullScreen' value='true'></param><embed src='http://www.youtube.com/v/bYsb5uyt-lE&hl=en&fs=1&ap=%2526fmt%3D18' type='application/x-shockwave-flash' allowfullscreen='true' width='425' height='344'></embed></object>");
    }
    else
    {
        document.write("<object width='425' height='344'><param name='movie' value='http://www.youtube.com/v/Xpp_IYCbe0k&hl=en&fs=1&rel=0'></param><param name='allowFullScreen' value='true'></param><embed src='http://www.youtube.com/v/Xpp_IYCbe0k&hl=en&fs=1&rel=0' type='application/x-shockwave-flash' allowfullscreen='true' width='425' height='344'></embed></object>");
    }
   
}

