function popUpWindow(href,height,width) {
	if(width) w = width;
	else w = 500;
	
	if(height) h = height;
	else h = 500;
	
	
	window.open(href,"","width="+w+",height="+h+",scrollbars=1");
    return false;	
}

$(function() {
	//popup link open
	
	$('a.popUp').click(function(){
		
		$href =$(this).attr('href');
		$height = $(this).attr('height');
		$width = $(this).attr('width');
		
		popUpWindow($href,$height,$width);
		return false;
	});
	
	/*$('input[@type=text]').focus(function(){
		var currentVal = $(this).val();										// Read initial field value
		$(this).val('');														// Clear initial value

		$(this).blur(function(){
			var getNewVal = $(this).val();										// Read new input value
			if ( getNewVal == '' || getNewVal == ' ' ) {
				$(this).val(currentVal);										// Switch to initial value
			}
		});
	});*/

	// remove left border on first LI of navigator
	$("#navigator li:first").addClass("first");

	// replace
	$("p, h1, h2, h3, li, div#textbox").not("h1#logo").each(function(){
		var lookfor = $(this).html();

		if ( lookfor.indexOf("Company Formations 24-7") != -1 ) {
			var re = new RegExp("Company Formations 24-7","g");
			var newString = lookfor.replace(re,"<span class=\"cf\">Company Formations <em>24-7</em></span>");

			$(this).html(newString);
		}

		if ( lookfor.indexOf("Company Formations 24.7") != -1 ) {
			var re = new RegExp("Company Formations 24.7","g");
			var newString = lookfor.replace(re,"<span class=\"cf\">Company Formations <em>24.7</em></span>");

			$(this).html(newString);
		}
	});

	// help
	/*if ( $('img[@alt="help"]').length ) {
		$('img[@alt="help"]').tooltip({
				track: true,
		    delay: 0,
		    showURL: false,
		    showBody: " - ",
		    opacity: 0.85,
		    top: 22,
				left: 22
			});
		}*/
		
			/*// help bubbles
			$('.withhelp .helpbubble').next().children('input, textarea').focus(function(){
				
					//$(this).parent('p').prev().fadeIn();
					var fieldType = $(this).attr('type');
					var bubbleColor = $(this).parent('p').prev().attr('class');
					if ( fieldType == 'text' || fieldType == 'TEXT' || fieldType == 'password' || fieldType == 'PASSWORD' ) {
						$(this).parent('p').prev().children('.rounded').children('.innerbub').css('background-position','left 12px');
						if ( bubbleColor == 'helpbubble red' )
							$(this).css('border','1px solid #ECA8B3');
						else
							$(this).css('border','1px solid #A2A5D8');
					}
				//if($(this).val().length == 0) {
					$(this).parent('p').prev().fadeIn();
					$(this).blur(function(){
						$(this).parent('p').prev().fadeOut();
						$(this).css('border','1px solid #001B50');
					});
					$(this).change(function(){
						$(this).parent('p').prev().fadeOut();											
					});
				//}
			});	*/
			
		
});

var detect = navigator.userAgent.toLowerCase();
var os_ = navigator.platform.toLowerCase();
var browser,thestring;

if (checkIt('safari')) browser = "Safari"
else browser = "not Safari"

if ( os_ == 'macppc' || os_ == 'macintel' ) os = "Mac"
else os = "not Mac"

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
