function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

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);
	this.isFirefox		= (agent.indexOf('firefox') != -1);
	this.isMozilla		= (agent.indexOf('mozilla') != -1);
	
}

function SearchBoxFix(inputId) {
	var browser = new detect();
	var str = "bombich.com";
	var input = document.getElementById(inputId);
	if (!browser.isSafari2) {
		input.value=str;
		input.onfocus = function() {
			input.value="";
			input.style.color="#000";
		};
	}

	if (browser.isIE || browser.isMozilla && !browser.isFirefox && !browser.isWin) {
		// IE, Mozilla on Mac
		input.style.fontSize = '13px';
		input.style.height = input.offsetHeight+4+'px';
		input.style.margin = '4px 10px 0px 0px';
	}

	if (browser.isFirefox) { 
		input.style.fontSize = '13px';
		input.style.height = input.offsetHeight+4+'px';
		input.style.margin = '-10px 10px 2px 0px';
		//input.style.margin-top = '-15px';
    	//input.style.margin-right = '10px';
    	//input.style.margin-bottom = '5px';
    	//input.style.margin-left = '10px';
	}

	if (browser.isSafari2) { 
		input.style.width = input.offsetWidth+28+'px';
	}

	if (browser.isWin && browser.isIE) { 
		input.style.fontSize = '13px';
		input.style.margin = '4px 10px 1px 0px';
		input.style.height = input.offsetHeight+18+'px';
		input.style.color = '#76797c';
	}

}

function getQuerystring(key, default_) {
	if (default_ == null) default_ = ""; 
	key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
	var qs = regex.exec(window.location.href);
	if (qs == null)
		return default_;
	else
		return qs[1];
}
