///-codeFile-//////////////////////////////////////////////////////////////////
// Support.js
//
// Written by Doug Greenall (douggreenall.co.uk)
// Copyright (c) 2008 Doug Greenall
//
// Feel free to use this code in any of your own personal projects but please
// leave this notice and my details intact. This code may not be used for any
// commercial projects without explicit permission
///////////////////////////////////////////////////////////////////////////////


///-function-//////////////////////////////////////////////////////////////////
// wGet
///////////////////////////////////////////////////////////////////////////////
function wGet(ID) { return window.document.getElementById(ID); }


///-class-/////////////////////////////////////////////////////////////////////
// Vector2D
///////////////////////////////////////////////////////////////////////////////
function Vector2D(X, Y)
{
    ///-data-//////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////

    this._x = X;
    this._y = Y;


    ///-arithmetic-////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////

    this.AddVal = function(Value) { this._x += Value; this._y += Value; return this; };
    this.SubVal = function(Value) { this._x -= Value; this._y -= Value; return this; };
    this.MulVal = function(Value) { this._x *= Value; this._y *= Value; return this; };
    this.DivVal = function(Value)
    {
        if (Value)
        {
            this._x /= Value;
            this._y /= Value;
        }

        return this;
    };


    this.AddVec = function(Vector) { this._x += Vector._x; this._y += Vector._y; return this; };
    this.SubVec = function(Vector) { this._x -= Vector._x; this._y -= Vector._y; return this; };
    this.MulVec = function(Vector) { this._x *= Vector._x; this._y *= Vector._y; return this; };
    this.DivVec = function(Vector)
    {
        if (Vector._x && Vector._y)
        {
            this._x /= Vector._x;
            this._y /= Vector._y;
        }

        return this;
    };


    ///-methods-///////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////

    this.toString = function() { return this._x + "|" + this._y; };
    this.Clone = function() { return new Vector2D(this._x, this._y); };

    this.GetXInt = function() { return Math.round(this._x); };
    this.GetYInt = function() { return Math.round(this._y); };

    this.GetXPxl = function() { return Math.round(this._x) + 'px'; };
    this.GetYPxl = function() { return Math.round(this._y*3.5) + 'px'; };
}

