$(document).ready(function () {
	Z.CruiseCtz = {
		init : function(tab){
			var sArray = new Array();
			var checkPopupBlocker = false;
			var winpop = new Array();
			var selectedLink = 0;
			
			var try1=false;
			
			$('#fm_cruise_destination ').val("").attr('selected',true);
			
			$('#fm_cruise_destination').change(function(){
				var a = $(this).val();
				if(a==""){
					$('div#tab-4 .result-container').fadeOut();
					$('div#tab-4 #search-btn').fadeOut();
					$('div#tab-4 #right-side-banner').fadeIn();
					$('div#tab-4 .front-banner-ctz').css({background: 'url("http://d2qcctj8epnr7y.cloudfront.net/images/marvinpogi/desc-trip-mama5.png") no-repeat scroll 0 0 transparent'});
				}else{
					$('div#tab-4 .result-container').fadeIn();
					$('div#tab-4 #search-btn').fadeIn();
					$('div#tab-4 #right-side-banner').hide();
					$('div#tab-4 .front-banner-ctz').css({background: 'url("http://fliasia.s3.amazonaws.com/widget-wide/images/desc-trip-mama6.png") no-repeat scroll 0 0 transparent'});
				}
			});
			
			
			$('div#tab-4 #btn-check-all').click(function(){
				$('div#tab-4 .chck').each(function(){
					$(this).attr('checked','checked');
					$(this).trigger('updateState'); 
					/*if($(this).is(':checked')){
						var strOptions = 'toolbar,menubar,scrollbars,resizable,location,height=' + 100 + ',width=' + 100 + ',left=' + 10 + ',top=' + 10 + ',screenX=' + 10 + ',screenY=' + 10;
						var id_ = $(this).parent()[0].id;
						var id_ = $(this).parent().parent()[0].id;
							try{
								if(winpop[id_]){
									winpop[id_].close();
								}
								winpop[id_] = window.open('', 'win_' + id_, strOptions);
								winpop[id_].blur();
								window.focus();
							}catch(e){}
					}else{
						if(winpop[id_]){
							winpop[id_].close();
						}
					}*/
				});
				$('div#tab-4 #btn-check-all').css('display','none');
				$('div#tab-4 #btn-uncheck-all').css('display','block');
				return false;
			});
			
			$('div#tab-4 #btn-uncheck-all').click(function(){
				$('div#tab-4 .chck').each(function(){
					$(this).attr('checked',false);
					$(this).trigger('updateState'); 
				});
				$('div#tab-4 #btn-uncheck-all').css('display','none');
				$('div#tab-4 #btn-check-all').css('display','block');
			});
			var supplierClick = new Array();
		   $('div#tab-4 .search-btn').click(function(){
				checkPopupBlocker = false;
				/*if(popup_blocked()) {
					alert('Please disable your pop-up blocker and click Update Trip again.');
					return false;
				}
				return false;*/
				sArray = new Array();
				$('#more-supplier').hide();
				supplierClick = new Array();
				var count_selected = 0;
				var lastItemID = '';
				
				var ii = 0;
				var exit = false;
				var searchtype = (this.id == 'search-btn') ? 'air' : 'air_hotel';
			   $('.vtip').each(function(){
					if($(this).is(":visible")){
						$(this).fadeOut('fast',function(){
							$(this).fadeIn('fast');
						});
						exit = true;
					}
			   });
			   if(exit){
				   exit = false;
				   return exit;
			   }
			   
				if($('#fm_cruise_destination').val()==""){
					alert('Please select Cruise Destination');
					$('#fm_cruise_destination').focus();
					return false;
				}
			   /*$('.chck').each(function(){
					if($(this).is(':checked')){
						var strOptions = 'toolbar,menubar,scrollbars,resizable,location,height=' + 100 + ',width=' + 100 + ',left=' + 10 + ',top=' + 10 + ',screenX=' + 10 + ',screenY=' + 10;
						//var id_ = $(this).parent()[0].id;
						var id_ = $(this).parent().parent()[0].id;
							try{
								if(winpop[id_]){
									//winpop[id_].close();
								}else{
									winpop[id_] = window.open('', 'win_' + id_, strOptions);
									winpop[id_].blur();
									window.focus();
								}
							}catch(e){}
					}else{
						if(winpop[id_]){
							winpop[id_].close();
						}
					}
				});*/
				
				//$.cookie('city1'+document.domain, city1,{ expires: null} );
				//$.cookie('city2'+document.domain, city2,{ expires: null});
				
				$('#gointo').html($("#fm_cruise_destination option:selected").text()+' '+'Departure Month: '+
					$("#fm_cruise_departure_date option:selected").text()+' Cruise Length : '+$("#fm_cruise_length option:selected").text());//092
				
				var n = $('div#tab-4 .chck:checked').length;
				if(n<1){
					$('#error2').show();
					setTimeout(function(){
						$('#error2').fadeOut('slow');
					},3500);
					return false;
				}else if(n<3){
					$('#error1').show();
					setTimeout(function(){
						$('#error1').fadeOut('slow');
					},3500);
					return false;
				}
				
				if(this.id=='search-btn-fh') {
					
				}else{
					var departureMonth = $('#fm_cruise_departure_date').val();
					var departureYear = $('#year').val();
					var destinationID = $('#fm_cruise_destination').val();
					var cruiseLengthID = $('#fm_cruise_length').val();
					
					if(destinationID!=""){
						var n = $('div#tab-4 .chck:checked').length;
						// double row window
						//var nWindowsHor = n == 4 ? 2 : n;
						//var nWindowsVer = n == 4 ? 2 : 1;
						
						// single row window
						var nWindowsHor = n;
						var nWindowsVer = 1;
						
						//var windowWidth = screen.availWidth / nWindowsHor;
						var winLeft = (10+parseInt(window.screen.availWidth / 4));
						var windowWidth =50+ (window.screen.availWidth - (60+parseInt(window.screen.availWidth / 4)))/nWindowsHor;
						var windowHeight = screen.availHeight / nWindowsVer;
						for (i = 0; i <n; i++) {
							var c = new Object;
							
							c.left = Math.floor(winLeft+((i % nWindowsHor) * windowWidth + 0.5));
								
							c.top = Math.floor(Math.floor(i / nWindowsHor) * windowHeight + 0.5);
							//c.width = Math.floor(windowWidth + 0.5);
							c.width = Math.floor(windowWidth);
							c.height = Math.floor(windowHeight + 0.5);
							sArray[i]=c;
						}
						var ii = 0;
						$('.tabs').html('');
						$('.tab_container').html('');
						
						popw = new Array();
						popX=1;
						popY=1;
						
						$('#various1').trigger('click');
						//$('#getEmail').trigger('click');
						
						$('#mb-top-check-right-selected').html('');
						$('#mb-top-check-right-unselected').html('');
						
						var count_unselected = 0;
						
						ii = 0;
						var guid = globalObj.guidGenerator();
						var to_ = $("#fm_cruise_destination option:selected").text();
						
						$('div#tab-4 ul.title-flights li div.tile').each(function(i,v){
							var obj = $(v).find('.url');
							var chk = $(v).find('.chck');
							if(obj[0] != undefined && $(chk).is(':checked')){
								//var title__ = $(v).find('.title').html();
								var title__ = $(v).find('.title').val();
								var img = $(v).find('.img').val();
								var type__ = 'Cruise';
								var _id_ = this.id;
								
								var url = obj.val();
								//var url = 'http://www.google.com/';
								var referralURL = encodeURIComponent("http://"+document.domain);
								referralURL = referralURL.replace('www.','');
								var url ="loader.php?template="+encodeURIComponent(category_name)+"&advertiser="+encodeURIComponent(title__)+"&widget_type=cruise&memberid="+memberid+"&visitor="+guid+"&to="+to_+"&url="+ encodeURIComponent("click_cruises.php?departureMonth="+departureMonth+
									"&departureYear="+departureYear+"&destinationID="+destinationID+
									"&cruiseLengthID="+cruiseLengthID+
									"&publisherID="+g_ctz+"&advertiserID="+_id_+
									"&referralURL="+referralURL);
								
								var sup = '<div class="mb-check-icon def-tab"><a id="sup-win'+
								$(this).parent()[0].id+'" href="javascript:;" class="sup"><img width="80" height="34" alt=" " src="'+img+'">'+
								'<input type="hidden" class="_url" value="'+url+'" />'+'</a>'+
								'<span class="search-type" >'+type__+'</span>'+'</div>';
								
								/*var sup = '<div class="mb-check-icon def-tab2"><a id="sup-win'+
								$(this).parent()[0].id+'" href="javascript:;" class="sup"><img width="80" height="34" alt=" " src="'+img+'">'+
								'<input type="hidden" class="_url" value="'+url+'" />'+'</a>'+
								'<span class="search-type" >'+type__+'</span>'+
								'<img class="def-tab2-img" src="http://hotels.asia.com/images/ajax-loader4.gif" />'+
								'</div>';*/
														
								$('#mb-top-check-right-selected').append(sup);
							
								if($('#dispCompare_sbs').is(':checked')===true) {
									popSBS(ii ,url, $(this).parent()[0].id,sArray);				
								}
								else{
									popStacked(ii,url, $(this).parent()[0].id);				
								}
								
								supplierClick[$(this).parent()[0].id] = false;
								ii++;
								count_selected++;
								lastItemID =$(this).parent()[0].id;
							}
						});
										
						var count_unselected = 0;
						$('div#tab-4 li div.tile').each(function(i,v){ //append unselected ads to modal popup
							//if($(this).find('.result-box-icon').is(':visible')){
								var obj = $(v).find('.url');
								var chk = $(v).find('.chck');
								var title__ = $(v).find('.title').val();
								if(obj[0] != undefined && $(chk).is(':checked')==false){
									var _id_ = this.id;
									var referralURL = encodeURIComponent("http://"+document.domain);
									referralURL = referralURL.replace('www.','');
									var type__ = 'Cruise';
										var url ="loader.php?template="+encodeURIComponent(category_name)+"&advertiser="+encodeURIComponent(title__)+"&widget_type=cruise&memberid="+memberid+"&visitor="+guid+"&to="+to_+"&url="+ encodeURIComponent("click_cruises.php?departureMonth="+departureMonth+
									"&departureYear="+departureYear+"&destinationID="+destinationID+
									"&cruiseLengthID="+cruiseLengthID+
									"&publisherID="+g_ctz+"&advertiserID="+_id_+
									"&referralURL="+referralURL);
								

									var img = $(v).find('.img').val();
									var sup = '<div class="mb-box-icon"><a id="sup-win'+
										$(this).parent()[0].id+'" href="javascript:;" class="sup-unselected"><img width="80" height="34" alt=" " src="'+img+'">'+
										'<input type="hidden" class="_url" value="'+url+'" />'+'</a>'+
										'<span class="search-type" >'+type__+'</span>'+
										'</div>';
									
									$('#mb-top-check-right-unselected').append(sup);
									count_unselected++;
								}
							//}
						});
						
						$('.mb-check-icon:last').removeClass('def-tab').addClass('active-tab');
						//$('.mb-check-icon:last').find('.def-tab2-img').hide();
						
						supplierClick[lastItemID] = true;
						
						$('#checking-sites').html('Checking '+count_selected+' sites');
						
						$('.sup').click(function(){
							$('.mb-check-icon').removeClass('active-tab');
							$('.mb-box-icon').removeClass('active-tab');
							//$(this).parent().removeClass('def-tab2');
							$(this).parent().removeClass('def-tab');
							$(this).parent().addClass('active-tab');
							
							$(this).parent().find('.def-tab2-img').hide();
							
							var id = $(this)[0].id.replace('sup-win','');
							supplierClick[id] = true;
							
							if(winpop[id]!=undefined){
								winpop[id].focus();
							}else{
								
								var url = $(this).find('._url').val();
								
								var myWidth = (screen.availWidth > 800) ? (screen.availWidth - 100) : screen.availWidth;		// if 800x600 or less, take up
								var myHeight = (screen.availHeight > 600) ? (screen.availHeight - 100) : (screen.availHeight - 70);	// the whole screen.
								
								var myTop = Math.round((screen.availHeight - myHeight) / 2)-25;
								//var winLeft = (10+parseInt(window.screen.availWidth / 4));
								//var windowWidth = window.screen.availWidth - (60+parseInt(window.screen.availWidth / 4))+50;
								var winLeft =10+parseInt($('#fancybox-wrap').css('width').replace('px',''));
								//var windowWidth = window.screen.availWidth - winLeft;
								//var windowHeight = screen.availHeight;
								var windowWidth = ( screen.width * .5 );
								var windowHeight = ( screen.height * .5 );
								var strOptions = 'toolbar=no,scrollbars=no,resizable,location,height=' + windowHeight + ',width=' +
									windowWidth + ',left=' + winLeft + ',top=' + myTop + ',screenX=' + winLeft + ',screenY=' + myTop;
								
								winpop[id] = window.open(url, 'win_'+id, strOptions);
								
							}
							
							var allClicked = true;
							for(var o =0;o<supplierClick.length;o++){
								if(supplierClick[o] == false){
									allClicked = false;
									break;
								}
							}
							if(allClicked){
								if($('#mb-top-check-right-unselected').children().length>0)
									$('#more-supplier').slideDown();
							}
							return false;
						});
						
						$('#sites-to-check').html(count_unselected+' more sites to check');
						$('.sup-unselected').click(function(i,v){
						
							$('.mb-check-icon').removeClass('active-tab');
							$('.mb-box-icon').removeClass('active-tab');
							$(this).parent().removeClass('def-tab');
							$(this).parent().addClass('active-tab');
							
							var id = $(this)[0].id.replace('sup-win','');
							var obj = $(this).find('._url');
							var url = obj.val();
								
							if(winpop[id]!=undefined){
								winpop[id].focus();
							}else{
								var myWidth = (screen.availWidth > 800) ? (screen.availWidth - 100) : screen.availWidth;		// if 800x600 or less, take up
								var myHeight = (screen.availHeight > 600) ? (screen.availHeight - 100) : (screen.availHeight - 70);	// the whole screen.
								
								var myTop = Math.round((screen.availHeight - myHeight) / 2)-25;
								//var winLeft = (10+parseInt(window.screen.availWidth / 4));
								//var windowWidth = window.screen.availWidth - (60+parseInt(window.screen.availWidth / 4))+50;
								var winLeft =10+parseInt($('#fancybox-wrap').css('width').replace('px',''));
								//var windowWidth = window.screen.availWidth - winLeft;
								//var windowHeight = screen.availHeight;
								var windowWidth = ( screen.width * .5 );
								var windowHeight = ( screen.height * .5 );
								var strOptions = 'toolbar=no,scrollbars=no,resizable,location,height=' + windowHeight + ',width=' +
									windowWidth + ',left=' + winLeft + ',top=' + myTop + ',screenX=' + winLeft + ',screenY=' + myTop;
								try {
									if(winpop[id]){
											winpop[id].focus();				
									}else{
										winpop[id] = window.open(url, 'win_'+id, strOptions);
									}
								}catch(e){return false;}
							}
							return false;
						});
						
						$('div#tab-4 .chck:checked').each(function(){
							$(this).removeAttr('checked');
							$(this).trigger('updateState'); 
						});
					}
					
					/*setTimeout(function(){
						$('.def-tab2-img:visible').each(function(){
							$(this).hide();
							$(this).parent().removeClass('def-tab2');
							$(this).parent().addClass('def-tab');
						});
					},5000);*/
				}
				return false;
		   });

		   

		$('body').append( '<p class="vtip" style="display: none" id="compare-msg-p"><img id="compare-vtipArrow" />Please select 2 sites to compare.</p>' );
		function findPosEx(obj) {
			var curleft = obj.offsetLeft || 0;
			var curtop = obj.offsetTop || 0;
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
			return {x:curleft,y:curtop};
		}

			
			function onItemSelect(e){
				var city1 = $('#city1').val();
				var city2 = $('#city2').val();
				var date1 = $('#date1').val();
				var date2 = $('#date2').val();
				
				
				pattern = new RegExp(/\(([^}]+)\)/);
				var newString1 = pattern.exec(city1);
				var newString2 = pattern.exec(city2);
				var a = (newString1!=undefined)?newString1[1]:city1
				var b = (newString2!=undefined)?newString2[1]:city2
				if(a!="" && b!="" && a!="Enter a City or Airport Code" && b!="Enter a City or Airport Code"){
					$(".chck").each(function (i) {
						if(i==1 || i==3 || i==6 || i==7 || i==8)
							$(this).attr('checked','checked');
					});
					$('div#tab-4 .result-container').fadeIn();
					$('div#tab-4 #search-btn').fadeIn();
					$('div#tab-4 #right-side-banner').hide();
					$('div#tab-4 .front-banner-ctz').css({background: 'url("http://fliasia.s3.amazonaws.com/widget-wide/images/desc-trip-mama6.png") no-repeat scroll 0 0 transparent'});
					return;
					
				}else{
					$('div#tab-4 .result-container').fadeOut();
					$('div#tab-4 #search-btn').fadeOut();
					$('div#tab-4 #right-side-banner').show(); 
					$('div#tab-4 .front-banner-ctz').css({background: 'url("http://d2qcctj8epnr7y.cloudfront.net/images/marvinpogi/desc-trip-mama5.png") no-repeat scroll 0 0 transparent'});
				}
			}
			
			function bindCheckbox(){
				$('div#tab-4 .chck').click(function(){
					if($(this).is(':checked')){
						var strOptions = 'toolbar,menubar,scrollbars,resizable,location,height=' + 100 + ',width=' + 100 + ',left=' + 10 + ',top=' + 10 + ',screenX=' + 10 + ',screenY=' + 10;
						var id_ = $(this).parent()[0].id;
							try{
								if(winpop[id_]){
									winpop[id_].close();
								}
								winpop[id_] = window.open('', 'win_' + id_, strOptions);
								winpop[id_].blur();
								window.focus();
							}catch(e){}
						//}
					}else{
						if(winpop[id_]){
							winpop[id_].close();
						}
					}
				});
			}
			bindCheckbox();
			
			
			function isDate(dateStr) {
				var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
				var matchArray = dateStr.match(datePat); // is the format ok?
				if (matchArray == null) {
					return false;
				}
				var month = matchArray[1]; // p@rse date into variables
				var day = matchArray[3];
				var year = matchArray[5];
				if (month < 1 || month > 12) { // check month range
					alert("Month must be between 1 and 12.");
					return false;
				}
				if (day < 1 || day > 31) {
					alert("Day must be between 1 and 31.");
					return false;
				}
				if ((month==4 || month==6 || month==9 || month==11) && day==31) {
					alert("Month "+month+" doesn`t have 31 days!")
					return false;
				}
				if (month == 2) { // check for february 29th
					var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
					if (day > 29 || (day==29 && !isleap)) {
						alert("February " + year + " doesn`t have " + day + " days!");
						return false;
					}
				}
				return true; // date is valid
			}
			
			//Popup Blocker Enabled
			var iid = 0;
			function popSBS (rec,url,_id) {
				var self = this;
				var topX=_sArray[rec].left;
				var topY=_sArray[rec].top;
				var sWidth = _sArray[rec].width;
				var sHeight = _sArray[rec].height;
				var strOptions = 'toolbar=no,scrollbars=no,resizable,location,height=' + sHeight + ',width=' +
					sWidth + ',left=' + topX + ',top=' + topY + ',screenX=' + topX + ',screenY=' + topY;
					
				//window.blur();
				if(winpop[_id]){
					try {
						winpop[_id].moveTo(topX, topY);
						winpop[_id].resizeTo(sWidth,sHeight);
						winpop[_id].focus();
						
						winpop[_id].location.href = url;
						winpop[_id].focus();
					}catch(e){}
				}else{
					var w = window.open(url, 'win_'+_id, strOptions);
					if(w != null || typeof(w)!='undefined'){
						winpop[_id] = w;
					}else{
						//alert('sss');
					}
					//winpop[_id] = window.open(url, 'win_'+_id, strOptions);
					/*if(self.winpop[_id] == null || typeof(self.winpop[_id])=='undefined'){
						alert('Warning! Your Pop-Up Blocker is On.');
					}*/
					//self.winpop[_id].onclose = function (){alert('sss');}
				}
			}

			var iid2 = 0;
			function popStacked (rec,url,_id) {
				var self = this;
				var topX=200*rec;
				var topY=100*rec;
				var sWidth = 400;
				var sHeight = 400;
				var to = 100;
				if (navigator.appName == 'Microsoft Internet Explorer'){
					to = window.screenTop;
				}else if(navigator.appName == 'Netscape'){
					to = window.mozInnerScreenY;
				}else{
					to = window.outerHeight - window.innerHeight;
				}
				var myWidth = (screen.availWidth > 800) ? (screen.availWidth - 100) : screen.availWidth;		// if 800x600 or less, take up
				var myHeight = (screen.availHeight > 600) ? (screen.availHeight - 100) : (screen.availHeight - 70);	// the whole screen.
				var myLeft = Math.round((screen.availWidth - myWidth) / 2);
				var myTop = Math.round((screen.availHeight - myHeight) / 2)-25;
				to = myTop;
				
				var w1 = $('#fancybox-wrap').css('width');
				var w2 = (w1 * window.screen.availWidth / 100);
				//if (navigator.appName == ie){
					//var s =10+parseInt(window.screen.availWidth / 4);
					var s = 10+parseInt(w1);
					//topX=s+(40*rec);
					topX=s+(100*rec);
					topY=to+(20*rec);
				//}
				
				sWidth = window.screen.availWidth - topX;
				sHeight = window.screen.availHeight -  topY;
				
				sWidth = ( screen.width * .5 );
				sHeight = ( screen.height * .5 );
					
				var strOptions = 'toolbar=no,scrollbars=no,resizable,location,height=' + sHeight + ',width=' +
					sWidth + ',left=' + topX + ',top=' + topY + ',screenX=' + topX + ',screenY=' + topY;
				
				//window.blur();
				if(winpop[_id]){
					try{
						winpop[_id].moveTo(topX, topY);
						winpop[_id].resizeTo(sWidth,sHeight);
						winpop[_id].focus();
						
						winpop[_id].location.href = url;
						winpop[_id].focus();
					}catch(e){}
				}else{
					var w = window.open(url, 'win_'+_id, strOptions);
					if(checkPopupBlocker==false){
						checkPopupBlocker = true;
						var popup = window.open('','_blank','width=10, height=10, left=0, top=0,toolbar=no,scrollbars=no');
						if(popup == null || typeof(popup)=='undefined'){
							//alert('popup blocker enabled');
							$.blockUI({ message: $('#popup-blocker-msg'),
								baseZ:2000,
								css: {
									top: '41px',
									margin: '0 0 0 250px',
									border: 'none', 
									padding: '0px', 
									cursor: 'default'
								}
							});
						}else{
							popup.close();
						}
					}
					
					if(w != null || typeof(w)!='undefined'){
						winpop[_id] = w;
					}else{
						//alert('sss');
						/*$.blockUI(
						{ message: $('#subscribe-news'),
						baseZ:2000,
						css: {
						top: '41px',
						margin: '0 0 0 250px',
						border: 'none', 
						padding: '0px', 
						cursor: 'default' }}); */
					}
					//winpop[_id]= window.open(url, 'win_'+_id, strOptions);
				}
				
			}
			
			$("#various1").fancybox({
				'type':'inline',
				'showCloseButton':false,
				'autoDimensions': true, 
				'autoScale': true,
				//'width' : screen.availWidth-42,
				'height' : screen.availHeight-170,
				onClosed : function(){
					winpop = new Array();
					/*if(activeMenu == "flights")
						$('#sticky-ads').show();*/
				},
				'onComplete': function() {
					//$("#fancybox-wrap").css({'top':'20px', 'bottom':'auto'});
					$("#fancybox-wrap").css({'left':'0px','top':'0px', 'bottom':'auto'});
				},
				onStart: function(){
					$("#fancybox-wrap").css({'left':'0px !important','top':'0px !important', 'bottom':'auto'});
				}
			});
			$('#popup-close').click(function(){
				$.fancybox.close();
				/*if(activeMenu == "flights")
					$('#sticky-ads').show();*/
			});
			
			/*if(hauto!=undefined && hauto!=''){
				$('#city1').val(hfrom);
				$('#city2').val(hto);
				$('#date1').val(hdate1);
				$('#date2').val(hdate2);
				$('#adults').val(hadults);
				
				if(hflighttype=='1'){
					$('#one_way').attr('checked','checked');
				}else{
					$('#roundtrip').attr('checked','checked');
				}
				
				onItemSelect('');
			}*/
			
			$('.close12').click(function() {
				$.unblockUI();				
				return false; 
			}); 
			
			function popup_blocked() {
				var popup1 = window.open('','_blank','width=10, height=10, left=0, top=0,toolbar=no,scrollbars=no,location');
				var popup = window.open('','_blank','width=10, height=10, left=0, top=0,toolbar=no,scrollbars=no,location');
				if(popup == null || typeof(popup)=='undefined'){
					return true;
				}else{
					popup.close();
					return false;
				}
			}
			
			$('.error-notification').click(function(){
				$(this).fadeOut();
				return false;
			});
			
			$(document).keyup(function(e) {
			  if (e.keyCode == 27) {
				$.unblockUI();
			  }
			});
			
			$('.ads-img').click(function(){
				var chk = $(this).parent().find('.chck');
				if(chk.is(':checked')){
					chk.removeAttr('checked');
				}else{
					chk.attr('checked','checked');
				}
			});
			
			function getAvailablePopWin(){
				var retVal = new Array();
				for(var x=1;x<El.prepop.length;x++){
					try{
						if(El.prepop[x].location.hostname==''){
							retVal.push(x);
						}
					}catch(e){}
				}
				return retVal;
			}
		}
	}
});
