/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}expires='; expires='+date.toUTCString();}var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}return cookieValue;}};

/* scip's swf script v.0.91, studio::at

Core pasted/modified from:
SWFObject v2.0 <http://code.google.com/p/swfobject/> 
Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis

*/

var sss = {
	
client: function(){
		var u = navigator.userAgent.toLowerCase(),
			p = navigator.platform.toLowerCase(),
			webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
			ie = false,
			windows = p ? /win/.test(p) : /win/.test(u),
			mac = p ? /mac/.test(p) : /mac/.test(u);
		/*@cc_on
			ie = true;
			@if (@_win32)
				windows = true;
			@elif (@_mac)
				mac = true;
			@end
		@*/
		
		return { webkit:webkit, ie:ie, win:windows, mac:mac };
}(),

playerversion: function(compare){
		var playerVersion = [0,0,0],d = null;
		if (typeof navigator.plugins != 'undefined' && typeof navigator.plugins['Shockwave Flash'] == 'object') {
			d = navigator.plugins['Shockwave Flash'].description;
			if (d) {
				d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
				playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
				playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
				playerVersion[2] = /r/.test(d) ? parseInt(d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
			}
		}
		else if (typeof window.ActiveXObject != 'undefined') {
			var a = null, fp6Crash = false;
			try {
				a = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7');
			}
			catch(e) {
				try { 
					a = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
					playerVersion = [6,0,21];
					a.AllowScriptAccess = "always";  // Introduced in fp6.0.47
				}
				catch(e) {
					if (playerVersion[0] == 6) {
						fp6Crash = true;
					}
				}
				if (!fp6Crash) {
					try {
						a = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
					}
					catch(e) {}
				}
			}
			if (!fp6Crash && a) { // a will return null when ActiveX is disabled
				try {
					d = a.GetVariable("$version");  // Will crash fp6.0.21/23/29
					if (d) {
						d = d.split(" ")[1].split(",");
						playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
					}
				}
				catch(e) {}
			}
		}	
	return playerVersion;
}(),

needxfix: function(){
				var ua = navigator.userAgent.toLowerCase();
				var ret = /msie/.test(ua) ? (parseFloat(ua.replace(/^.*windows nt (\d+(\.\d+)?).*$/, "$1"))>=5.1) : (/opera/.test(ua) && (parseInt(navigator.appVersion.charAt(0))>=9));				
				//alert(ret);
				return ret;
}(),

player: function(compare){
		var pv = this.playerversion, v = String(compare).split(".");
		v[0] = parseInt(v[0], 10);
		v[1] = (v[1]==null) ? 0 : parseInt(v[1], 10);
		v[2] = (v[2]==null) ? 0 : parseInt(v[2], 10);
		return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
},

create: function(attObj, parObj){
		var r;
		if (this.client.ie && this.client.win) { // IE, the object element and W3C DOM methods do not combine: fall back to outerHTML
			var div = document.createElement('div');
			var att = "";
			for (var i in attObj) {
				if (attObj[i] != Object.prototype[i]) { // Filter out prototype additions from other potential libraries, like Object.prototype.toJSONString = function() {}
					if (i == "data") {
						parObj.movie = attObj[i];
					}
					else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
						att += ' class="' + attObj[i] + '"';
					}
					else if (i != "classid") {
						att += ' ' + i + '="' + attObj[i] + '"';
					}
				}
			}
			var par = "";
			for (var j in parObj) {
				if (parObj[j] != Object.prototype[j]) { // Filter out prototype additions from other potential libraries
					par += '<param name="' + j + '" value="' + parObj[j] + '" />';
				}
			}
			div.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
			r = div.firstChild;
			this.fixObjectLeaks(r); // This bug affects dynamic publishing only
			delete div;
		}
		else if (this.client.webkit && this.client.webkit < 312) { // Older webkit engines ignore the object element's nested param elements: fall back to the proprietary embed element
			var e = document.createElement("embed");
			e.setAttribute("type", 'application/x-shockwave-flash');
			for (var k in attObj) {
				if (attObj[k] != Object.prototype[k]) { // Filter out prototype additions from other potential libraries
					if (k == "data") {
						e.setAttribute("src", attObj[k]);
					}
					else if (k.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
						e.setAttribute("class", attObj[k]);
					}
					else if (k != "classid") { // Filter out IE specific attribute
						e.setAttribute(k, attObj[k]);
					}
				}
			}
			for (var l in parObj) {
				if (parObj[l] != Object.prototype[l]) { // Filter out prototype additions from other potential libraries
					if (l != "movie") { // Filter out IE specific param element
						e.setAttribute(l, parObj[l]);
					}
				}
			}
			r = e;
		}
		else { // Well-behaving browsers
			var o = document.createElement('object');
			o.setAttribute("type", 'application/x-shockwave-flash');
			for (var m in attObj) {
				if (attObj[m] != Object.prototype[m]) { // Filter out prototype additions from other potential libraries
					if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
						o.setAttribute("class", attObj[m]);
					}
					else if (m != "classid") { // Filter out IE specific attribute
						o.setAttribute(m, attObj[m]);
					}
				}
			}
			for (var n in parObj) {
				if (parObj[n] != Object.prototype[n] && n != "movie") { // Filter out prototype additions from other potential libraries and IE specific param element
							var p = document.createElement("param");
							p.setAttribute("name", n);	
							p.setAttribute("value", parObj[n]);
							o.appendChild(p);
				}
			}
			r = o;
		}

		return r;
},

replace: function(el, attObj, parObj, compare){
	if(compare!=null && !this.player(compare)) return;
	if(typeof el == 'string') el = document.getElementById(el);
	var r;
	el.parentNode.replaceChild(r = this.create(attObj, parObj), el);
	return r;
},


xfix: function(elements){
	if(!this.needxfix) return;

	for (var i=0; i<elements.length; i++){
		var original = (typeof elements[i] == 'string') ? document.getElementById(elements[i]) : elements[i];
							
		if(this.client.ie && original.data) original.removeAttribute('data'); // ie only
							
		// this approach == no flashvars hack
		var clone = original.cloneNode(true);
		var dummy_div = document.createElement('div');
		dummy_div.appendChild(clone);	
		dummy_div.innerHTML = dummy_div.innerHTML;  // no more "Click to activate"
		original.parentNode.replaceChild(dummy_div.firstChild, original);
	}
	
},

hideobjects: function(){
	document.write('<style id="sss_css" type="text/css">object{ visibility: hidden; }</style>'); // hide to prevent blinking
},

showobjects: function(){
	var sss_css =  document.getElementById('sss_css');
	sss_css.disabled = true;
	sss_css.parentNode.removeChild(sss_css);
},

fixObjectLeaks: function(el) {
		if (this.client.ie && this.client.win && this.player('8.0.0')) {
			window.attachEvent("onunload", function () {
				var obj = (typeof el == 'string') ? document.getElementById(el) : el;
				if (obj) {
					for (var i in obj) {
						if (typeof obj[i] == "function") {
							obj[i] = function() {};
						}
					}
					if(typeof obj.parentNode != 'undefined') obj.parentNode.removeChild(obj);
				}
			});
		}
}


}//ENFOF sss;

