
$(document).ready(function() {  
    $('a.galleryfile').fancybox({
        overlayShow: true,
        overlayOpacity: 0.5,
        zoomSpeedIn: 1500,
        zoomSpeedOut:600,
        showNavArrows:true,
        showCloseButton:true
    });             

});

function main(){
    player = new Player();
    player.play();
    
}

function resizeContent(){
   
    var pageHeight = document.body.scrollHeight;
    var winHeight=self.innerHeight ? self.innerHeight : document.body.clientHeight;
    //alert(winHeight);
    //var contentHeight = pageHeight - 430;
    var contentHeight = winHeight - 100;
    if(document.getElementById('content'))
        document.getElementById('content').style.minHeight = contentHeight + "px";
    if(document.getElementById('scroll-wrap'))
        document.getElementById('scroll-wrap').style.height =  contentHeight + "px";
    if(document.getElementById('scroll-pane'))
        document.getElementById('scroll-pane').style.height =  contentHeight + "px";
}


function selectNews(url, period){
    document.location.href=url+period+"/";
}


function changeMainMenuStyle(id){

}


function revertMainMenuStyle(id){

    
}

function showMenu(id){
    if(document.getElementById('menu_'+id))
        document.getElementById('menu_'+id).style.visibility = 'visible';
}

function hideMenu(id){
    if(document.getElementById('menu_'+id))
        document.getElementById('menu_'+id).style.visibility = 'hidden';
}
    

function loadMovie(movie) {

    var so = new SWFObject('/images/flv/player.swf','player','518','348','8');
    so.addParam('flashvars', 'config=/images/flv/config.xml&autostart=true&file=' + movie);
    so.addParam('allowfullscreen','true');
    if (document.getElementById('videoplayer'))
        so.write('videoplayer');
}

function formatMonth(month){
    if(month<10) month='0'+month;
    return month;
}

function changeRedMenuStyle(id){
    document.getElementById('topmenuitem_'+id).className = 'topmenuitem_a';
    document.getElementById('topmenuitem_left_'+id).className = 'topmenuitem_left_a';
    document.getElementById('topmenuitem_right_'+id).className = 'topmenuitem_right_a';
}
function revertRedMenuStyle(id){
    document.getElementById('topmenuitem_'+id).className = 'topmenuitem';
    document.getElementById('topmenuitem_left_'+id).className = 'topmenuitem_left';
    document.getElementById('topmenuitem_right_'+id).className = 'topmenuitem_right';
}

function inArray(val,arr){
    for (var i=0; i < arr.length; i++) {
        if (arr[i] == val) {
            return true;
        }
    }
    return false;
}

function navigate(formname,idx){
    if(idx!=0)
        document.location.href=document.getElementById(formname).options[idx].value;
}

var tabs = Array ('news','announces','publications');

function getTabIndex(id){
    for(var i = 0; i < tabs.length; i++)
        if(tabs[i]==id)
            return i;
    return false;
}

function hideAllTabs(){
    for(var i = 0; i <tabs.length; i++){
        document.getElementById(tabs[i]).style.display = 'none';
        
        var tabIndex = getTabIndex(tabs[i]);
        if(tabIndex == 0)
            document.getElementById(tabs[i]+'tab').className = 'lefttab';
        else if (tabIndex == tabs.length - 1)
            document.getElementById(tabs[i]+'tab').className = 'righttab';
        else
            document.getElementById(tabs[i]+'tab').className = 'tab';
    }
}

function switchTab(id){
    hideAllTabs();
    document.getElementById(id).style.display = 'block';

    var tabIndex = getTabIndex(id);
    if(tabIndex == 0)
        document.getElementById(id+'tab').className = 'lefttab_a';
    else if (tabIndex == tabs.length - 1)
        document.getElementById(id+'tab').className = 'righttab_a';
    else
        document.getElementById(id+'tab').className = 'tab_a';
}

function ChangeGalleryPic(imgName,imgFile, title){

    document.images[imgName].src = imgFile;
    document.getElementById(imgName + 'link').href = imgFile;
    document.getElementById(imgName + 'link').title = title;
    document.images[imgName].alt=title;
    document.images[imgName].title=title;
//alert(title);

}

var step = 1;
var delay = 10;

var scrollAreaCount = 1;
var containers = new Array(scrollAreaCount);
var contents = new Array(scrollAreaCount);

var contentWidth;
var contentHeight;
var initialPosition = new Array(scrollAreaCount);

var timeOut;

function moveleft(container, content, ind){
    defineObjects(container, content, ind);
    if(parseInt(contents[ind].style.left) >(contentWidth - parseInt(containers[ind].style.width)) * -1){
        contents[ind].style.left=parseInt(contents[ind].style.left) - step + "px";
        timeOut=setTimeout("moveleft('"+container+"', '"+content+"', "+ind+")", delay);
    }
}

function moveright(container, content, ind){
    //alert("right");
    defineObjects(container, content, ind);
    if (parseInt(contents[ind].style.left) < initialPosition[ind]){
        contents[ind].style.left=parseInt(contents[ind].style.left) + step + "px";
        timeOut=setTimeout("moveright('"+container+"', '"+content+"', "+ind+")", delay);
    }
}
function moveup(container, content, ind){
    defineObjectsVert(container, content, ind);
    if(parseInt(contents[ind].style.top) > (contentHeight - parseInt(containers[ind].style.height)) * -1){
        contents[ind].style.top=parseInt(contents[ind].style.top) - step + "px";
        timeOut=setTimeout("moveup('"+container+"', '"+content+"', "+ind+")", delay);
    }
}

function movedown(container, content, ind){
    defineObjectsVert(container, content, ind);
    if (parseInt(contents[ind].style.top) < initialPosition[ind]){
        contents[ind].style.top=parseInt(contents[ind].style.top) + step + "px";
        timeOut=setTimeout("movedown('"+container+"', '"+content+"', "+ind+")", delay);
    }
}

function defineObjects(container, content, ind){
    containers[ind] = document.getElementById(container);
    contents[ind] = document.getElementById(content);
    if(document.getElementById("fpscontenttable")){
        contentWidth = document.getElementById("fpscontenttable").offsetWidth;
        contentHeight = document.getElementById("fpscontenttable").offsetHeight;
    }

    //contentWidth = 400;
    //alert(contentWidth);
    if(!initialPosition[ind])
        initialPosition[ind] = parseInt(contents[ind].style.left);
}
function defineObjectsVert(container, content, ind){
    containers[ind] = document.getElementById(container);
    contents[ind] = document.getElementById(content);

    if(document.getElementById("pcontenttable")){
        contentWidth = document.getElementById("pcontenttable").offsetWidth;
        contentHeight = document.getElementById("pcontenttable").offsetHeight;
    }
    //contentWidth = 400;
    //alert(contentWidth);
    if(!initialPosition[ind])
        initialPosition[ind] = parseInt(contents[ind].style.top);
}

function setPriceValue(model_id){   
    for (i=0;i<models.length;i++)
    {   
        if (models[i][0] == model_id){            
            document.getElementById('model_price').value = models[i][1];
        }
    }
}

