
var mob = (navigator.userAgent.indexOf("iPhone") != -1) || ((navigator.userAgent.indexOf("Android") != -1) || (navigator.userAgent.indexOf("Mobile") != -1)) || (navigator.userAgent.indexOf('iPad') != -1) || (navigator.userAgent.indexOf('iPod') != -1);
if (document.addEventListener) {
    window.addEventListener('load', isWebGlSupported);
}else if(document.attachEvent){
    window.attachEvent('onload', isWebGlSupported);
}
function isWebGlSupported() {
    var canvasSupported = !!window.HTMLCanvasElement;
    var context = null;
    var ua = navigator.userAgent.toLowerCase();
    var isAtLeastIE10 = (ua.match(/Trident\/[6]/i)); //test IE10;
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { //test for MSIE x.x;
        var ieversion = new Number(RegExp.$1) // capture x.x portion and store as a number
       // if (ieversion >= 9 || ieversion >= 8) var IeUser = true;
    }
    if (ieversion >= 5 || ieversion >= 6 || ieversion >= 7 || ieversion >= 8 || ieversion >= 9 || isAtLeastIE10) {
        canvasSupported = false;
    }
    if (canvasSupported) {
        var canvas = document.getElementById("superblaze-canvas");
        var names = ["webgl2", "webgl", "experimental-webgl", "webkit-3d", "moz-webgl"];
        for (var ii = 0; ii < names.length; ++ii) {
            try {
                context = canvas.getContext(names[ii], {
                    antialias: true,
                    depth: true
                });
            } catch (e) {}
            if (context) {
                break;
            }
        }
        canvasSupported = !!(window.WebGLRenderingContext && context);
    }
    if (canvasSupported) {
        addLoader();
        SuperblazeStart(context);
        if ((navigator.userAgent.indexOf("iPhone") != -1) || ((navigator.userAgent.indexOf("Android") != -1) || (navigator.userAgent.indexOf("Mobile") != -1)) || (navigator.userAgent.indexOf('iPod') != -1)) {
             if ((navigator.userAgent.indexOf("iPhone") != -1) || (navigator.userAgent.indexOf("Android") != -1) || (navigator.userAgent.indexOf('iPod') != -1)) {
                document.location = "mobile/index.html"
            } 
        } else {
        }
    } 
}

function addLoader() {
	if(mobileViewPoint == false) {
		$('#transPatch,#loader,#loader1,#loader2').css('display', 'block');
		$('#loader').html('<image src="images_gl/loaderblock.jpg" />');
		$('#loader1').html('<image src="images_gl/loader_011.png"/>');
		$('#loader2').html('<div id="loaderbar" style="position:absolute; left:463px; top:0px;width:1px;outline:none;overflow:hidden;"><image src="images_gl/loaderbar.png" style="outline:none;"/></div>');
	} else {
		$('#transPatch,#loader,#loader1,#loader2').css('display', 'block');
		$('#loader').html('<image src="images_gl/loaderblock_mobile.png" />');
		$('#loader1').html('<image src="images_gl/loader_011_mobile.png"/>');
		 $('#loader2').html('<div id="loaderbar" style="position:absolute;left:244px;top:0px;width:1px;outline:none;overflow:hidden;"><image src="images_gl/loaderbar_mobile.png" style="outline:none;"/></div>');
	}
}

var dragCursor;
var curBrowser = BrowserDetect.browser;
// IE doesn't support co-ordinates
var cursCoords = (curBrowser == "Explorer") ? "" : " 4 4";

function initDragCursorSpin() {
    handOpenSpin();
    $('body').mouseup(function() {
        handOpenSpin();
    });
}

function handClosedSpin() {
    dragCursor = (curBrowser == "Firefox") ? "-moz-grabbing" : "url(images_gl/closedhand.cur)" + cursCoords + ", move";
    // Opera doesn't support url cursors and doesn't fall back well...
    if (curBrowser == "Opera") dragCursor = "move";
}

function handOpenSpin() {
    dragCursor = (curBrowser == "Firefox") ? "-moz-grab" : "url(images_gl/openhand.cur)" + cursCoords + ", move";
}

function getCanvasSupported() {
    return canvasSupported;
}