﻿function checkMobile(alternateURL) {// create an iframe

    //var isMobile = false;

    var iframe = document.createElement('iframe'), realScreen;

    // hide iframe, but not by using display:none

    iframe.style.height = '0px';
    iframe.style.width = '0px';
    iframe.style.border = 'none';
    iframe.style.position = 'absolute';
    iframe.style.left = '-99999px';

    // insert the iframe into our document

    document.appendChild(iframe);

    // put a crazy meta tag in there to prevent scaling

    iframe.contentWindow.document.innerHTML =
  '<head><meta name="viewport"' +
  ' content="width=device-width, initial-scale=1, maximum-scale=1" />' +
  '</head><body></body>';

    // get screen property of frame's window object

    realScreen = iframe.contentWindow.screen;

    // if the screen is tiny
    // or the "real" screen is smaller than the "virtual" screen
    // then redirect

    if ((realScreen.width <= 480) || (realScreen.height <= 480) ||
    (realScreen.width < screen.width) || (realScreen.height < screen.height)) {
        //isMobile = true; 
        alert('mobile');
        location.replace(alternateURL);
    }

    // remove our iframe if we're still here
    alert('not');
    document.removeChild(iframe);
}

function popitup(url) {
    newwindow = window.open(url, 'name', 'height=300,width=400,resizable=0,status=0,location=0,scrollbars=0' );
    if (window.focus) { newwindow.focus() }
    return false;
}
