
$(function () {
    $(document).ready(function () {

        $("#next").click(function () {

            var loop = 0;
            for (loop = 0; loop <= arrPR.length - 3; loop++) {
                if (loop == arrPR.length - 4)
                    $("#next").css('color', 'Gray');

                if ($('#pressRelease' + (loop + 1)).css('display') == 'block') {

                    $('#pressRelease' + (loop + 1)).css('display', 'none');
                    $('#pressRelease' + (loop + 2)).css('display', 'none');
                    $('#pressRelease' + (loop + 3)).css('display', 'block');
                    $('#pressRelease' + (loop + 4)).css('display', 'block');
                    $("#previous").css('color', 'Red');
                    break;
                }

            }
        });
        $("#previous").click(function () {
            var loop = 3;
            for (loop = 3; loop <= arrPR.length; loop++) {
                if ($('#pressRelease' + loop).css('display') == 'block') {
                    if (loop == 3)
                        $("#previous").css('color', 'Gray');
                    if (loop % 2 == 1 && loop == arrPR.length) {
                        $('#pressRelease' + loop).css('display', 'none');
                        //$('#pressRelease' + (loop + 2)).css('display', 'none');
                        $('#pressRelease' + (loop - 1)).css('display', 'block');
                        $('#pressRelease' + (loop - 2)).css('display', 'block');
                        $("#next").css('color', 'Red');
                        break;
                    } else {
                        $('#pressRelease' + loop).css('display', 'none');
                        $('#pressRelease' + (loop + 1)).css('display', 'none');
                        $('#pressRelease' + (loop - 1)).css('display', 'block');
                        $('#pressRelease' + (loop - 2)).css('display', 'block');
                        $("#next").css('color', 'Red');
                        break;
                    }
                }
            }
        });


    });

});
//=================================================================
var arrPR = new Array(
//add new press releases
//{ Event: { texth8: '', PessReleaseDate: '', PressReleaseContent: '', readmore: ''} },
{PressRelease: { PressReleaseTitle: 'ProDX, a Leading IT and Software Staffing Company... ', PessReleaseDate: 'Beaverton, Ore. (PRWEB) November 17, 2011', PressReleaseContent: '"Last year alone, we placed more than 125 qualified IT professionals and software engineers at clients throughout...', readmore: 'http://www.prweb.com/releases/2011/11/prweb8961458.htm'} },
{ PressRelease: { PressReleaseTitle: 'Join Agilis Solutions at the All About Mobile Conference...', PessReleaseDate: 'Beaverton, Ore.-November 10, 2011 ', PressReleaseContent: 'Agilis Solutions President Eileen Boerger will join the All About Mobile industry panel, "Transitioning Your Existing Solutions to...', readmore: 'http://www.prweb.com/releases/2011/11/prweb8941832.htm'} },
{ PressRelease: { PressReleaseTitle: 'Agilis Solutions President Joins Cloud Channel...', PessReleaseDate: 'Beaverton, Ore.-November 04, 2011', PressReleaseContent: 'Agilis Solutions President Eileen Boerger will join Cloud industry leaders on the executive roundtable panel...', readmore: 'http://www.prweb.com/releases/2011/11/prweb8933678.htm'} },
{ PressRelease: { PressReleaseTitle: 'Cloud Computing and Software Development Expert Eileen Boerger...', PessReleaseDate: 'Beaverton, Ore.-November 01, 2011', PressReleaseContent: 'Agilis Solutions President Eileen Boerger, a featured thought leader and industry expert in SafeNet\'s ....', readmore: 'http://www.prweb.com/releases/2011cloud-computing/10software-development/prweb8917877.htm'} },
{ PressRelease: { PressReleaseTitle: 'America\'s Agilis Solutions and Vietnam\'s FPT Software...', PessReleaseDate: 'Beaverton, Ore.-September 22, 2011', PressReleaseContent: '"We were among the first to work with FPT, virtually getting the best-of-the-best in a market no one had really yet discovered.".... ', readmore: 'http://corsource.net/PressReleasedoc\\Agilis.FPTpartnership.pdf'} },
{ PressRelease: { PressReleaseTitle: 'Mark Shia Honored as "CFO of the Year" Finalist', PessReleaseDate: 'Beaverton, Ore.-May 6, 2011', PressReleaseContent: 'CorSource Technology Group, Inc., parent company of Agilis Solutions and ProDX, announces that Chief Financial...', readmore: 'http://corsource.net/PressReleasedoc\\MarkShiaNR.pdf'} },
{ PressRelease: { PressReleaseTitle: 'Agilis Solutions Software Development Experts Move Companies...', PessReleaseDate: 'Beaverton, Ore.-April 7, 2011', PressReleaseContent: 'Agilis Solutions, a leading provider of software product development services, today announced its Expert Consulting Services...', readmore: 'http://corsource.net/PressReleasedoc\\4.7.11Agilis ServicesNR.pdf'} },
{ PressRelease: { PressReleaseTitle: 'Agilis Solutions Launches Ask Eileen!', PessReleaseDate: 'Beaverton, Ore.-June 18, 2010', PressReleaseContent: 'Agilis Solutions, a leading provider of custom software application services and software development outsourcing ...', readmore: 'http://corsource.net/PressReleasedoc\\6.18.10Ask Eileen! NR.pdf'} },
{ PressRelease: { PressReleaseTitle: 'Agilis Solutions Announces Bay Area Expansion', PessReleaseDate: 'Beaverton, Ore.-March 26, 2010', PressReleaseContent: 'Agilis Solutions, a leading Oregon-based provider of software product development services and outsourcing pioneer to Vietnam, today announced it...', readmore: 'http://corsource.net/PressReleasedoc\\3.26.10Agilis Solutions Bay Area NR.pdf'} }
);


function CreatePressRelease() {
    var pr = 0;
    for (pr = 0; pr < arrPR.length; pr++) {
        var newdiv = document.createElement('div');
        var divID = 'pressRelease' + (pr + 1);

        newdiv.setAttribute('id', divID);
        newdiv.className = 'PressRl';
        var newdiv2 = document.createElement('div');
        newdiv2.className = 'PressReleaseTitle';
        newdiv2.innerHTML = arrPR[pr].PressRelease.PressReleaseTitle;
        var newdiv3 = document.createElement('div');
        newdiv3.className = 'PessReleaseDate';
        newdiv3.innerHTML = arrPR[pr].PressRelease.PessReleaseDate;
        var newdiv4 = document.createElement('div');
        newdiv4.className = 'PressReleaseContent';
        newdiv4.innerHTML = arrPR[pr].PressRelease.PressReleaseContent;
        var newa = document.createElement('a');
        newa.className = 'readmore';
        newa.href = arrPR[pr].PressRelease.readmore;
        newa.target = '_blank';
        newa.innerHTML = 'Read more...';

        newdiv.appendChild(newdiv2);
        newdiv.appendChild(newdiv3);
        newdiv.appendChild(newdiv4);
        newdiv.appendChild(newa);
        if (pr % 2 == 0) {
            newdiv.className = 'PressRl pressReaseOnTop';
        }
        var PressReleaseArea = document.getElementById('PressReleaseArea')
        PressReleaseArea.appendChild(newdiv);

    }
    setDisplay();

}
function setDisplay() {
    var pr = 3;
    $('#pressRelease1').css('display', 'block');
    $('#pressRelease2').css('display', 'block');
    for (pr = 3; pr <= arrPR.length; pr++) {
        $('#pressRelease' + pr).css('display', 'none');
    }
}
//==========================================================


var arrVideo = new Array(
//add new video
//{ Event: { linkImage: '', strongTitle: '', inputLinkVideo: ''} },
{ Video: { linkImage: 'http://img.youtube.com/vi/ff70hSXKTLI/1.jpg', strongTitle: 'SIIA\'s Mobile Trends Interview', inputLinkVideo: 'http://www.youtube.com/embed/ff70hSXKTLI'} },
{ Video: { linkImage: 'http://img.youtube.com/vi/Vsbl3bvwpyE/1.jpg', strongTitle: 'SafeNet\'s Moving to the Cloud Interview', inputLinkVideo: 'http://www.youtube.com/embed/Vsbl3bvwpyE'} },
{ Video: { linkImage: 'http://img.youtube.com/vi/iBPlhp1lyB4/1.jpg', strongTitle: 'Keys to  a Successful Migration to the Cloud', inputLinkVideo: 'http://www.youtube.com/embed/iBPlhp1lyB4'} },
{ Video: { linkImage: 'http://corsource.net/images/video4.png', strongTitle: 'Cloud Channel Summit 2011 Interview', inputLinkVideo: 'http://cloudchannelsummit.dreamsimplicity.com/player/BgRk'} }
);

// Create list videos
function createVideoItem() {
    var news_topright = document.getElementById('news_topright');
    news_topright.innerHTML = arrVideo[0].Video.strongTitle;
    var iframeID = document.getElementById('iframeID');
    iframeID.src = arrVideo[0].Video.inputLinkVideo + '?rel=0';
    var videoloop = 0;
    for (videoloop = 0; videoloop < arrVideo.length; videoloop++) {
        var newli = document.createElement('li');
        if (videoloop == 0) {
            newli.className = 'news_item news_item_active';
        } else {
            newli.className = 'news_item';
        }
        var newspan = document.createElement('span');
        newspan.className = 'alignleft';
        var newImage = document.createElement('img');
        newImage.className = 'attachment-size_90x71';
        newImage.src = arrVideo[videoloop].Video.linkImage;
        newspan.appendChild(newImage);
        var newdiv = document.createElement('div');
        newdiv.className = 'text';
        var newstrong = document.createElement('strong');
        newstrong.innerHTML = arrVideo[videoloop].Video.strongTitle;
        newdiv.appendChild(newstrong);
        var newinput = document.createElement('input');
        newinput.type = 'hidden';
        newinput.value = arrVideo[videoloop].Video.inputLinkVideo;

        newli.appendChild(newspan);
        newli.appendChild(newdiv);
        newli.appendChild(newinput);

        var ulVideo = document.getElementById('ulvideo')
        ulVideo.appendChild(newli);
    }


    hideFormText();
    initButtons();
    initCustomFile();
    initGallery();

    $(".news_item").click(function (e) {
        $(".news_item").removeClass("news_item_active");
        $(this).addClass("news_item_active");
        var item = $(this).children('input').attr('value');
        var video = $('iframe').attr('src');
        video = item + '?rel=0';
        $('iframe').attr('src', video);
        var title = $(this).children('.text').children('strong').html();
        $(".news_topright").html(title);
    });

}
