$(function()
{
	$("a.group").fancybox({
		'hideOnContentClick': false,
		'autoScale': true
	});

//	$(".fade").hover(
//		function() { $(this).stop().animate({opacity: 0}, 250); }
//		,
//		function() { $(this).stop().animate({opacity: 1}, 250); }
//	);
});

$(function () {
	$('#submitBtn1').formValidator({
		onSuccess	: function() { console.log('Success!'); },
		scope		: '#form-1',
		errorDiv	: '#errorDiv1'
	});
});

PositionX = 100;
PositionY = 20; /*[[ original value: 100 ]]*/

defaultWidth  = 500;
defaultHeight = 500;

var AutoClose = true;

// Do not edit below this line...
// ================================
var IsChrome = function() {
	var userAgent = navigator.userAgent.toLowerCase();
	return /chrome/.test( userAgent );
};


if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var isChrome = IsChrome();

var features ='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;

/*
* Factory function to create a popup window to display images
* currently supports only IE, FF, Chrome
*/
var myPopupWindow = '';
function openPopupWindow(url, imageTitle, width, height)
{
	var arr = url.split(',');
	if (isIE)
	{
		var hwnd=window.open(arr[0],'win',features);
		var t = hwnd.document;
		t.open("text/html");
		var str = '<html><head><title>Loading...</title><style>body{margin:0px;}</style><scr'+'ipt src="http://code.jquery.com/jquery-latest.js"></scr'+'ipt>';
		str += '<scr'+'ipt type="text/javascript" src="http://www.startonight.com.tr/js/jquery.cross.js"></scri'+'pt>';
		str += '<link href="style.css" rel="stylesheet" type="text/css" media="all" />';
		str += '<style type="text/css">';
		str += 'a img, img { border: none 0 !important; }';
		str += '</style>';
		str += '<sc'+'ript type="text/javascript">';
		str += 'function reSizeToImage(){';
			str += 'window.resizeTo(300,300);';
			str += 'width=300-(document.body.clientWidth-document.images[0].width);';
			str += 'height=300-(document.body.clientHeight-document.images[0].height);';
			str += 'window.resizeTo(width,height);';
		str += '}';
		str += 'function doTitle(){document.title="'+imageTitle+'";}';
		str += '</sc'+'ript>';
			if (!AutoClose) { str += '</head><body bgcolor="#000000" onload="reSizeToImage();doTitle();self.focus()">'; }
			else { str += '</head><body bgcolor="#000000" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">'; } //
		str += '<a href="#"><img id="img" name="George" class="fade" src='+arr[0]+' style="background-image: url(\''+arr[1]+'\');"></a></body></html>';
		t.write(str);
		t.close();
	}
	else if (isChrome)
	{
		var hwnd=window.open(arr[0],'win',features);
		var t = hwnd.document;

		t.open("text/html");
		var str = '<html><head><title>Loading...</title><style>body{margin:0px;}</style><scr'+'ipt src="http://code.jquery.com/jquery-latest.js"></scr'+'ipt>';
		str += '<sc'+'ript type="text/javascript" src="http://www.startonight.com.tr/js/jquery.cross.js"></sc'+'ript>';
		str += '<link href="style.css" rel="stylesheet" type="text/css" media="all" />';
		str += '<style type="text/css">';
		str += 'a img, img { border: none 0; }';
		str += '</style>';
		str += '<sc'+'ript type="text/javascript">';
		str += 'function reSizeToImage(){';
			str += 'window.resizeTo(300,300);';
			str += 'width=document.images[0].width;';
			str += 'height=document.images[0].height;';
			str += 'window.resizeTo(width,height);';
		str += '}';
		str += 'function doTitle(){document.title="'+imageTitle+'";}';
		str += '</sc'+'ript>';
			if (!AutoClose) { str += '</head><body bgcolor="#000000" onload="reSizeToImage();doTitle();self.focus()">'; }
			else { str += '</head><body bgcolor="#000000" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()"'; } //
		str += '<a href="#"><img id="img" name="George" class="fade" src='+arr[0]+' style="background-image: url(\''+arr[1]+'\');"></a></body></html>';
		t.write(str);
		t.close();
	}
	/*[[ FF && the like ]]*/
	else
	{
		hwnd=window.open('about:blank','',features);
		with (hwnd.document)
		{
			writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
			writeln('<link href="style.css" rel="stylesheet" type="text/css" media="all" />');
			writeln('<script src="http://code.jquery.com/jquery-latest.js"></script>');
			writeln('<script type="text/javascript" src="http://www.startonight.com.tr/js/jquery.cross.js"></script>');
			writeln('<style type="text/css">');
			writeln('a img, img { border: none 0; }');
			writeln('</style>');
			writeln('<sc'+'ript type="text/javascript">');
			writeln('jQuery(function(){ $("a").click(function(){ return false;});});');
			writeln('</sc'+'ript>');
			writeln('<sc'+'ript type="text/javascript">');
				writeln('function reSizeToImage(){');
					writeln('window.innerWidth=document.images["George"].width;');
					writeln('window.innerHeight=document.images["George"].height;');
				writeln('}');
				writeln('function doTitle(){document.title="'+imageTitle+'";}');
			writeln('</sc'+'ript>');
			if (!AutoClose) { writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">'); }
			else { writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()" >'); } //
			writeln('<a href="#"><img id="img" name="George" class="fade" src='+arr[0]+' style="background-image: url(\''+arr[1]+'\');"></a></body></html>');
			close();
		}
	}
	if (window.focus) { hwnd.focus(); }
}
/*
* Convenience function to open the popup window
*/
function popImage(imageURL,imageTitle)
{
	return openPopupWindow(imageURL,imageTitle);
}


