﻿;
///////////////////////////////////////////////////////////////////////////////
//// SonixJS
///////////////////////////////////////////////////////////////////////////////
if(typeof SonixJS == 'undefined'){
    var SonixJS = {
        __namespace:true,
        __typeName:'SonixJS'
    };
};

///// To get random num
SonixJS.RND=function(){
	return (+new Date());
};

///////////////////////////////////////////////////////////////////////////////
/////  SonixJS.URL
/////
/////  options = {
/////  	protocol: string,
/////  	hostName: string,
/////  	port: string,
/////  	pathName: string,
/////  	search: string / {},
/////  	hash: string
/////  }
/////
///////////////////////////////////////////////////////////////////////////////
SonixJS.URL = {
	href: function(options){
		options = options || {};
		var protocol=options.protocol || location.protocol.replace(':', ''),
			hostName=options.hostName || location.hostname,
			port=options.port || location.port,
			pathName=options.pathName || location.pathname,
			search=options.search || decodeURIComponent(location.search.replace('?', '')),
			hash=(options.hash===false) ? options.hash : options.hash || location.hash.replace('#', '');
		if(search.constructor!=String){
			var srchs=decodeURIComponent(location.search.replace('?', '')).split('&'), srcObj={};
			for(var i=0, l=srchs.length; i<l; i++){
				var nv=srchs[i].split('=');
				srcObj[nv[0]]=nv[1];
			}
			jQuery.extend(srcObj, options.search);
			var srchArray=[];
			jQuery.each(srcObj, function(n, v){
				srchArray.push(n+'='+encodeURIComponent(v));
			});
			search=srchArray.join('&');
		}
		return protocol+'://'+hostName+((!!port)?':'+port:'')+pathName+((!!search)?'?'+search:'')+((!!hash)?'#'+hash:'');
	},
	qs: function(key){
		key=key || '';
		var srchs=decodeURIComponent(location.search.replace('?', '')).split('&'), srcObj={};
		for(var i=0, l=srchs.length; i<l; i++){
			var nv=srchs[i].split('=');
			srcObj[nv[0]]=nv[1];
		}
		if(key===''){
			return srcObj;
		}else{
			return srcObj[key] || '';
		}
	}
};


///////////////////////////////////////////////////////////////////////////////
/////  SonixJS.FNS
///////////////////////////////////////////////////////////////////////////////
SonixJS.FNS = {
    showImageLoadingIndicator: function(){
        if(jQuery){
            if(jQuery.browser.msie && jQuery.browser.version < '7') jQuery('#imageLoadingIndicator > div:first-child').css('height', jQuery().height()+'px');
            jQuery('#imageLoadingIndicator').css('display', 'block');
        }
    },
    hideImageLoadingIndicator: function(){
        if(jQuery){
            jQuery('#imageLoadingIndicator').css('display', 'none');
        }
    },
    showDropdownbox: function(){
	    if(jQuery){
	        if(jQuery.browser.msie && jQuery.browser.version <= 6) jQuery('select').show();
	    }
    },
    hideDropdownbox: function(){
        if(jQuery){
	        if(jQuery.browser.msie && jQuery.browser.version <= 6) jQuery('select').hide();
	    }
    }
};

///////////////////////////////////////////////////////////////////////////////
/////  SonixJS.LOG
///////////////////////////////////////////////////////////////////////////////
SonixJS.LOG = {
	logs: [],
	timeCounters: {},
	log: function(){
		var x='';
		for(var i=0; i<arguments.length; i++){ 
			if(i===0){
				x=arguments[0].toString();
			}else{
				x+=' ' + arguments[i].toString();
			}
		}
		this.logs.unshift(x);
	},
	time: function(name, reset){
		if(!name) return;
		if(!reset && name in this.timeCounters) return;
		this.timeCounters[name]=new Date().getTime();
    },
	timeEnd: function(name){
		if(!this.timeCounters) return;
		var time = new Date().getTime();
		var timeCounter = this.timeCounters[name];
		if(timeCounter){
            var diff = time - timeCounter;
            this.log(name + ":", diff + "ms");
            delete this.timeCounters[name];
        }
    },
	clear: function(){
		this.logs=[];
	},
	show: function(){
		alert(this.logs.join('\r\n'));
	}
};

///////////////////////////////////////////////////////////////////////////////
/////  SonixJS.JSON
///////////////////////////////////////////////////////////////////////////////
SonixJS.JSON = {
    arrayToString: function(arr, quote){
        if(!quote){
            return '[' + arr.join(',') + ']';
        }else{
            var tmpArray = []
            for(var i=0, l=arr.length; i<l; i++){
                tmpArray.push('"' + arr[i] + '"');
            }
            return '[' + tmpArray.join(',') + ']'; 
        }
    }
};


///////////////////////////////////////////////////////////////////////////////
/////  SonixJS.Cookie
///////////////////////////////////////////////////////////////////////////////
SonixJS.Cookie = {
    read: function(name, subkey){
        var cookieValue = '', search = name + '=';
        if(document.cookie.length > 0){ 
            var offset = document.cookie.indexOf(search);
            if(offset !== -1){ 
                offset += search.length;
                var end = document.cookie.indexOf(';', offset);
                if(end === -1) end = document.cookie.length;
                cookieValue = decodeURIComponent(document.cookie.substring(offset, end));

                if(!!subkey){
                    var kvps = cookieValue.split('&');
                    for(var i=0, l=kvps.length; i<l; i++){
                        if(kvps[i].indexOf(subkey + '=') !== -1){
                            offset = kvps[i].indexOf(subkey + '=') + subkey.length + 1;
                            return kvps[i].substring(offset);
                        }
                    }
                    cookieValue = '';
                }
            }
        }
        return cookieValue;
    },
    write: function(name, value, domain, hours){
        var expires = '';
        if(!!hours){
            var date = new Date((new Date()).getTime() + hours * 3600000);
            expires = '; expires=' + date.toUTCString();
        }
        var path = '; path=/';
        domain = (!!domain) ? '; domain=.' + (domain) : '';
        value += '';
        if(value.indexOf('=') !== -1){
	        var kv, kvps = value.split('&');
	        for(var i=0, l=kvps.length; i<l; i++){
	            kv = kvps[i].split('=');
	            kvps[i] = kv[0] + '=' + encodeURIComponent(kv[1]);
	        }
	        value = kvps.join('&');
        }else{
            value = encodeURIComponent(value);
        }
        document.cookie = [name, '=', value, expires, path, domain].join('');
    },
    changeOne: function(name, subkey, value, domain, hours){
        var newValue = SonixJS.Cookie.read(name);
        if (newValue !== '') {
            var kv, found = false, kvps = newValue.split('&');
            for(var i=0, l=kvps.length; i<l; i++){
	            kv = kvps[i].split('=');
	            if(kv[0] === subkey){
	                kvps[i] = kv[0] + '=' + value;
	                found = true;
	            }
	        }
	        newValue = kvps.join('&');
	        if (!found) newValue += '&' + subkey + '=' + value;
	    }else{
	        newValue = subkey + '=' + value;
	    }
        SonixJS.Cookie.write(name, newValue, domain, hours);
    },
    changeMulti: function(name, kvs, domain, hours){
        kvs = kvs || {};
        var newValue = SonixJS.Cookie.read(name);
        if (newValue !== '') {
            var kv, kvps = newValue.split('&'), added = '';
            for(var i=0, l=kvps.length; i<l; i++){
	            kv = kvps[i].split('=');
	            if(!!kvs[kv[0]]){
	                kvps[i] = kv[0] + '=' + kvs[kv[0]];
	                added += kv[0] + ',';
	            }
	        }
	        newValue = kvps.join('&');
	        for(var x in kvs){
	            if(added.indexOf(x) === -1) newValue += '&' + x + '=' + kvs[x];
	        }
	    }else{
	        var values = [];
	        for(var x in kvs){
	            values.push(x + '=' + kvs[x]);
	        }
	        newValue = values.join('&');
	    }
        SonixJS.Cookie.write(name, newValue, domain, hours);
    },
    readAsObject: function(name){
        var cookieValue = '', search = name + '=', obj = {};
        if(document.cookie.length > 0){ 
            var offset = document.cookie.indexOf(search);
            if(offset !== -1){ 
                offset += search.length;
                var end = document.cookie.indexOf(';', offset);
                if(end === -1) end = document.cookie.length;
                cookieValue = decodeURIComponent(document.cookie.substring(offset, end))
                if(cookieValue.indexOf('=') !== -1){
                    var kv, kvps = cookieValue.split('&');
                    for(var i=0, l=kvps.length; i<l; i++){
                        kv = kvps[i].split('=');
                        obj[kv[0]] = (!!kv[1])?kv[1]:'';
                    }
                }else{
                    obj[name] = cookieValue;
                }
            }
        }
        return obj;
    }
};


///////////////////////////////////////////////////////////////////////////////
/////  SonixJS.MSG
///////////////////////////////////////////////////////////////////////////////
SonixJS.MSG = {
	get: function(id, language, dft){
		return (this.language===language && this[id]) ? this[id] : (!!dft) ? dft : '';
	},
	load: function(ids, language){
		var self = this;
		jQuery.get('/DS/MetaData.asp', {what: 'msg', ids: ids, language: language}, function(data){
					var d=eval('(' + data + ')');
					self.language=language;
					jQuery.each(d.items, function(n, v){self[v.id]=v.msg;});
		});
	},
	load2: function(ids, language){
		var self = this;
		jQuery.ajax({
			async: false,
			url: '/DS/MetaData.asp',
			data: {what: 'msg', ids: ids, language: language},
			success: function(data){
				var d=eval('(' + data + ')');
				self.language=language;
				jQuery.each(d.items, function(n, v){self[v.id]=v.msg;});
			}
		});
	}
};

		
///////////////////////////////////////////////////////////////////////////////
/////  SonixJS.QS
///////////////////////////////////////////////////////////////////////////////
SonixJS.QS = function(key){
	return SonixJS.URL.qs(key);
};


///////////////////////////////////////////////////////////////////////////////
/////  SonixJS.Dialog
///////////////////////////////////////////////////////////////////////////////
SonixJS.Dialog = {
	show: function(html, options){
		SonixJS.FNS.hideDropdownbox();
		jQuery(document.body).addClass('jui');
		if(jQuery('#jdlg').size()===0) jQuery('<div id="jdlg" style="display:none;"></div>').appendTo(document.body);
		jQuery('#jdlg')
			.html(html)
			.css({display:'block', width:'1px', height:'1px'})
			.dialog(jQuery.extend({
				resizable:false,
				modal:true,
				overlay:{
					opacity:0.5,
					background:'#000000'
				},
				zIndex:999999
			}, options));
	},
	hide: function(){
		SonixJS.FNS.showDropdownbox();
		jQuery(document.body).removeClass('jui');
		jQuery('#jdlg').dialog('destroy');
	},
	leaveMsg: function(){
		var html='', self=this;
			options={
				title: 'Leave us a message, please!',
				width: 480,
				height: 320,
				buttons: {
					'Send': function(){},
					'Close': function(){self.hide();}
				},
				open:function(ev, ui){}
			};
		html+='<div class="sonix-warning" style="text-align:left;">';
			html+='Please send us your comments / suggestions and inquires by writing it below, and click send button.';
		html+='</div>';
		this.show(html, options);
	}
};


///////////////////////////////////////////////////////////////////////////////
/////  SonixJS.Magnifier
///////////////////////////////////////////////////////////////////////////////
SonixJS.Magnifier = {
	show: function(html, options){
		SonixJS.FNS.hideDropdownbox();
		jQuery('#jmag')
			.html(html)
			.css({display:'block', width:'1px', height:'1px'})
			.magnifier(jQuery.extend({
				zIndex:999999
			}, options));
	},
	hide: function(){
		SonixJS.FNS.showDropdownbox();
		jQuery('#jmag').magnifier('destroy');
	}
};


///////////////////////////////////////////////////////////////////////////////
/////  SonixJS.OBJ
/////  Maintenance the object like {0:XX, 1:YY, count:2} OR {0:{xx:XX, yy:YY}, 1:{xx:X, yy:Y}, count:2}
///////////////////////////////////////////////////////////////////////////////
SonixJS.OBJ = {
	append: function(obj, value){
		obj=obj || {count:0};
		if(typeof value == 'object'){
			obj[obj.count++] = $j.extend({}, value);
		}else{
			obj[obj.count++] = value;
		}
	},
	getIndex: function(itms, itm, key){
		for(var i=0; i<itms.count; i++){
			if(typeof key == 'undefined'){
				if(typeof this.lastIdx != 'undefined'){
					if(itms[i]==itm && i>this.lastIdx) return i;
				}else{
					if(itms[i]==itm) return i;
				}
			}else{
				if(typeof this.lastIdx != 'undefined'){
					if(itms[i][key]==itm && i>this.lastIdx) return i;
				}else{
					if(itms[i][key]==itm) return i;
				}
			}
		}
		return -1;
	},
	remove: function(obj, itm, key){
		obj=obj || {count:0};
		if(obj.count>0){
			var idx=this.getIndex(obj, itm, key);
			if(idx>=0){
				if(idx===obj.count-1){
					delete obj[idx];
				}else{
					for(var i=idx; i<obj.count-1; i++) obj[i]=obj[i+1];
					delete obj[obj.count-1];
				}
				obj.count--;
			}
		}
	},
	removeAll: function(obj, itm, key){
		obj=obj || {count:0};
		while(obj.count>0 && this.getIndex(obj, itm, key)>=0){
			this.remove(obj, itm, key);
		}
	},
	update: function(obj, itm, newValue, key){
		obj=obj || {count:0};
		if(obj.count>0){
			var idx=this.getIndex(obj, itm, key);
			if(typeof this.lastIdx != 'undefined') this.lastIdx=idx;
			if(idx>=0){
				if(typeof newValue == 'object'){
					obj[idx]=$j.extend({}, obj[idx], newValue);
				}else{
					obj[idx]=newValue;
				}
			}
		}
	},
	updateAll: function(obj, itm, newValue, key){
		obj=obj || {count:0};
		this.lastIdx=-1;
		while(obj.count>0 && this.getIndex(obj, itm, key)>=0){
			this.update(obj, itm, newValue, key);
		}
		delete this.lastIdx;
	},
	get: function(obj, itm, key){
		obj=obj || {count:0};
		if(obj.count>0){
			var idx=this.getIndex(obj, itm, key);
			if(idx>=0){
				return obj[idx];
			}
		}
		return undefined;
	}
};



///////////////////////////////////////////////////////////////////////////////
//// SonixJS.SETTING
//// rs=[{},{name:'XXX', pagenumber:YYY, value:'ZZZ'},...,{}]
///////////////////////////////////////////////////////////////////////////////
SonixJS.SETTING = function(rs){
	for(var i=0, l=rs.length; i<l; i++){
		if(typeof(this[rs[i].name]) == 'undefined') this[rs[i].name] = {};
		this[rs[i].name][rs[i].pagenumber] = rs[i].value;
	}
	
	this.get = function(key, subkey){
		if(this[key] && this[key][subkey]){
			return this[key][subkey];
		}
		return undefined;
	}
};

///////////////////////////////////////////////////////////////////////////////
//// Inherits
///////////////////////////////////////////////////////////////////////////////
/*
function Person(n,race){ 
	this.constructor.population++;
	// ************************************************************************ 
	// PRIVATE VARIABLES AND FUNCTIONS 
	// ONLY PRIVELEGED METHODS MAY VIEW/EDIT/INVOKE 
	// *********************************************************************** 
	var alive=true, age=1;
	var maxAge=70+Math.round(Math.random()*15)+Math.round(Math.random()*15);
	
	function makeOlder(){return alive = (++age <= maxAge)} 

	var myName=n?n:"John Doe";
	var weight=1;


	// ************************************************************************ 
	// PRIVILEGED METHODS 
	// MAY BE INVOKED PUBLICLY AND MAY ACCESS PRIVATE ITEMS 
	// MAY NOT BE CHANGED; MAY BE REPLACED WITH PUBLIC FLAVORS 
	// ************************************************************************ 
	this.toString=this.getName=function(){return myName} 

	this.eat=function(){ 
		if(makeOlder()){ 
			this.dirtFactor++;
			return weight*=3;
		}else alert(myName+" can't eat, he's dead!");
	} 
	this.exercise=function(){ 
		if(makeOlder()){ 
			this.dirtFactor++;
			return weight/=2;
		}else alert(myName+" can't exercise, he's dead!");
	} 
	this.weigh=function(){return weight} 
	this.getRace=function(){return race} 
	this.getAge=function(){return age} 
	this.muchTimePasses=function(){age+=50; this.dirtFactor=10;} 


	// ************************************************************************ 
	// PUBLIC PROPERTIES -- ANYONE MAY READ/WRITE 
	// ************************************************************************ 
	this.clothing="nothing/naked";
	this.dirtFactor=0;
} 

// ************************************************************************ 
// PUBLIC METHODS -- ANYONE MAY READ/WRITE 
// ************************************************************************ 
Person.prototype.beCool=function(){this.clothing="khakis and black shirt"} 
Person.prototype.shower=function(){this.dirtFactor=2} 
Person.prototype.showLegs=function(){alert(this+" has "+this.legs+" legs")} 
Person.prototype.amputate=function(){this.legs--} 

// ************************************************************************ 
// PROTOTYOPE PROERTIES -- ANYONE MAY READ/WRITE (but may be overridden) 
// ************************************************************************ 
Person.prototype.legs=2;

// ************************************************************************ 
// STATIC PROPERTIES -- ANYONE MAY READ/WRITE 
// ************************************************************************ 
Person.population = 0;

// Here is the code that uses the Person class 
function RunGavinsLife(){ 
	var gk=new Person("Gavin","caucasian");       //New instance of the Person object created. 
	var lk=new Person("Lisa","caucasian");        //New instance of the Person object created. 
	alert("There are now "+Person.population+" people");

	gk.showLegs(); lk.showLegs();                 //Both share the common 'Person.prototype.legs' variable when looking at 'this.legs' 

	gk.race = "hispanic";                         //Sets a public variable, but does not overwrite private 'race' variable. 
	alert(gk+"'s real race is "+gk.getRace());    //Returns 'caucasian' from private 'race' variable set at create time. 
	gk.eat(); gk.eat(); gk.eat();                 //weight is 3...then 9...then 27 
	alert(gk+" weighs "+gk.weigh()+" pounds and has a dirt factor of "+gk.dirtFactor);

	gk.exercise();                                //weight is now 13.5 
	gk.beCool();                                  //clothing has been update to current fashionable levels 
	gk.clothing="Pimp Outfit";                    //clothing is a public variable that can be updated to any funky value 
	gk.shower();
	alert("Existing shower technology has gotten "+gk+" to a dirt factor of "+gk.dirtFactor);

	gk.muchTimePasses();                          //50 Years Pass 
	Person.prototype.shower=function(){           //Shower technology improves for everyone 
		this.dirtFactor=0;
	} 
	gk.beCool=function(){                         //Gavin alone gets new fashion ideas 
		this.clothing="tinfoil";
	};

	gk.beCool(); gk.shower();
	alert("Fashionable "+gk+" at " 
		+gk.getAge()+" years old is now wearing " 
		+gk.clothing+" with dirt factor " 
		+gk.dirtFactor);

	gk.amputate();                                //Uses the prototype property and makes a public property 
	gk.showLegs(); lk.showLegs();                 //Lisa still has the prototype property 

	gk.muchTimePasses();                          //50 Years Pass...Gavin is now over 100 years old. 
	gk.eat();                                     //Complains about extreme age, death, and inability to eat. 
}
*/
/*Function.prototype.inheritsFrom=function(parentClassOrObject){
	if(parentClassOrObject.constructor==Function){
		//Normal Inheritance 
		this.prototype=new parentClassOrObject;
		this.prototype.constructor=this;
		this.prototype.parent=parentClassOrObject.prototype;
	}else{
		//Pure Virtual Inheritance 
		this.prototype=parentClassOrObject;
		this.prototype.constructor=this;
		this.prototype.parent=parentClassOrObject;
	}
	return this;
}*/
/*
LivingThing = { 
	beBorn : function(){ 
		this.alive = true;
	} 
} 
//
function Mammal(name){ 
	this.name=name;
	this.offspring=[];
} 
Mammal.inheritsFrom( LivingThing );
Mammal.prototype.haveABaby=function(){ 
	this.parent.beBorn.call(this);
	var newBaby = new this.constructor( "Baby " + this.name );
	this.offspring.push(newBaby);
	return newBaby;
} 
//
function Cat( name ){ 
	this.name=name;
} 
Cat.inheritsFrom( Mammal );
Cat.prototype.haveABaby=function(){ 
	var theKitten = this.parent.haveABaby.call(this);
	alert("mew!");
	return theKitten;
} 
Cat.prototype.toString=function(){ 
	return '[Cat "'+this.name+'"]';
} 
//
var felix = new Cat( "Felix" );
var kitten = felix.haveABaby( ); // mew! 
alert( kitten );                 // [Cat "Baby Felix"] 
*/
SonixJS.namespace=SonixJS.ns=function(){
	var a=arguments, o=null, i, j, d, rt;
	for (i=0; i<a.length; ++i) {
		d=a[i].split(".");
		rt = d[0];
		eval('if (typeof ' + rt + ' == "undefined"){' + rt + ' = {};} o = ' + rt + ';');
		for (j=1; j<d.length; ++j) {
			o[d[j]]=o[d[j]] || {};
			o=o[d[j]];
		}
	}
};
SonixJS.isEmpty=function(v, allowBlankString){
	return v===null || v===undefined || ((SonixJS.isArray(v) && !v.length)) || (!allowBlankString?v==='':false);
};
SonixJS.isArray=function(v){
	return Object.prototype.toString.call(v)==='[object Array]';
};
SonixJS.isObject=function(v){
	return v && typeof(v)==='object';
};
SonixJS.isPrimitive=function(v){
	var t=typeof(v);
	return t==='string' || t==='number' || t==='boolean';
};
SonixJS.isFunction=function(v){
	return typeof(v)==='function';
};
SonixJS.apply=function(o, c, defaults){
	if(defaults){
		SonixJS.apply(o, defaults);
	}
    if(o && c && SonixJS.isObject(c)){
		for(var p in c){
			o[p]=c[p];
		}
	}
	return o;
};
SonixJS.applyIf=function(o, c){
	if(o && c){
		for(var p in c){
			if(typeof(o[p])==="undefined"){
				o[p]=c[p];
			}
		}
	}
	return o;
};
SonixJS.override=function(origclass, overrides){
	if(overrides){
		var p = origclass.prototype;
		for(var method in overrides){
			p[method]=overrides[method];
		}
	}
};
SonixJS.extend=function(){
	// inline overrides
	var io = function(o){
		for(var m in o){
			this[m]=o[m];
		}
	};
	var oc = Object.prototype.constructor;

	return function(sb, sp, overrides){
		if(SonixJS.isObject(sp)){
			overrides=sp;
			sp=sb;
			sb=overrides.constructor !== oc ? overrides.constructor : function(){sp.apply(this, arguments);};
		}
		var F=function(){}, sbp, spp=sp.prototype;
		F.prototype=spp;
		sbp=sb.prototype=new F();
		sbp.constructor=sb;
		sb.superclass=spp;
		if(spp.constructor===oc){spp.constructor=sp;}
		sb.override=function(o){SonixJS.override(sb, o);};
		sbp.supperclass=sbp.supr=(function(){return spp;});
		sbp.override=io;
		SonixJS.override(sb, overrides);
		sb.extend=function(o){SonixJS.extend(sb, o);};
		return sb;
	};
}();

SonixJS.applyIf(String.prototype, {
	etc: function(cnt){
	    cnt=cnt || this.length;
    	if(cnt>=this.length){
	        return (this.length===0)?"&nbsp;":this;
    	}else{
        	return this.substr(0, cnt - 3).concat("...");
	    }
	}
});

///////////////////////////////////////////////////////////////////////////////
//// SonixJS.RSR
///////////////////////////////////////////////////////////////////////////////
SonixJS.RSR={
    name: 'SonixJS.Resources',
	bgPtrview: '/services/preview_bg.asp',
	bgPtrview75x50: '/services/preview_bg.asp?actionx=previewResized&width=1&maxX=75&maxY=50',
	bgPtrview125x100: '/services/preview_bg.asp?actionx=previewResized&width=1&maxX=125&maxY=100',
	bgPtrview250x200: '/services/preview_bg.asp?actionx=previewResized&width=1&maxX=250&maxY=200',
	bgPtrview550x300: '/services/preview_bg.asp?actionx=previewResized&width=1&maxX=550&maxY=300',
	bgPtrview750x700: '/services/preview_bg.asp?actionx=previewResized&width=1&maxX=750&maxY=700',
	styleSelector: '/creator/v8/creator-styleselector2.asp',
    version: '1.0'
};

///////////////////////////////////////////////////////////////////////////////
//// SonixJS.POPUP
///////////////////////////////////////////////////////////////////////////////
SonixJS.POPUP={
	instance: null,
	open: function(url, name, specs, replaceHistory){
		this.instance=window.open(url, name, specs, replaceHistory);
		if(SonixJS.isFunction(window.focus)) this.instance.focus();
		return false;
	},
	close: function(){
		if(this.instance){
			try{this.instance.close();}catch(e){};
		}
	}
};

///////////////////////////////////////////////////////////////////////////////
//// SonixJS.CHAT
///////////////////////////////////////////////////////////////////////////////
SonixJS.CHAT={
	openClient: function(options){
		var url=options.url || 'http://chat.wowimpression.com/chatclient.aspx',
			name=options.name || 'Chat',
			specs=options.specs || 'width=510, height=424',
			view=options.view || 'home';
			
		if(view==='creator' && jQuery.browser.msie){
			jQuery(window).unbind('beforeunload');
		}
		SonixJS.POPUP.open(url, name, specs);
		if(view==='creator' && jQuery.browser.msie){
			setTimeout(function(){
				jQuery(window).bind('beforeunload', function(event){
					var message='You will lose unsaved artwork, unless you have refreshed.';
					event.originalEvent.returnValue=message; 
				});
			}, 1000);
		}
	},
	closeClient: function(){
		SonixJS.POPUP.close();
	}
};

///////////////////////////////////////////////////////////////////////////////
//// SonixJS.Object
///////////////////////////////////////////////////////////////////////////////
SonixJS.Object={};