jQuery.noConflict();
(function($) {
	$(document).ready(function(){		
		/* _______________________________________________Cookie Lightbox */
		//Check to see if cookie is set and show information popup if not set
		if($.cookie('hide_popup') == null || $.cookie('hide_popup') == false){
			$.fancybox({
				'href'	: 	'#info_popup',
				'hideOnOverlayClick':false,
                'hideOnContentClick':false,
                'centerOnScroll' :true
			});
		}
		//Set the cookie on closing the lightbox
		$('a#fancybox-close').live('click', function(){
			$.cookie('hide_popup', true, { expires: 30 });
		});
		/* ___________________________________________End Cookie Lightbox */
		
		 /* $('#menuitem8').click(function(e){
		    e.preventDefault();
		});
		var n = $("#main-menu ul.nav li.main a").length;
		alert(n);
		$("li.main").hover(
		  function () {
		    $(this).next().show();
		    alert('heelo');
		  },
		  function () {
		    $(this).next().hide();
		  }
		);*/
		$("#menuitem_8 a:first").click(function(){ return false; });
		$("#menuitem_9 a:first").click(function(){ return false; });
		$("#menuitem_11 a:first").click(function(){ return false; });
		$("#menuitem_12 a:first").click(function(){ return false; });
		$("#menuitem_14 a:first").click(function(){ return false; });
		$("#menuitem_15 a:first").click(function(){ return false; });

		$('form.popup').jqTransform({imgPath:'../img/'});

		equalHeight($(".homecols"));

		// Modal galleries
		$('.screenshots-guide').parents('.csc-textpic').find('.csc-textpic-imagewrap').css({'display':'none'});
		
		//Search form init
		$('input#key-search').val('Keyword search');
		$('input#key-search').bind('focusin',focusWin);
		$('input#key-search').bind('focusout',focusLost);

		$('.screenshots-guide a').click(function(e) {
                    
			e.preventDefault();
			myOptions = {
                                header: '<div style="margin-top: 15px;"></div>',
				closeButton: '<a class="nyroModalClose" href="" title="Screenshots Guide" style="color: white;background-color: #01124f;padding: 5px;position: absolute;top: 0px;right: 0px;" >Close x</a>',	// Close button HTML
			  	sizes:{
		      	 w: 820,
		         h: 740,
		         initW: 1,
		         initH: 2,
		         minW: 820,	// minimum width
		    		minH: 740,	// minimum height
		    		wMargin: 25,	// Horizontal margin
		    		hMargin: 15
		   	}
			};
			var data= $(this).parents('.csc-textpic').find('.csc-textpic-imagewrap').html();
		   $.nmData(data,myOptions);
		});
                
          	              
          	$('a.popup-link,a[href="contact-us/request-a-call-back.html"],a[href="contact-us/request-information.html"],a[href="contact-us/request-market-report.html"],a[href="contact-us/request-trading-demo.html"]').click(function(e) {
			e.preventDefault();
			myOptions = {
			  closeButton: '<a class="nyroModalClose" href="" title="Close" style="color: white;background-color: #01124f;padding: 5px;position: absolute;top: 0px;right: 0px;" >Close x</a>',	// Close button HTML
			  header: '',
			  sizes:{
				w: 627,
				h: 600,
				initW: 1,
				initH: 2,
				minW: 627,	// minimum width
				minH: 518,	// minimum height
				wMargin: 25,	// Horizontal margin
				hMargin: 15
			  },
				callbacks: {		
   					beforeShowCont: function(nm) {
                  	jQuery('.tx-powermail-pi1 form').jqTransform();
                  }
				}
			  };
			//$(this).attr('href',$(this).attr('href')+'?type=7778');
			//$(this).nm(myOptions);
			$.nmManual($(this).attr('href')+'?type=7778',myOptions);
		});
	});


})(jQuery);


	//search form function
	function focusWin() {
	    if (jQuery(this).val()=='Keyword search') {jQuery(this).val(''); }
	}
	function focusLost() {
	    if (jQuery(this).val()=='') {jQuery(this).val('Keyword search'); }
	}



function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
		var thisHeight = jQuery(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}


function ods_pm_ajax_onclick(obj,id){
	callingForm=jQuery(obj).parents('form');

	if(jQuery(callingForm).validate().form()){
	   sendInfo = jQuery(callingForm).serialize()+encodeURI('&tx_powermail_pi1[ods_pm_ajax]'+'='+id);
	   //console.log(sendInfo);
	   //submit the modal form if any:
	   if (jQuery('div.nyroModalCont').is('div')) {
   			jQuery('div.nyroModalCont').find('#'+id).css({opacity:'0.5'});
				jQuery('div.nyroModalCont').find('#'+id+'_ol').css({display:'block'});
				jQuery.ajax({
		   		url: jQuery(callingForm).attr('action'),
		   		context: jQuery('div.nyroModalCont'),
		   		dataType: 'html',
		   		data: sendInfo,
		   		success: function(data) {
						jQuery(this).find('#'+id).html(data);
						jQuery(this).find('#'+id+'_ol').css({display:'none'});
						jQuery(this).find('#'+id).css({opacity:1});
		   		}
 				}); 
	   }
	   else {
	   	   jQuery('#'+id).css({opacity:'0.5'});
				jQuery('#'+id+'_ol').css({display:'block'});
				jQuery.ajax({
		   		url: jQuery(callingForm).attr('action'),
		   		context: document.body,
		   		dataType: 'html',
		   		data: sendInfo,
		   		success: function(data) {
						jQuery('#'+id).html(data);
						jQuery('#'+id+'_ol').css({display:'none'});
						jQuery('#'+id).css({opacity:1});
		   		}
 				}); 
	   }


	}
	return false;
}


