$(document).ready(function() {
    ////////////////////*cookies*//////////////////////////////////////////

    ///Check region and adjust top right region changer
    function checkRegion() {
        switch ($.cookie('tippmann')) {
            case "1":
                $('ul#topnav li#region').css('background-color', '#B00027');
                $('.american2').css('visibility', 'visible');
                $('li#region p').text('USA');
                americafyeah();
                setHPFlashAmerica();
                break;
            case "3":
                $('ul#topnav li#region').css('background-color', '#38b82e');
                $('.foreign').css('visibility', 'visible');
                $('.foreign2').css('display', 'block');
                $('li#region p').text('Canada');
                canada();
                setHPFlashCanada();
                break;
            case "4":
                $('ul#topnav li#region').css('background-color', '#be4914');
                $('.foreign').css('visibility', 'visible');
                $('.foreign2').css('display', 'block');
                $('li#region p').text('Latin America');
                setHPFlashLatin();
                break;
            case "2":
                $('ul#topnav li#region').css('background-color', '#1d6bb1');
                $('.foreign').css('visibility', 'visible');
                $('.foreign2').css('display', 'block');
                $('.emea').css('display', 'block');
                $('li#region p').text('EMEA');
                setHPFlashEMEA();
                break;
            case "5":
                $('ul#topnav li#region').css('background-color', '#5E3AD2');
                $('.foreign').css('visibility', 'visible');
                $('.foreign2').css('display', 'block');
                $('li#region p').text('Asia Pacific');
                setHPFlashAsia();
                break;
        }
    }
    checkRegion();

    /*Show the best stuff, The AMERICAN stuff*/
    function americafyeah() {
        //redirect to mobile
        (function(a,b){if(/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))window.location=b})(navigator.userAgent||navigator.vendor||window.opera,'http:\/\/tippmann.mviso.com');


        $('.american').css('display', 'block');
        $('.americana').children('a').text('Where To Buy');
        $('a.regchanger').text('U.S. Army');
        $('a.regchanger').attr('href', 'http://www.tippmann.com/catalogs/usarmy/index.html');

    };
    function canada() {
        $('div#ctl00_Content_pnlMainContent div.canada').css('display', 'block');
        $('.americana').children('a').text('Where To Buy');
    };



    ///open overlay
    function setRegion() {
        $('div#overlay').fadeIn('fast');
        $('div#regionselect').fadeIn('slow');
    };

    ///close overlay
    function closeRegion() {
        $('div#overlay').fadeOut('slow');
        $('div#regionselect').fadeOut('fast');
    };
    ///No cookie, make one!
    if ($.cookie('tippmann') == null) {
        setRegion();
    };

    ///setting cookie on region click for overlay
    $('div#regionselect div.usa').click(function() {
        $.cookie('tippmann', null);
        $.cookie('tippmann', '1', { expires: 90 });
        $('li#region p').text('USA');
        closeRegion();
        $('ul#topnav li#region').css('background-color', '#B00027');
        //window.location.reload(true);
        var str = window.location.href.toLowerCase();
        str = str.replace('emea', 'usa');
        str = str.replace('canada', 'usa');
        str = str.replace('asia', 'usa');
        str = str.replace('latinamerica', 'usa');
        window.location.replace(str);
        window.location.reload(true);
    });
    $('div#regionselect div.canada').click(function() {
        $.cookie('tippmann', null);
        $.cookie('tippmann', '3', { expires: 90 });
        $('li#region p').text('Canada');
        closeRegion();
        $('ul#topnav li#region').css('background-color', '#38b82e');
        //window.location.reload(true);
        var str = window.location.href.toLowerCase();
        str = str.replace('emea', 'canada');
        str = str.replace('usa', 'canada');
        str = str.replace('asia', 'canada');
        str = str.replace('latinamerica', 'canada');
        window.location.replace(str);
        window.location.reload(true);
    });
    $('div#regionselect div.latin').click(function() {
        $.cookie('tippmann', null);
        $.cookie('tippmann', '4', { expires: 90 });
        $('li#region p').text('Latin America');
        closeRegion();
        $('ul#topnav li#region').css('background-color', '#be4914');
        //window.location.reload(true);
        var str = window.location.href.toLowerCase();
        str = str.replace('emea', 'latinamerica');
        str = str.replace('usa', 'latinamerica');
        str = str.replace('asia', 'latinamerica');
        str = str.replace('canada', 'latinamerica');
        window.location.replace(str);
        window.location.reload(true);
    });
    $('div#regionselect div.emea').click(function() {
        $.cookie('tippmann', null);
        $.cookie('tippmann', '2', { expires: 90 });
        $('li#region p').text('EMEA');
        closeRegion();
        $('ul#topnav li#region').css('background-color', '#1d6bb1');
        //window.location.reload(true);
        var str = window.location.href.toLowerCase();
        str = str.replace('latinamerica', 'emea');
        str = str.replace('usa', 'emea');
        str = str.replace('asia', 'emea');
        str = str.replace('canada', 'emea');
        window.location.replace(str);
        window.location.reload(true);
    });
    $('div#regionselect div.asia').click(function() {
        $.cookie('tippmann', null);
        $.cookie('tippmann', '5', { expires: 90 });
        $('li#region p').text('Asia');
        closeRegion();
        $('ul#topnav li#region').css('background-color', '#5E3AD2');
        //window.location.reload(true);
        var str = window.location.href.toLowerCase();
        str = str.replace('latinamerica', 'asia');
        str = str.replace('usa', 'asia');
        str = str.replace('emea', 'asia');
        str = str.replace('canada', 'asia');
        window.location.replace(str);
        window.location.reload(true);
    });

    /*region changing*/
    var $reg;

    $('li#region').click(function() {
        $('ul#regchange').slideToggle('fast');
    });
    $('ul#regchange li').click(function() {
        $reg = $(this).children('a').text();
        regionColor();
    });
    function regionColor() {
        switch ($reg) {
            case "USA":
                $('ul#topnav li#region').css('background-color', '#B00027');
                $('li#region p').text('USA');
                $.cookie('tippmann', null);
                $.cookie('tippmann', '1', { expires: 90 });
                var str = window.location.href.toLowerCase();
                str = str.replace('emea', 'usa');
                str = str.replace('canada', 'usa');
                str = str.replace('asia', 'usa');
                str = str.replace('latinamerica', 'usa');
                window.location.replace(str);
                window.location.reload(true);
                break;
            case "Canada":
                $('ul#topnav li#region').css('background-color', '#38b82e');
                $('li#region p').text('Canada');
                $.cookie('tippmann', null);
                $.cookie('tippmann', '3', { expires: 90 });
                //window.location.reload(true);
                var str = window.location.href.toLowerCase();
                str = str.replace('emea', 'canada');
                str = str.replace('usa', 'canada');
                str = str.replace('asia', 'canada');
                str = str.replace('latinamerica', 'canada');
                window.location.replace(str);
                window.location.reload(true);
                break;
            case "Latin America":
                $('ul#topnav li#region').css('background-color', '#be4914');
                $('li#region p').text('Latin America');
                $.cookie('tippmann', null);
                $.cookie('tippmann', '4', { expires: 90 });
                //window.location.reload(true);
                var str = window.location.href.toLowerCase();
                str = str.replace('emea', 'latinamerica');
                str = str.replace('usa', 'latinamerica');
                str = str.replace('asia', 'latinamerica');
                str = str.replace('canada', 'latinamerica');
                window.location.replace(str);
                window.location.reload(true);
                break;
            case "EMEA":
                $('ul#topnav li#region').css('background-color', '#1d6bb1');
                $('li#region p').text('EMEA');
                $.cookie('tippmann', null);
                $.cookie('tippmann', '2', { expires: 90 });
                //window.location.reload(true);
                var str = window.location.href.toLowerCase();
                str = str.replace('latinamerica', 'emea');
                str = str.replace('usa', 'emea');
                str = str.replace('asia', 'emea');
                str = str.replace('canada', 'emea');
                window.location.replace(str);
                window.location.reload(true);
                break;
            case "Asia Pacific":
                $('ul#topnav li#region').css('background-color', '#5E3AD2');
                $('li#region p').text('Asia Pacific');
                $.cookie('tippmann', null);
                $.cookie('tippmann', '5', { expires: 90 });
                //window.location.reload(true);
                var str = window.location.href.toLowerCase();
                str = str.replace('latinamerica', 'asia');
                str = str.replace('usa', 'asia');
                str = str.replace('emea', 'asia');
                str = str.replace('canada', 'asia');
                window.location.replace(str);
                window.location.reload(true);
                break;
        }
    }
    $('li#usareg').hover(
		function() {
		    $('li#usareg').css({
		        'border-left': '10px solid #b00027',
		        'padding-left': '7px',
		        'background-position': '220px 12px'
		    });
		}, function() {
		    $('li#usareg').css({
		        'border-left': '0px none',
		        'padding-left': '17px',
		        'background-position': '230px 12px'
		    });
		}
	);
    $('li#canadareg').hover(
		function() {
		    $('li#canadareg').css({
		        'border-left': '10px solid #38b82e',
		        'padding-left': '7px',
		        'background-position': '220px 12px'
		    });
		}, function() {
		    $('li#canadareg').css({
		        'border-left': '0px none',
		        'padding-left': '17px',
		        'background-position': '230px 12px'
		    });
		}
	);
    $('li#latinreg').hover(
		function() {
		    $('li#latinreg').css({
		        'border-left': '10px solid #be4914',
		        'padding-left': '7px',
		        'background-position': '220px 12px'
		    });
		}, function() {
		    $('li#latinreg').css({
		        'border-left': '0px none',
		        'padding-left': '17px',
		        'background-position': '230px 12px'
		    });
		}
	);
    $('li#emeareg').hover(
		function() {
		    $('li#emeareg').css({
		        'border-left': '10px solid #1d6bb1',
		        'padding-left': '7px',
		        'background-position': '96px 12px'
		    });
		}, function() {
		    $('li#emeareg').css({
		        'border-left': '0px none',
		        'padding-left': '17px',
		        'background-position': '106px 12px'
		    });
		}
	);
    $('li#asiareg').hover(
		function() {
		    $('li#asiareg').css({
		        'border-left': '10px solid #5e3ad2',
		        'padding-left': '7px',
		        'background-position': '220px 12px'
		    });
		}, function() {
		    $('li#asiareg').css({
		        'border-left': '0px none',
		        'padding-left': '17px',
		        'background-position': '230px 12px'
		    });
		}
	);
    $('ul#midnav li').hover(
		function() {
		    $(this).children('a').css('color', '#c00319');
		}, function() {
		    $(this).children('a').css('color', '#fff');
		}
	);

    //////////////* END COOKIES NOM NOM *///////////////

    /*nav drops*/
    var config = {
        over: function() {
            $(this).children('ul.drop').slideDown('fast');
        },
        timeout: 300,
        out: function() {
            $(this).children('ul.drop').slideUp('fast');
        }
    };

    $('.drop').each(function() {
        $(this).parent().eq(0).hoverIntent(config);
    });


    /*home callout full clickability*/
    $('div.homesection').click(
	    function() {
	        $homelink = $(this).find('a').attr('href');
	        window.location = $homelink;
	    }
	);
    $('div.homesection').hover(
	    function() {
	        $(this).css({
	            'background-color': '#222',
	            'cursor': 'pointer'
	        });
	    }, function() {
	        $(this).css({
	            'background-color': 'transparent',
	            'cursor': 'default'
	        });
	    }
	);






    /*download section*/
    $('div.companyselect h2').click(function() {
        $(this).next().slideToggle('fast');
    });
    $("div#stickers a.fancy").fancybox({
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'speedIn': 100,
        'speedOut': 200,
        'overlayShow': true
    });

    /*Product Builder*/
    $("div#markerlinks a.fancy").fancybox({
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'speedIn': 100,
        'speedOut': 200,
        'overlayShow': true
    });



    /*accessory slider*/
    var currentPosition = 0;
    var slideWidth = 235;
    var slides = $('.slide');
    var numberOfSlides = slides.length;

    // Remove scrollbar in JS
    $('#imageslidercontainer').css('overflow', 'hidden');

    // Wrap all .slides with #slideInner div
    $('#slideInner').css({
        'float': 'left',
        'width': slideWidth
    });

    // Set #slideInner width equal to total width of all slides
    $('#slideInner').css('width', slideWidth * numberOfSlides);


    // Insert left and right arrow controls in the DOM
    //$('div.imageslider:first-child').append('<span class="control" id="leftControl"><img src="img/slidearrowleft.png" alt="arrow left" /></span><span class="control" id="rightControl"><img src="img/slidearrowright.png" alt="arrow right" /></span>');

    // Hide left arrow control on first load
    manageControls(currentPosition);

    // Create event listeners for .controls clicks
    $('.control')
		.bind('click', function() {
		    // Determine new position
		    currentPosition = ($(this).attr('id') == 'rightControl')
		? currentPosition + 1 : currentPosition - 1;

		    // Hide / show controls
		    manageControls(currentPosition);
		    // Move slideInner using margin-left
		    $('#slideInner').animate({
		        'marginLeft': slideWidth * (-currentPosition)
		    });
		});


    // manageControls: Hides and shows controls depending on currentPosition
    function manageControls(position) {
        // Hide left arrow if position is first slide
        if (position == 0) { $('#leftControl').hide() }
        else { $('#leftControl').fadeIn('fast') }
        // Hide right arrow if position is last slide
        if (position == numberOfSlides - 1) { $('#rightControl').hide() }
        else { $('#rightControl').fadeIn('fast') }
    }

    /* Select One Dropdown*/
    /*
    $('a.selectone').click(function () {
    $('ul.dropdown').slideDown('fast');
    });
    $('ul.dropdown li a').click(function () {
    var $str = $(this).text();
    $('a.selectone').html($str);
    $('ul.dropdown').slideUp('fast');
    });
    $('ul.dropdown li a').hover(
    function() {
    $(this).css('background-color','#323232');
    },
    function() {
    $(this).css('background-color','#808080');
    }
    );*/
    /*INIT event categorization (functions below)*/
    makeSenario();
    makeTournament();

    /*TOOL TIP*/
    $('div.warrantyform div.form p.where span').qtip({
        content: '<img src="img/serial.jpg" alt="Serial Number Placement" />',
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            name: 'dark',
            width: 323,
            height: 300
        }
    });
    $('div#customcontent p.where span').qtip({
        content: '<img src="img/serial.jpg" alt="Serial Number Placement" />',
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            name: 'dark',
            width: 323,
            height: 300
        }
    });

    /*Tab content*/
    $(".tabcontent").hide();
    $("ul#tabs li:first").addClass("active").show();
    $(".tabcontent:first").show();


    $("ul#tabs li").click(function() {
        $("ul#tabs li").removeClass("active");
        $(this).addClass("active");
        $(".tabcontent").hide();

        var activeTab = $(this).find("a").attr("href");
        $(activeTab).fadeIn();
        return false;
    });


    /*extent left nav*/
    dostuff();

    var urlParams = {};
    (function() {
        var e,
            a = /\+/g,  // Regex for replacing addition symbol with a space
            r = /([^&=]+)=?([^&]*)/g,
            d = function(s) { return decodeURIComponent(s.replace(a, " ")); },
            q = window.location.search.substring(1);

        while (e = r.exec(q))
            urlParams[d(e[1])] = d(e[2]);
    })();

    if (urlParams["showBuilder"]) {
        var t = setTimeout("showTheBuilder()", 1000);
    }
});           //end of document.ready()

function showTheBuilder()
    {
        $("div#markerlinks a.fancy").fancybox({
	        'transitionIn'	:	'elastic',
	        'transitionOut'	:	'elastic',
	        'speedIn'		:	100, 
	        'speedOut'		:	200, 
	        'overlayShow'	:	true
            }).trigger('click');
    }

/*LEFT NAV*/
function dostuff() {
    var bodyheight = $('div#handholder').height();
    $('div#leftnav').height(bodyheight-32);
    var markerpresence = $('div#markerlinks').length;
    if (markerpresence > 0) {
        $('div#handholder').css('background-color','#464646');
    };
    var downloadpresence = $('div.smalldl').length;
    if (downloadpresence>10) {
        $('div#handholder').css('background-color','#202020');
    };
    var DTpresence = $('div.SolutionType').length;
    if (DTpresence>0) {
        $('div#handholder').css('background-color','#323232');
    };
    var DTpresence = $('div#eventcontent').length;
    if (DTpresence>0) {
        $('div#handholder').css('background-color','#202020');
    };
}

//$('#flashcontainer').html('');
function setHPFlashAmerica() {
//    var usaFlash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
//    usaFlash += 'codebase="http://fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
//    usaFlash += 'width="960" height="380" ';
//    usaFlash += 'id="shoutletWidget" ';
//    usaFlash += 'align="middle">';
//    usaFlash += '<param name="movie" value="http://cdn.shoutlet.com/widgets/flash/SWFBootstrap.php?w=34805" />';
//    usaFlash += '<param name="allowScriptAccess" value="always" />';
//    usaFlash += '<param name="wmode" value="transparent" />';
//    usaFlash += '<param name="FlashVars" value="configv3=http://cdn.shoutlet.com/service/config/widgetconfig?widgetID=34805&amp;child=http://cdn.shoutlet.com/widgets/flash/SWFProxy.php?s=ShoutletOS.swf" />';
//		usaFlash += '<param name="quality" value="high" />';
//		usaFlash += '<param name="bgcolor" value="#000000" />';
//		usaFlash += '<embed src="http://cdn.shoutlet.com/widgets/flash/SWFBootstrap.php?w=34805" ';
//		usaFlash += 'FlashVars="configv3=http://cdn.shoutlet.com/service/config/widgetconfig?widgetID=34805&amp;child=http://cdn.shoutlet.com/widgets/flash/SWFProxy.php?s=ShoutletOS.swf" ';
//		usaFlash += 'quality="high" ';
//		usaFlash += 'bgcolor="#000000" ';
//		usaFlash += 'width="960" height="380" ';
//		usaFlash += 'name="shoutletWidget" ';
//		usaFlash += 'align="middle" ';
//		usaFlash += 'allowScriptAccess="always" ';
//		usaFlash += 'wmode="transparent" ';
//		usaFlash += 'type="application/x-shockwave-flash" ';
//		usaFlash += 'pluginspage="http://www.adobe.com/go/getflashplayer" />';
    //		usaFlash += '</object>';
//    var usaFlash = $.ajax({
//        url: "http://cdn.shoutlet.com/widgets/?w=34805",
//        type: "GET"
    //    });
    //var usaFlash = '<script type="text/javascript" src="http://cdn.shoutlet.com/widgets/?w=34805"></script>';
    //var usaFlash = '<iframe src="http://cdn.shoutlet.com/widgets/?w=34805" width="960"></iframe>';

    var othercountries = $('span.canada, span.emea, span.latin, span.asia');
	othercountries.hide();

}

function setHPFlashLatin() {
//    var latinFlash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
//    latinFlash += 'codebase="http://fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
//    latinFlash += 'width="960" height="380" ';
//    latinFlash += 'id="shoutletWidget" ';
//    latinFlash += 'align="middle">';
//    latinFlash += '<param name="movie" value="http://cdn.shoutlet.com/widgets/flash/SWFBootstrap.php?w=36582" />';
//    latinFlash += '<param name="allowScriptAccess" value="always" />';
//    latinFlash += '<param name="wmode" value="transparent" />';
//    latinFlash += '<param name="FlashVars" value="configv3=http://cdn.shoutlet.com/service/config/widgetconfig?widgetID=36582&amp;child=http://cdn.shoutlet.com/widgets/flash/SWFProxy.php?s=ShoutletOS.swf" />';
//    latinFlash += '<param name="quality" value="high" />';
//    latinFlash += '<param name="bgcolor" value="#000000" />';
//    latinFlash += '<embed src="http://cdn.shoutlet.com/widgets/flash/SWFBootstrap.php?w=36582" ';
//    latinFlash += 'FlashVars="configv3=http://cdn.shoutlet.com/service/config/widgetconfig?widgetID=36582&amp;child=http://cdn.shoutlet.com/widgets/flash/SWFProxy.php?s=ShoutletOS.swf" ';
//    latinFlash += 'quality="high" ';
//    latinFlash += 'bgcolor="#000000" ';
//    latinFlash += 'width="960" height="380" ';
//    latinFlash += 'name="shoutletWidget" ';
//    latinFlash += 'align="middle" ';
//    latinFlash += 'allowScriptAccess="always" ';
//    latinFlash += 'wmode="transparent" ';
//    latinFlash += 'type="application/x-shockwave-flash" ';
//    latinFlash += 'pluginspage="http://www.adobe.com/go/getflashplayer" />';
//    latinFlash += '</object>';

    //    $('.flashcontainer').html(latinFlash);
    var othercountries = $('span.canada, span.emea, span.usa, span.asia');
    othercountries.hide();
}
function setHPFlashEMEA() {
//    var emeaFlash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
//    emeaFlash += 'codebase="http://fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
//    emeaFlash += 'width="960" height="380" ';
//    emeaFlash += 'id="shoutletWidget" ';
//    emeaFlash += 'align="middle">';
//    emeaFlash += '<param name="movie" value="http://cdn.shoutlet.com/widgets/flash/SWFBootstrap.php?w=36578" />';
//    emeaFlash += '<param name="allowScriptAccess" value="always" />';
//    emeaFlash += '<param name="wmode" value="transparent" />';
//    emeaFlash += '<param name="FlashVars" value="configv3=http://cdn.shoutlet.com/service/config/widgetconfig?widgetID=36578&amp;child=http://cdn.shoutlet.com/widgets/flash/SWFProxy.php?s=ShoutletOS.swf" />';
//    emeaFlash += '<param name="quality" value="high" />';
//    emeaFlash += '<param name="bgcolor" value="#000000" />';
//    emeaFlash += '<embed src="http://cdn.shoutlet.com/widgets/flash/SWFBootstrap.php?w=36578" ';
//    emeaFlash += 'FlashVars="configv3=http://cdn.shoutlet.com/service/config/widgetconfig?widgetID=36578&amp;child=http://cdn.shoutlet.com/widgets/flash/SWFProxy.php?s=ShoutletOS.swf" ';
//    emeaFlash += 'quality="high" ';
//    emeaFlash += 'bgcolor="#000000" ';
//    emeaFlash += 'width="960" height="380" ';
//    emeaFlash += 'name="shoutletWidget" ';
//    emeaFlash += 'align="middle" ';
//    emeaFlash += 'allowScriptAccess="always" ';
//    emeaFlash += 'wmode="transparent" ';
//    emeaFlash += 'type="application/x-shockwave-flash" ';
//    emeaFlash += 'pluginspage="http://www.adobe.com/go/getflashplayer" />';
//    emeaFlash += '</object>';

    //    $('.flashcontainer').html(emeaFlash);
    var othercountries = $('span.canada, span.usa, span.latin, span.asia');
    othercountries.hide();
}
function setHPFlashAsia() {
//    var asiaFlash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
//    asiaFlash += 'codebase="http://fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
//    asiaFlash += 'width="960" height="380" ';
//    asiaFlash += 'id="shoutletWidget" ';
//    asiaFlash += 'align="middle">';
//    asiaFlash += '<param name="movie" value="http://cdn.shoutlet.com/widgets/flash/SWFBootstrap.php?w=36583" />';
//    asiaFlash += '<param name="allowScriptAccess" value="always" />';
//    asiaFlash += '<param name="wmode" value="transparent" />';
//    asiaFlash += '<param name="FlashVars" value="configv3=http://cdn.shoutlet.com/service/config/widgetconfig?widgetID=36583&amp;child=http://cdn.shoutlet.com/widgets/flash/SWFProxy.php?s=ShoutletOS.swf" />';
//    asiaFlash += '<param name="quality" value="high" />';
//    asiaFlash += '<param name="bgcolor" value="#000000" />';
//    asiaFlash += '<embed src="http://cdn.shoutlet.com/widgets/flash/SWFBootstrap.php?w=36583" ';
//    asiaFlash += 'FlashVars="configv3=http://cdn.shoutlet.com/service/config/widgetconfig?widgetID=36583&amp;child=http://cdn.shoutlet.com/widgets/flash/SWFProxy.php?s=ShoutletOS.swf" ';
//    asiaFlash += 'quality="high" ';
//    asiaFlash += 'bgcolor="#000000" ';
//    asiaFlash += 'width="960" height="380" ';
//    asiaFlash += 'name="shoutletWidget" ';
//    asiaFlash += 'align="middle" ';
//    asiaFlash += 'allowScriptAccess="always" ';
//    asiaFlash += 'wmode="transparent" ';
//    asiaFlash += 'type="application/x-shockwave-flash" ';
//    asiaFlash += 'pluginspage="http://www.adobe.com/go/getflashplayer" />';
//    asiaFlash += '</object>';

    //    $('.flashcontainer').html(asiaFlash);
    var othercountries = $('span.canada, span.emea, span.latin, span.usa');
    othercountries.hide();
}
function setHPFlashCanada() {
//    var canadaFlash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
//    canadaFlash += 'codebase="http://fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
//    canadaFlash += 'width="960" height="380" ';
//    canadaFlash += 'id="shoutletWidget" ';
//    canadaFlash += 'align="middle">';
//    canadaFlash += '<param name="movie" value="http://cdn.shoutlet.com/widgets/flash/SWFBootstrap.php?w=36581" />';
//    canadaFlash += '<param name="allowScriptAccess" value="always" />';
//    canadaFlash += '<param name="wmode" value="transparent" />';
//    canadaFlash += '<param name="FlashVars" value="configv3=http://cdn.shoutlet.com/service/config/widgetconfig?widgetID=36581&amp;child=http://cdn.shoutlet.com/widgets/flash/SWFProxy.php?s=ShoutletOS.swf" />';
//    canadaFlash += '<param name="quality" value="high" />';
//    canadaFlash += '<param name="bgcolor" value="#000000" />';
//    canadaFlash += '<embed src="http://cdn.shoutlet.com/widgets/flash/SWFBootstrap.php?w=36581" ';
//    canadaFlash += 'FlashVars="configv3=http://cdn.shoutlet.com/service/config/widgetconfig?widgetID=36581&amp;child=http://cdn.shoutlet.com/widgets/flash/SWFProxy.php?s=ShoutletOS.swf" ';
//    canadaFlash += 'quality="high" ';
//    canadaFlash += 'bgcolor="#000000" ';
//    canadaFlash += 'width="960" height="380" ';
//    canadaFlash += 'name="shoutletWidget" ';
//    canadaFlash += 'align="middle" ';
//    canadaFlash += 'allowScriptAccess="always" ';
//    canadaFlash += 'wmode="transparent" ';
//    canadaFlash += 'type="application/x-shockwave-flash" ';
//    canadaFlash += 'pluginspage="http://www.adobe.com/go/getflashplayer" />';
//    canadaFlash += '</object>';

    //    $('.flashcontainer').html(canadaFlash);
    var othercountries = $('span.usa, span.emea, span.latin, span.asia');
    othercountries.hide();
}
/*Home page backgrounds*/
function background1() {
    $('#aspnetForm').css({
    'background-image': 'url("../img/Tipp25YrsExprnce.jpg")'
    });
};
function background2() {
    $('#aspnetForm').css({
        'background-image':'url("../img/02.jpg")'
    });
};
function background3() {
    $('#aspnetForm').css({
        'background-image':'url("../img/03.jpg")'
    });
};
function background4() {
    $('#aspnetForm').css({
        'background-image':'url("../img/04.jpg")'
    });
};
function background5() {
    $('#aspnetForm').css({
        'background-image':'url("../img/05.jpg")'
    });
};
function background6() {
    $('#aspnetForm').css({
    'background-image': 'url("../img/Tipp25YrsExprnce.jpg")'
    });
};

/*events categorization functions*/
function makeSenario () {
    $('div.keystone').parent('div.eventblock').css({
        'background-image':'url("../img/scenarioicon.gif")',
        'background-position':'651px 0',
        'background-repeat':'repeat-y'
    });
};
function makeTournament () {
    $('div.camel').parent('div.eventblock').css({
        'background-image':'url("../img/tournamentrightpipe.gif")',
        'background-position':'651px 0',
        'background-repeat':'repeat-y'
    });
};


function sendShopatronRequest(xmlString) {

    //for testing purposes
    xmlString = '<?xml version="1.0"?>';
    xmlString += '<methodCall>';
    xmlString += '<methodName>examples.loadOrder</methodName>';
    xmlString += '<params>';
    xmlString += '<param>';
    xmlString += '<value><string>100.1</string></value>';
    xmlString += '</param>';
    xmlString += '<param>';
    xmlString += '<value><int>1</int></value>';
    xmlString += '</param>';
    xmlString += '<param>';
    xmlString += '<value>';
    xmlString += '<struct>';
    xmlString += '<member><name>item_1</name>';
    xmlString += '<value>';
    xmlString += '<struct>';
    xmlString += '<member><name>product_id</name>';
    xmlString += '<value><string>RC64ARF</string></value>';
    xmlString += '</member>';
    xmlString += '<member><name>name</name>';
    xmlString += '<value><string>SIG SUKHOI ARF KIT</string></value>';
    xmlString += '</member>';
    xmlString += '<member><name>price</name>';
    xmlString += '<value><double>9.99</double></value>';
    xmlString += '</member>';
    xmlString += '<member><name>actual_price</name>';
    xmlString += '<value><double>9.99</double></value>';
    xmlString += '</member>';
    xmlString += '<member><name>avg_margin</name>';
    xmlString += '<value><double>.23</double></value>';
    xmlString += '</member>';
    xmlString += '<member><name>vat_inclusive</name>';
    xmlString += '<value><int>0</int></value>';
    xmlString += '</member>';
    xmlString += '<member><name>quantity</name>';
    xmlString += '<value><int>1</int></value>';
    xmlString += '</member>';
    xmlString += '</struct>';
    xmlString += '</value>';
    xmlString += '</member>';
    xmlString += '</struct>';
    xmlString += '</value>';
    xmlString += '</param>';
    xmlString += '<param>';
    xmlString += '<value>';
    xmlString += '<struct>';
    xmlString += '<member><name>language_id</name>';
    xmlString += '<value><int>1</int></value>';
    xmlString += '</member>';
    xmlString += '<member><name>currency_id</name>';
    xmlString += '<value><int>1</int></value>';
    xmlString += '</member>';
    xmlString += '</struct>';
    xmlString += '</value>';
    xmlString += '</param>';
    xmlString += '</params>';
    xmlString += '</methodCall>';

    alert(xmlString);

    //error. 302 re-direct. some origin policy. happens every time.
    var response =
        $.ajax({
            type: "POST",
            url: "http://xml.shopatron.com/xmlServer.php",
            data: xmlString,
            success: function(returnValue) {
                alert(returnValue);
            },
            error: function(msg, textStatus) {
                alert(msg.status);
            }
        }).responseText;    

}


/*Tshirt switcher*/
 var ntshirt = 9;
 var tshirtimgon = new Array(9);
 var tshirtimgoff = new Array(9);
 var tshirtdownload = new Array(9);
 var tshirtimgdetail = new Array(9);
 tshirtimgon[0] = "shirt1_on.gif";
 tshirtimgoff[0] = "shirt1_off.gif";
 tshirtdownload[0] = "shirt1_tree.pdf";
 tshirtimgdetail[0] = "shirt1.jpg";
 tshirtimgon[1] = "shirt2_on.gif";
 tshirtimgoff[1] = "shirt2_off.gif";
 tshirtdownload[1] = "shirt2_players_banner.pdf";
 tshirtimgdetail[1] = "shirt2.jpg";
 tshirtimgon[2] = "shirt3_on.gif";
 tshirtimgoff[2] = "shirt3_off.gif";
 tshirtdownload[2] = "shirt3_squat.pdf";
 tshirtimgdetail[2] = "shirt3.jpg";
 tshirtimgon[3] = "shirt4_on.gif";
 tshirtimgoff[3] = "shirt4_off.gif";
 tshirtdownload[3] = "shirt4_gernade.pdf";
 tshirtimgdetail[3] = "shirt4.jpg";
 tshirtimgon[4] = "shirt5_on.gif";
 tshirtimgoff[4] = "shirt5_off.gif";
 tshirtdownload[4] = "shirt5_splat.pdf";
 tshirtimgdetail[4] = "shirt5.jpg";
 tshirtimgon[5] = "shirt6_on.gif";
 tshirtimgoff[5] = "shirt6_off.gif";
 tshirtdownload[5] = "shirt6_logo_splat.pdf";
 tshirtimgdetail[5] = "shirt6.jpg";
 tshirtimgon[6] = "shirt9_on.gif";
 tshirtimgoff[6] = "shirt9_off.gif";
 tshirtdownload[6] = "shirt9.pdf";
 tshirtimgdetail[6] = "shirt9.jpg";
 tshirtimgon[7] = "shirt8_on.gif";
 tshirtimgoff[7] = "shirt8_off.gif";
 tshirtdownload[7] = "shirt8.pdf";
 tshirtimgdetail[7] = "shirt8.jpg";
 tshirtimgon[8] = "shirt7_on.gif";
 tshirtimgoff[8] = "shirt7_off.gif";
 tshirtdownload[8] = "shirt7.pdf";
 tshirtimgdetail[8] = "shirt7.jpg";
 function TshirtClick(n, img) { 
 for (i=0;i<ntshirt;i++) { 
	if (i == n) { 
		eval('document.images.imgtshirt.src = "/images/downloads/tshirts/' + tshirtimgdetail[i] + '";'); 
		eval('document.images.imgthumbnail' + i + '.src = "/images/downloads/tshirts/' + tshirtimgon[i] + '";'); 
		for (j=0;j<document.anchors.length;j++) { 
			if (document.anchors[j].name == 'atshirtdownload') { 
				eval('document.anchors[j].href = "/images/downloads/tshirts/' + tshirtdownload[i] + '";'); 
			} 
		} 
	} 
	else { 
		eval('document.images.imgthumbnail' + i + '.src = "/images/downloads/tshirts/' + tshirtimgoff[i] + '";'); 
	} 
}
 
} 

