window.addEvent('domready', function() {

	// fix external links
	$(document.body).getElements('a[rel^=blank]').addEvent('click', function(e) {
		window.open(this.href, '_blank');
		return false;
	});

	

});

var pageTrackerCustom = {
    topLevelDomain: function() {
        var hostName = String(window.location.hostname).replace('www.mytoshiba.','');
		return hostName.substring(hostName.indexOf('.') + 1, hostName.length).toUpperCase();
	},
    _trackEvent: function(category, action, optional_label, optional_value) {
        try {
            pageTracker._trackEvent(category, action, optional_label, optional_value);
        } catch (er) { }
    }
}


String.implement({
	padLeft: function(length, padChar) {
		if ($type(length) != "number") {
			if ($type(length) == "string") length.toInt();
			else return this;
		}
		if (length <= this.length) return this;
		else {
			if ($type(padChar) != "string") padChar = " "
			tmp = ""
			for (i = 0; i < (length - this.length); i++) tmp = tmp + padChar
			return tmp + this;
		}
	},
	htmlEncode: function() {
		var el = new Element('div').set('text', this);
		return el.get('text').replace(/&/, '&amp;').clean();
	},
	toProperCase: function() {
		return this.toLowerCase().replace(/^(.)|\s(.)/g, function($1) { return $1.toUpperCase(); });
	}
});

var Popup = new Class({
	options: {
		center: true,
		target: 'window',
		replace: true,
		window: {
			height: 400,
			width: 400,
			status: false,
			toolbar: false,
			menubar: false,
			location: false,
			resizable: false,
			scrollbars: false,
			left: 0,
			top: 0
		}
	},
	initialize: function(url, options) { this.setOptions(options);
		this.parameters	= '';
		if ($defined(url)) {
		
			if (this.options.center && this.options.window.left == 0 && this.options.window.top == 0) {
				this.options.window.left	= Math.round((screen.width - this.options.window.width) / 2);   if (this.options.window.left < 25) this.options.window.left = 0;
				this.options.window.top		= Math.round((screen.height - this.options.window.height) / 2); if (this.options.window.top < 50)  this.options.window.top	= 0;
			}
			
			if (this.options.target != '_self' && this.options.target != '_blank') {
				this.parameters	= this.toParameterString();
			}
			
			var win = window.open(url, this.options.target, this.parameters, this.options.replace);
			win.focus();
		}
	},
	toParameterString: function() {
		var options = '';
		for (var option in this.options.window) {
			value	= this.options.window[option];
			value	= ($type(value) == 'boolean' ? (value ? 'yes' : 'no') : value);
			options += ',' + option + '=' + value;
		}
		
		return options.slice(1);
	}
});
Popup.implement(new Options);
