var myPopupWindow = '';

$(document).ready(function(){

	$('img[@src$=.png]').ifixpng('/i/pixel.gif');

	$("input[@type=text], input[@type=password], select, textarea").focus(function(){
		$(this).parent().addClass('field-focused');
	});

	$("input[@type=text], input[@type=password], select, textarea").blur(function(){
		$(this).parent().removeClass('field-focused');
	});
	
	$(".confirm-link").click(function(){
		return confirm("Are you sure you wish to remove this "+$(this).attr("rel")+"?");
	});
	
	$(".back-btn").click(function(){
		if ($(this).attr("rel") != '') {
			window.location = $(this).attr("rel");
		}		
	});
		
});

function openPopupWindow(url, name, width, height)
{
    //Remove special characters from name
    name = name.replace(/\/|\-|\./gi, "");

    //Remove whitespaces from name
    var whitespace = new RegExp("\\s","g");
    name = name.replace(whitespace,"");

    //If it is already open
    if (!myPopupWindow.closed && myPopupWindow.location)
    {
        myPopupWindow.location.href = url;
    }
    else
    {
        myPopupWindow= window.open(url,name, "location=no, scrollbars=yes, resizable=yes, toolbar=no, menubar=no, width=" + width + ", height=" + height );
        if (!myPopupWindow.opener) myPopupWindow.opener = self;
    }

     //If my main window has focus - set it to the popup
    if (window.focus) {myPopupWindow.focus()}
}
