/* ************************************************************************** **
**      $()                                                                   **
**      Extension of getElementById method                                    **
** ************************************************************************** */
function $() {
    var elems = [];
    for (var i=0; i<arguments.length; i++) {
        var elem = arguments[i];
        if (typeof elem == 'string') elem = document.getElementById(elem);
        if (arguments.length == 1) return elem;
        elems.push(elem);
    }
    return elems;
}

/* ************************************************************************** **
**      $T(myTag)                                                             **
**      Reduction of getElementByTagName method                               **
** ************************************************************************** */
Object.prototype.$T = function (t,o) {   
	o = o || document;
    return o.getElementsByTagName(t);
}

/* ************************************************************************** **
**      $c()                                                                  **
**      GetElementsByClassName                                                **
**                                                                            **
**      Arguments:                                                            **
**      myClass:    className                                                 **
**      myObject:   scope (defaults to document)                              **
**      myTag:      filter by tag (defaults to all)                           **
** ************************************************************************** */
function $c(c,o,t) { 
	o = o || document;
    if (!o.length) { o = [o]; }
    var elements = [];
    for(var i = 0; i<o.length; i++) { 
        e = o[i];
        if(e.getElementsByTagName) {
            o.children = e.getElementsByTagName(t || '*');
            for (var j = 0; j<o.children.length; j++) {
                o.child = o.children[j];
                if(o.child.className&&(new RegExp('\\b'+c+'\\b').test(o.child.className))) { elements.push(o.child); }
            }
        }
    }
    return elements;
}


/* ************************************************************************** **
**      HTMLObject                                                            **
** ************************************************************************** */

HTMLObject = function(el) {
	//if(!window.attachEvent) {return el;}
	for(property in HTMLObject) {el[property] = HTMLObject[property];}
	return el;
}

/* ************************************************************************** **
**      WhizBang                                                              **
** ************************************************************************** */

WhizBang = function(){};


/* ************************************************************************** **
**      extend(destination,source)                                            **
**      taken from prototype.js                                               **
** ************************************************************************** */

Object.extend = function(destination,source) {
	for(property in source) { destination[property] = source[property]; }
	return destination;
}

/* ************************************************************************** **
**      Class(class_name)                                                     **
** ************************************************************************** */

var Class = function() {
	return function() {this.initialize.apply(this,arguments);}
}

/* ************************************************************************** **
**      Event Addition and Removal                                            **
** ************************************************************************** */

function addEventToObject(obj, evt, func) {
    var oldhandler = obj[evt];
    obj[evt] = (typeof obj[evt] != 'function') ? func : function(){oldhandler();func();};
}

function removeEventFromObject(obj,evt) {
	var oldhandler = obj[evt];
	obj[evt] = null;
}


/* ************************************************************************** **
**      Array.push()                                                          **
**      Adds method  for older unsupported browsers                           **
** ************************************************************************** */

if (!Array.prototype.push) {
    Array.prototype.push = function(elem) {
        this[this.length] = elem;
        return this.length;
    }
}

/* ************************************************************************** **
**      Array.shift()                                                         **
**      Adds method  for older unsupported browsers                           **
** ************************************************************************** */

if (!Array.prototype.shift) {
    Array.prototype.shift = function() {
        var response = this[0];
        for (var i=0; i < this.length-1; i++) {
        this[i] = this[i + 1];
    }
    this.length--;
    return response;
    }
}

/* ************************************************************************** **
**      ajaxRequest(url,func)                                                 **
** ************************************************************************** */

function ajaxRequest(url,func) {
    if (window.XMLHttpRequest) {
        var req = new XMLHttpRequest();
        if (func) {req.onreadystatechange = function() {func(req);}}
        req.open("GET", url, true);
        if (req.setRequestHeader) {req.setRequestHeader('If-Modified-Since','Wed, 15 Nov 1995 00:00:00 GMT');}
        req.send(null);
    } else if (window.ActiveXObject) {
        isIE = true;
        try {var req = new ActiveXObject("Msxml2.XMLHTTP");}
        catch(e) {req = new ActiveXObject("Microsoft.XMLHTTP");}
        if (req) {
            if (func) {req.onreadystatechange = function() {func(req);}}
            req.open("GET", url, true);
            req.send();
        }
    }
}

/* ************************************************************************** **
**      ahah(url,target,func)                                                 **
** ************************************************************************** */

function ahah(url,target,func) {
    document.getElementById(target).innerHTML = '<img src="http://images.apple.com/jp/ilife/images/waitanimation.gif" alt="wait" width="20" height="20" border="0" id="wait">';
   if (window.XMLHttpRequest) {
       req = new XMLHttpRequest();
       req.onreadystatechange = (func) ? function(){ahahDone(target,func);} : function() {ahahDone(target);};
       req.open("GET", url, true);
       req.send(null);
   } else if (window.ActiveXObject) {
       req = new ActiveXObject("Microsoft.XMLHTTP");
       if (req) {
           req.onreadystatechange = (func) ? function(){ahahDone(target,func);} : function() {ahahDone(target);};
           req.open("GET", url, true);
           req.send();
       }
   }
}
function ahahDone(target,func) {
   if (req.readyState == 4) {
       if (req.status == 200 || req.status == 304) {
           results = req.responseText;
           document.getElementById(target).innerHTML = results;
           if (func) {func();}
       } else {
           document.getElementById(target).innerHTML="ahah error:\n" + req.statusText;
       }
   }
}

/* ************************************************************************** **
**      bind(o)                                                               **
**      binds a function to a function or object                              **
**      support for legacy bindWithArguments                                  **
** ************************************************************************** */
Function.prototype.bind = Function.prototype.bindWithArguments = function(o) {
	var __method = this;
	var args = [];
	for (var i=0,len=arguments.length-1; i<len; i++) { args[i] = arguments[i+1]; }
	return function() { __method.apply(o, args);};
};

/* ************************************************************************** **
**      scaletoheight                                                         **
** ************************************************************************** 
Object.prototype.ScaleToHeight = function(duration,startHeight,endHeight,step,func) {
	this.interval = 1; // initial interval
	this.duration = duration;
	this.step = step;
	this.setHeight = function(h) {this.style.height = h+"px"; };
	
	var delta = startHeight;
	var newHeight = startHeight;
	var time = 0;
	// quadratic easing in - accelerating from zero velocity
	// t: current time, b: beginning value, c: change in value, d: duration
	// t and d can be in frames or seconds/milliseconds
	this.quadeasein = function (t,b,c,d) {
		return c*(t/=d)*t + b;
	};
	this.quadeaseout = function (t,b,c,d) {
		return -c *(t/=d)*(t-2) + b;
	};
	this.changeHeight = function (newHeight,endHeight) {
		var changeHeightST = null;
		var stepDuration = Math.round(this.duration/this.step);
		this.duration -= stepDuration;
		//this.step--;
		if (newHeight < endHeight) {
			if(browser.isSafari) {
				this.setHeight(endHeight);
			} else {
				//	return c*(t/=d)*t + b;
				//this.step--;
				delta = (this.step > 0) ? (endHeight - newHeight)/this.step : 0;
				//newHeight = this.quadeasein(time,startHeight,delta,duration);
				//time += stepDuration;
				newHeight = Math.max(startHeight, Math.min(newHeight+delta, endHeight));
				if(newHeight > (endHeight-1)) {newHeight = endHeight;}
				this.setHeight(newHeight);
				changeHeightST = window.setTimeout(this.changeHeight.bind(this,newHeight,endHeight),stepDuration);
			}
		}
		else if (newHeight > endHeight) {
			if(browser.isSafari) {
				this.setHeight(endHeight);
			} else {
				delta = (this.step > 0) ? (newHeight - endHeight)/this.step : 0;
				
				
				//newHeight = this.quadeasein(time,startHeight,-delta,duration);
				//time += stepDuration; 
				newHeight = Math.min(startHeight, Math.max(newHeight-delta, endHeight));
				if(newHeight < (endHeight+1)) {newHeight = endHeight;}
				this.setHeight(newHeight);
				changeHeightST = window.setTimeout(this.changeHeight.bind(this,newHeight,endHeight),stepDuration);
			}
		} else if (newHeight == endHeight) {
			this.setHeight(endHeight);
			clearTimeout(changeHeightST);
			if (func) {func();}
		}
	};
	this.changeHeight(newHeight,endHeight);
}; */

/* ************************************************************************** **
**      ensureElementFromObject(el,again)                                     **
** ************************************************************************** */
function ensureElementFromObject(el,again){ // a simple IE fix
	if(!window.attachEvent) {return;} // if not IE6, return
	if(el.getAttribute('elementFromObject') != 'true' || again === true){
		for(property in Object) { el[property] = Object[property]; }
		el.setAttribute('elementFromObject','true');
	}
}

/* ************************************************************************** **
**      stopDefaultAction(ev)                                                 **
** ************************************************************************** */
function stopDefaultAction(ev) {
	if (!ev) ev = window.event;
	(ev.stopPropagation) ? ev.stopPropagation() : ev.cancelBubble = true;
	(ev.preventDefault) ? ev.preventDefault() : ev.returnValue = false;
	return false;
}

/* ************************************************************************** **
**      stopDefaultAction(ev)                                                 **
** ************************************************************************** */
function getClickedLink(ev) {
	if (!ev) ev = window.event;
	var clickedLink = (window.event) ? window.event.srcElement : ev.target;
	while (!clickedLink.tagName || clickedLink.tagName.toLowerCase() != "a") clickedLink = clickedLink.parentNode;
	return clickedLink;
}
	
/* ************************************************************************** **
**      Neat things HTMLObject can do                                         **
** ************************************************************************** */

Object.extend(HTMLObject, {
	getHeight: function() {
		return this.offsetHeight;
	},
	getWidth: function() {
		return this.offsetWidth;
	},
	getTop: function() {
		var styleValue = 0;
		var obj = this;
		if(obj.offsetParent) {
			while(obj.offsetParent) {
				styleValue += obj.offsetTop;
				obj = obj.offsetParent;
			}
		} else if(obj.x) {styleValue += obj.y;}
		return styleValue;
	},
	getLeft: function() {
		var styleValue = 0;
		var obj = this;
		if(obj.offsetParent) {
			while(obj.offsetParent) {
				styleValue += obj.offsetLeft;
				obj = obj.offsetParent;
			}
		} else if(obj.x) {styleValue += obj.x;}
		return styleValue;
	},
	getInfo: function(selector) {
		var viewCSS = (typeof document.defaultView == 'function') ? document.defaultView() : document.defaultView;
		if(viewCSS && viewCCSS.getComputedStyle) {
			var s = viewCSS.getComputedStyle(this,null);
			return s && s.getPropertyValue(selector);
		}
		return this.currentStyle && (this.currentStyle[selector] || null) || null;
	},
	addClass: function(class_name) {
		if (this.className !== '') {this.className += ' ' + class_name;}
		else {this.className = class_name;}
	},
	removeClass: function(class_name) {
		var oldClass = this.className;
		var re = new RegExp('\\s?'+class_name+'\\b');
		if (oldClass.indexOf(class_name) != -1) {this.className = oldClass.replace(re,'');}
	},
	hasClass: function(class_name) {
		var re = new RegExp('(^|\\s+)'+class_name+'(\\s+|$)');
		if (this.getAttributeNode("class") !== null) {
			return re.test(this.getAttributeNode("class").value);
		} else if (this.className){
			return re.test(this.className);
		} else {
			return false;
		}
	},
	addEvent: function(evt,func) {
		addEventToObject(this,evt,func);
	},
	removeEvent: function(evt) {
		removeEventFromObject(this,evt);
	}
});

/* ************************************************************************** **
**      AppleJAX                                                              **
** ************************************************************************** */

var AppleJAX = new Object();
Object.extend(AppleJAX, {
	ahah: function(url,target,func) {
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
			req.onreadystatechange = (func) ? function(){AppleJAX.ahahdone(target,func);} : function() {ahahDone(target);};
			req.open("GET", url, true);
			req.send(null);
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
			if (req) {
				req.onreadystatechange = (func) ? function(){AppleJAX.ahahdone(target,func);} : function() {ahahDone(target);};
				req.open("GET", url, true);
				req.send();
			}
		}
	},
	ahahdone: function(target,func) {
		if (req.readyState == 4) {
			if (req.status == 200 || req.status == 304) {
				results = req.responseText;
				$(target).innerHTML = results;
				if (func) {func();}
			} else {
				$(target).innerHTML = 'ahah error:\n' + req.statusText;
			}
		}
	},
	getXML: function(url,func) {
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
			req.onreadystatechange = function(){AppleJAX.getXMLdone(func);};
			req.open("GET", url, true);
			req.send(null);
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
			if (req) {
				req.onreadystatechange = function(){AppleJAX.getXMLdone(func);};
				req.open("GET", url, true);
				req.send();
			}
		}
	},
	getXML2: function(url,func) {
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
			if(func){req.onreadystatechange = function(){AppleJAX.getXMLdone(func);};};
			req.open("GET", url, true);
			req.send(null);
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
			if (req) {
				if(func){req.onreadystatechange = function(){AppleJAX.getXMLdone(func);};};
				req.open("GET", url, true);
				req.send();
			}
		}
	},
	getXMLdone: function(func) {
		if (req.readyState == 4) {
			results = req.responseXML;
			if (func) {func();}
		}
	},
	getXMLwithResults: function(url,func) {
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
			req.onreadystatechange = function(){AppleJAX.getXMLdoneWithResults(req,func);};
			req.open("GET", url, true);
			req.send(null);
		} else if (window.ActiveXObject) {
			var req = new ActiveXObject("Microsoft.XMLHTTP");
			if (req) {
				req.onreadystatechange = function(){AppleJAX.getXMLdoneWithResults(req,func);};
				req.open("GET", url, true);
				req.send();
			}
		}
	},
	getXMLdoneWithResults: function(req,func) {
		if (req.readyState == 4) {
			var results = req.responseXML;
			if (func) {func(results);}
		}
	}
});

/* ************************************************************************** **
**      Fade                                                                  **
** ************************************************************************** */

WhizBang.prototype.Fade = function(duration,startOpacity,endOpacity,interval,step,curve,func) {
	this.interval = interval;
	this.duration = duration;
	this.step = step;
	
	this.setOpacity = function (o) {
	    this.style.opacity = (o / 101);
	    this.style.MozOpacity = (o / 100);
	    this.style.KhtmlOpacity = (o / 100);
	    this.style.filter = "alpha(opacity=" + o + ")";
	};
	this.setOpacity(startOpacity);

	if(startOpacity == 0) {this.style.visibility = 'visible';}


	if(Browser.isIE()) {
		if(this.id == 'newfeatureinfo') {
			this.style.zIndex = '100';
			var movieframe = document.getElementById('movieframe');
			movieframe.style.height = this.offsetHeight + 'px';
		} else if(!(this.id == 'sharebug')&&!(this.id == 'newfeatureinfo')&&!(this.id == 'gallery')) {
			this.style.height = this.offsetHeight+'px';
		}
		this.style.zoom = '1';
	}
	var delta = startOpacity;
	var newOpacity = startOpacity;
	this.changeOpacity = function (newOpacity,endOpacity) {
		var changeOpacityST = null;
		
		var stepDuration = Math.round(this.duration/this.step);
		this.duration -= stepDuration;
		this.step--;
		if (newOpacity < endOpacity) {
			if (newOpacity <= endOpacity) {
				delta = (this.step > 0) ? (endOpacity - newOpacity)/this.step : 0;
				newOpacity = Math.max(startOpacity, Math.min(newOpacity+delta, endOpacity));
				this.setOpacity(newOpacity);
				changeOpacityST = window.setTimeout(this.changeOpacity.bindWithArguments(this,newOpacity,endOpacity),stepDuration);
			}
		} else if (newOpacity > endOpacity) {
			if (newOpacity >= endOpacity) {
				delta = (this.step > 0) ? (newOpacity - endOpacity)/this.step : 0;
				newOpacity = Math.min(startOpacity, Math.max(newOpacity-delta, endOpacity));
				this.setOpacity(newOpacity);
				changeOpacityST = window.setTimeout(this.changeOpacity.bindWithArguments(this,newOpacity,endOpacity),stepDuration);
			}		
		} else if (newOpacity == endOpacity) {
			this.setOpacity(newOpacity);
			clearTimeout(changeOpacityST);
			if(func) {func();}
		}
	};
	this.changeOpacity(newOpacity,endOpacity);
	return true;
};

/* ************************************************************************** **
**      ScaleToHeight                                                         **
** ************************************************************************** */

WhizBang.prototype.ScaleToHeight = function(duration,startHeight,endHeight,step,func) {
	this.interval = 1;
	this.duration = duration;
	this.step = step;
	this.setHeight = function(h) {this.style.height = h+"px"; };
	
	var delta = startHeight;
	var newHeight = startHeight;
	var time = 0;

	this.changeHeight = function (newHeight,endHeight) {
		var changeHeightST = null;
		var stepDuration = Math.round(this.duration/this.step);
		this.duration -= stepDuration;
		if (newHeight < endHeight) {
			if(Browser.isSafari1()) {
				this.setHeight(endHeight);
			} else {
				delta = (this.step > 0) ? (endHeight - newHeight)/this.step : 0;
				newHeight = Math.max(startHeight, Math.min(newHeight+delta, endHeight));
				if(newHeight > (endHeight-1)) {newHeight = endHeight;}
				this.setHeight(newHeight);
				changeHeightST = window.setTimeout(this.changeHeight.bindWithArguments(this,newHeight,endHeight),stepDuration);
			}
		}
		else if (newHeight > endHeight) {
			if(Browser.isSafari1()) {
				this.setHeight(endHeight);
			} else {
				delta = (this.step > 0) ? (newHeight - endHeight)/this.step : 0;
				newHeight = Math.min(startHeight, Math.max(newHeight-delta, endHeight));
				if(newHeight < (endHeight+1)) {newHeight = endHeight;}
				this.setHeight(newHeight);
				changeHeightST = window.setTimeout(this.changeHeight.bindWithArguments(this,newHeight,endHeight),stepDuration);
			}
		} else if (newHeight == endHeight) {
			this.setHeight(endHeight);
			clearTimeout(changeHeightST);
			if (func) {func();}
		}
	};
	this.changeHeight(newHeight,endHeight);
};

/* ************************************************************************** **
**      Scale Attribute                                                       **
** ************************************************************************** */
WhizBang.prototype.scaleAttrib = function(attribute,unit,startValue,endValue,duration,step,percent,func) {
	this.attribute = attribute;
	this.unit = unit;
	this.startValue = startValue;
	this.endValue = endValue;
	this.duration = duration;
	this.step = step;
	this.percent = percent;
	this.delta = startValue;
	this.funcpercent = Math.round((this.duration/this.step)*(this.percent/100));
	this.percentdone = 0;
	
	this.setAttrib = function(i) {this.style[this.attribute] = i+this.unit;};
	
	this.changeAttrib = function (newValue,endValue) {
		var iStepDuration = Math.round(this.duration/this.step);
		this.duration -= iStepDuration;
		this.percentdone++;
		if (newValue < endValue) {
			this.delta = (this.step > 0) ? (endValue - newValue)/this.step : 0;
			newValue = Math.max(this.startValue, Math.min(newValue+this.delta, endValue));
			if(newValue > (endValue-1)) {newValue = endValue;}
			this.setAttrib(newValue);
			var me = this;
			var changeAttribST = setTimeout(function(){me.changeAttrib(newValue,endValue);},iStepDuration);
		} else if (newValue > endValue) {
			this.delta = (this.step > 0) ? (newValue - endValue)/this.step : 0;
			newValue = Math.min(this.startValue, Math.max(newValue-this.delta, endValue));
			if(newValue < (endValue+1)) {newValue = endValue;}
			this.setAttrib(newValue);
			var me = this;
			var changeAttribST = setTimeout(function(){me.changeAttrib(newValue,endValue)},iStepDuration);
		} else if (newValue == endValue) {
			this.setAttrib(endValue);
			clearTimeout(changeAttribST);
		}
		if((this.percentdone == this.funcpercent) && func) {func();}
	};
	
	this.changeAttrib(this.startValue,this.endValue);
	return true;
};

/* ************************************************************************** **
**      Searchbox                                                             **
** ************************************************************************** */

var Searchbox = {
	init: function() {
		var boxes = document.getElementsByClassName('searchbox','','input');
		for(var i = 0, box; box = boxes[i]; i++) {
			if(!Browser.isSafari2()) {
				var str = Searchbox.getAttrValue(box,'placeholder');
				//Searchbox.setStyles(box);
				Searchbox.setBoxHeightWidth(box);
				Searchbox.setValue(box, str);
			}
		}
	},
	
	getAttrValue: function(b, a) {
		return b.getAttribute(a);
	},
	
	setValue: function(b, str) {
		b.value = str;
		b.onfocus = function(){b.value="";b.style.color="#000";};
	},
	
	setBoxHeightWidth: function(b) {
		var div = b.parentNode;
		var img1 = document.createElement('img');
		img1.setAttribute('border','0');
		img1.setAttribute('align','middle');
		img1.setAttribute('alt','');
		img1.style.height = '18px';
		img1.style.verticalAlign = 'top';
		img1.style.zIndex = '100';
		if(Browser.isIE7) { img1.setAttribute('class','srchimgs'); }
		else { img1.className = 'srchimgs'; }
		var img2 = img1.cloneNode(true);
		img1.style.width = '16px';
		img2.style.width = '9px';
		img1.setAttribute('src','http://images.apple.com/jp/ilife/images/searchleftcap20060111.gif');
		img2.setAttribute('src','http://images.apple.com/jp/ilife/images/searchrightcap20060111.gif');
		//alert('img1: '+img1.outerHTML);
		//alert('img2: '+img2.outerHTML);
		div.insertBefore(img1,b);
		div.appendChild(img2);
		
		if(Browser.isIE()) {
			b.style.width = ((div.id == 'search') ? 180 : div.offsetWidth) - (img1.width + img2.width) - 28 + 'px';
			b.style.height = ((img1.height >= img2.height) ? img1.height : img2.height) - 6 + 'px';
			b.style.marginTop = '-1px';
			//(div.id != 'search') ? b.style.marginTop = '2px' : b.style.marginTop = '-1px';
		} else {
		
			// 6px to offset padding
			b.style.width = ((div.id == 'search') ? 180 : div.offsetWidth) - (img1.width + img2.width) - 6 + 'px';
			b.style.height = ((img1.height >= img2.height) ? img1.height : img2.height) - 6 + 'px';
		
		}
		
	}
}

/* ************************************************************************** **
**      Browser                                                               **
** ************************************************************************** */

var Browser = {
	isSafari1: function() {
		var agent = navigator.userAgent.toLowerCase();
		if(agent.indexOf('safari') != -1 && !Browser.isSafari2()) {return true;}
	},
	isSafari2: function() {
		var agent = navigator.userAgent.toLowerCase();
		if(agent.indexOf('safari') != -1 && (parseFloat(agent.substring(agent.indexOf("applewebkit/")+"applewebkit/".length,agent.length).substring(0,agent.substring(agent.indexOf("applewebkit/")+"applewebkit/".length,agent.length).indexOf(' '))) >=  300)) {return true;}
	},
	isIE7: function() {
		var agent = navigator.userAgent.toLowerCase();
		if(agent.indexOf('msie 7.0') != -1) {return true;}
	},
	isIE: function() {
		var agent = navigator.userAgent.toLowerCase();
		if(agent.indexOf('msie') != -1) {return true;}
	}
};

/* ************************************************************************** **
**      Browser stuff                                                         **
** ************************************************************************** */
function detect() {
	// simplify things
	var agent 	= navigator.userAgent.toLowerCase();
	
	// detect platform
	this.isMac		= (agent.indexOf('mac') != -1);
	this.isWin		= (agent.indexOf('win') != -1);
	this.isWin2k	= (this.isWin && (
			agent.indexOf('nt 5') != -1));
	this.isWinSP2	= (this.isWin && (
			agent.indexOf('xp') != -1 || 
			agent.indexOf('sv1') != -1));
	this.isOther	= (
			agent.indexOf('unix') != -1 || 
			agent.indexOf('sunos') != -1 || 
			agent.indexOf('bsd') != -1 ||
			agent.indexOf('x11') != -1 || 
			agent.indexOf('linux') != -1);
	
	// detect browser
	this.isSafari	= (agent.indexOf('safari') != -1);
	this.isSafari2 = (this.isSafari && (parseFloat(agent.substring(agent.indexOf("applewebkit/")+"applewebkit/".length,agent.length).substring(0,agent.substring(agent.indexOf("applewebkit/")+"applewebkit/".length,agent.length).indexOf(' '))) >=  300));
	this.isOpera	= (agent.indexOf('opera') != -1);
	this.isNN		= (agent.indexOf('netscape') != -1);
	this.isIE		= (agent.indexOf('msie') != -1);
	
	// itunes compabibility
	this.isiTunesOK	= this.isMac || this.isWin2k;
}
var browser = new detect();
