function clickIE4() {
    if (event.button == 2) {
        return false;
    }
}

function clickNS4(e) {
    if (document.layers || document.getElementById && !document.all) {
        if (e.which == 2 || e.which == 3) {
            return false;
        }
    }
}
if (document.layers) {
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown = clickNS4;
}
else if (document.all && !document.getElementById) {
    document.onmousedown = clickIE4;
}
document.oncontextmenu = new Function("return false;")
var step = 1;
$(document).ready(function () {
    $('#plaque_msg').hide();
    $("#s_left").hide();
    $('#stylez').hide();
    $('#trcolor').hide();
    $('#trcolor2').hide();
    $('#back-button').hide();
});

function clear_p() {
    if ($('#plaque_message').val() == "Enter plaque Text Here... and plaque Colour (Gold or Silver)") $('#plaque_message').empty();
}

function turn_on() {
    $('#plaque_msg').show();
    $('span#added').remove();
    $('#price').append("<span id='added'> (+ $15.00 for Plaque)</span>");
}

function turn_off() {
    $('#plaque_msg').hide();
    $('span#added').remove();
}

function show_size_info(rand) {
    var fsize = $('#size').val();
    var style = $('#style_id').val();
    var color = $('#color').val();
    var color2 = $('#color2').val();
    var color3 = $('#color3').val();
    num = 1;
    if (color3 == '') color3 = 'none';
    if (color != '') num = num + 1;
    else color = 'none';
    if (color2 != '') num = num + 1;
    else color2 = 'none';
    if (fsize == "") {
        $('#price').html("$0.00");
        $('#rsize').html("0 x 0 cm");
    }
    else {
        getInfo(style, fsize, rand, num, color3, color2, color);
    }
}

function doNext(double, rand) {
    var val = $('#stylez').val();
    if (val == 0) alert("Please select a style before proceeding.");
    else step2(val, rand, double);
}

function doNextStep(val, double, rand) {
    window.location = '/frame-your-jersey.html&c=' + val;
}

function getTeam(team, cat) {
    window.location = '/frame-your-jersey.html&t=' + team;
}

function getStyle(team, r, style, type) {
    step2(style, r, team, type);
}

function changeCollageColor(rand, t) {
    var style = $('#style_id').val();
    var color = $('#color').val();
    var color2 = $('#color2').val();
    var color3 = $('#color3').val();
    num = 1;
    if (color == '') color = 'none';
    else num = num + 1;
    if (color2 == '') color2 = 'none';
    else num = num + 1;
    changeColor(style, color, rand, num, color2, color3, t);
}

function add2cart(opt, rand) {
    var style = $('#style_id').val();
    var price = $("#price").html();
    price = price.replace("$", "");
    var dimensions = $("#rsize").html();
    var dimo = new Array();
    dimensions = dimensions.replace("x", "").replace(" cm", "");
    dimo = dimensions.split(" ");
    var width = dimo[0];
    var height = dimo[2];
    var size = $('#size').val();
    var color = $('#color').val();
    var color2 = $('#color2').val();
    var color3 = $('#color3').val();
    var colorname = $('#color option:selected').text();
    var colorname2 = $('#color2 option:selected').text();
    var colorname3 = $('#color3 option:selected').text();
    if ($('#plaque_message').val() != null) {
        var plaque_msg = $('#plaque_message').val();
        var plaque = $("input:radio[name=plaque]:checked").val();
		var pcolor = $("input:radio[name=pcolor]:checked").val();
    }
    else {
        var plaque_msg = '';
        var plaque = 'no';
		var pcolor = '';
    }
    if (color3 == "") {
        alert("Please select your Single Mat Colour.");
    }
    else if (color == "" && document.getElementById("color").style.display != "none") {
        alert("Please select the shadow box color.");
    }
    else if (size == "") {
        alert("Please select a size.");
    }
    else {
        var num = $('#style_type').val();
        add2db(size, style, color, rand, price, width, height, opt, colorname, num, colorname2, colorname3, plaque, plaque_msg, pcolor);
    }
}

$(window).unload(function(){
	var rand = $("#random").val();
	var url = "/scripts/sport_frame.php?action=delete&r="+rand;
	
	var __xmlHttpRequest = window.XMLHttpRequest;
	window.XMLHttpRequest = XMLHttpRequest = function() {
	var _xmlHttp = null;
	if (!__xmlHttpRequest) {
		try {
			_xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(ex) {}
	}
	else {
		_xmlHttp = new __xmlHttpRequest();
	}
   
	if (!_xmlHttp) return null;
	
	this.abort = function() {return _xmlHttp.abort();}
	this.getAllResponseHeaders = function() {return _xmlHttp.getAllResponseHeaders();}
	this.getResponseHeader = function(header) {return _xmlHttp.getResponseHeader(header);}
	this.open = function(method, url, async, user, password) {
		return _xmlHttp.open(method, url, false, user, password);
	}
	this.send = function(body) {
		_xmlHttp.send(body);
		this.readyState = _xmlHttp.readyState;
		this.responseBody = _xmlHttp.responseBody;
		this.responseStream = _xmlHttp.responseStream;
		this.responseText = _xmlHttp.responseText;
		this.responseXML = _xmlHttp.responseXML;
		this.status = _xmlHttp.status;
		this.statusText = _xmlHttp.statusText;
		this.onreadystatechange();
	}
	this.setRequestHeader = function(name, value) {return _xmlHttp.setRequestHeader(name, value);}
	}
	
	$.get(url, function(data){});
});
