// edit this: the CSS selector representation of the element we want to attach the click event to
// if attaching to an <a> tag, 
var attachTo = '#leftnavbar .btn-more a';

var overlayURL;
jQuery(window).ready(
	function()
	{
		jQuery(html).appendTo(jQuery('body'));
		jQuery('<div id="mask_bob"></div>').insertBefore(jQuery('#modal_bob'));
		
		jQuery(attachTo).click(
			function(e)
			{
				if(jQuery(this).attr('href') && jQuery(this).attr('href')!=='' && jQuery(this).attr('href')!=='#')
				{
					overlayURL = jQuery(this).attr('href');
				}
				else
				{
					overlayURL = false;
				}
				
				// prevent default click action
				e.preventDefault();
				
				// fade mask in      
				jQuery('#mask_bob').fadeIn(1000);
				jQuery('#mask_bob').fadeTo("slow",0.8, function(){jQuery('#modal_Content.window').css({'display':'block'});jQuery('#mask_bob').css({height:jQuery('#overlay_bob').height() + 50 + 'px'});jQuery('html,body').animate({scrollTop: 0}, 1000);

var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {

//png fix 
jQuery('#overlay_bob input[type=image]').each(function() {
			var bgIMG = jQuery(this).attr('src');
			jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
   		jQuery(this).attr('src', 'http://www.bankonbaroda.com/images/spacer.gif')
		});
}

});
			});
			
		jQuery('#mask_bob').click(function () {  
			jQuery(this).fadeOut(1000);
	        jQuery('.window').hide();  
	    });
			
		jQuery('form#enquiry').submit(
			function(e)
			{
				e.preventDefault();
				
				jQuery.ajax({
					url: "http://www.bankonbaroda.com/process_enquiry.php",
					data: jQuery('form#enquiry').serialize(),
					dataType: 'jsonp',
					processData: false
				});
			});
		
		// center the overlay
		centerOverlay();
	});
	
// center the overlay on window ready
//jQuery(centerOverlay);
function ajaxReturn(msg)
{
	if(msg.error !== true)
	{
		// display confirmation and button to close overlay
		var link = overlayURL !== false ? overlayURL : '';
		var content = '<div id="sucessMessage"><h1 id="thank_you">Thank you!</h1><p>Your details have been safely received and someone will be in touch with you shortly ...</p><p><a href="' + link + '"><img src="http://www.bankonbaroda.com/images/continue.png" alt="Click to continue." title="Continue" /></a></p></div>';
		jQuery('form#enquiry').replaceWith(content);
		jQuery('html,body').animate({scrollTop: 0}, 1000);
		
		if (overlayURL !== false)
		{
			jQuery('#sucessMessage a').attr('href', overlayURL);
		}
		else
		{
			jQuery('#sucessMessage a').click(function(e) {
				e.preventDefault();
				jQuery('#mask_bob').fadeOut(1000);
	        	jQuery('.window').hide();  
			});
		}
	}
	else
	{
		// display error message
		var message = msg.msg;

		jQuery('div.errorMsg').html('<p class="errorMsg">' + message + '</p>');
		jQuery('html,body').animate({scrollTop: 0}, 1000);
	}
}
function centerOverlay()
{
	//Set height and width of mask
	jQuery('#mask_bob').css({'width':jQuery(window).width() + 'px','height':jQuery(document).height() + 'px'});  
	jQuery('#mask_bob').css({'top':0,'left':0});
	return jQuery('#overlay_bob').css({'left':(jQuery(window).width()/2)-(parseInt((jQuery('#overlay_bob').css('width')).replace(/px/g, ''))/2)});
}
jQuery(window).resize(centerOverlay);


var html = '<div id="modal_bob"><div id="modal_Content" class="window"><div id="overlay_bob"><form id="enquiry" action="./" method="post"><h2 id="thankYou">Thank you for your interest in Bank of Baroda</h2><p id="enquiryDetails">If you\'d like to talk to us about any of our products, leave us your details and we\'ll contact you shortly. We\'ll also let you know more about our FREE Bollywood DVD offer featuring Jab We Met and Welcome ... available with all new account openings.</p><div class="errorMsg"></div><div class="section personalDetails"><div><label for="title">Title</label><input type="text" name="title" id="title" value="" tabindex="1" /><div class="clear"></div></div><div><label for="name">Name<span class="required">*</span></label><input type="text" name="name" id="name" value="" tabindex="2" /><div class="clear"></div></div><div><label for="address1">Address</label><input type="text" name="address1" id="address1" value="" tabindex="3" /><div class="clear"></div></div><div><label for="phone">Phone<span class="required">*</span></label><input type="text" name="phone" id="phone" value="" tabindex="4" /><div class="clear"></div></div><div><label for="email">Email<span class="required">*</span></label><input type="text" name="email" id="email" value="" tabindex="5" /><div class="clear"></div></div></div><div class="section"><h2>Which products are you interested in?</h2><div><label for="product-1">Baroda Monthly/Annual</label><input name="product-1" type="checkbox" class="checkbox" id="product-1" value="product-1" /><div class="clear"></div></div><div><label for="product-2">Baroda Smart Sweep</label><input name="product-2" type="checkbox" class="checkbox" id="product-2" value="product-2" /><div class="clear"></div></div><div><label for="product-3">Baroda Flexi</label><input name="product-3" type="checkbox" class="checkbox" id="product-3" value="product-3" /><div class="clear"></div></div><div><label for="product-4">Click funds2India</label><input name="product-4" type="checkbox" class="checkbox" id="product-4" value="product-4" /><div class="clear"></div></div><div><label for="product-5">Others</label><input name="product-5" type="checkbox" class="checkbox" id="product-5" value="product-5" /><div class="clear"></div></div></div><div class="section"><div><label for="branch">Select your nearest branch</label><select name="branch" id="branch"><option value="0">&nbsp;</option><option value="1">Manchester</option><option value="2">Leicester</option><option value="3">Birmingham</option><option value="4">Tooting</option><option value="5">Kenton</option><option value="6">Wembley</option><option value="7">Southall</option><option value="8">Aldgate</option><option value="9">London Main Office - City Rd.</option></select><div class="clear"></div></div></div><div class="section"><h2>Where did you learn about Bank of Baroda</h2><div><label for="tv">TV</label><select name="tv" id="tv"><option value="0">&nbsp;</option><option value="sony">Sony</option><option value="star">Star</option><option value="zee">Zee</option><option value="b4u">B4U</option><option value="ndtv">NDTV</option><option value="aastha">Aastha</option></select><div class="clear"></div></div><div><label for="bus">Bus Poster</label><input type="checkbox" name="bus" id="bus" class="checkbox" value="bus" /><div class="clear"></div></div><div><label for="tube">Tube Poster</label><input type="checkbox" name="tube" id="tube" class="checkbox" value="tube" /><div class="clear"></div></div><div><label for="press">Press</label><select name="press" id="press"><option value="0">&nbsp;</option><option value="leicesterMercury">Leicester Mercury</option><option value="manchesterEveningNews">Manchester Evening News</option><option value="asianToday">Asian Today</option><option value="garviGujarat">Garvi Gujarat</option><option value="easternEye">Eastern Eye</option><option value="asianVoice">Asian Voice</option><option value="asianLite">Asian Lite</option><option value="asianAffairs">Asian Affairs</option><option value="indiaTodayInternational">India Today International</option><option value="others">Others</option></select><div class="clear"></div></div><div><label for="events">Events</label><select name="events" id="events"><option value="0">&nbsp;</option><option value="manchester">Manchester</option><option value="london">London</option><option value="leicester">Leicester</option><option value="birmingham">Birmingham</option></select><div class="clear"></div></div><div><label for="online">Online</label><input name="online" id="online" class="checkbox" type="checkbox" value="online" /><div class="clear"></div></div><div><label for="radio">Radio</label><input name="radio" id="radio" class="checkbox" type="checkbox" value="radio" /><div class="clear"></div></div></div><div><input type="hidden" name="act" value="enquiry" /><input type="hidden" name="redirectTo" id="redirectTo" value="" /><input class="submitDetails" src="http://www.bankonbaroda.com/images/submit-details.png" type="image" name="submit" value="submit" /></div></form></div></div>';
