/* Added Menu Functionality */
$(document).ready(function(){
$('a.jumper').each(function(){
	var link; 
	link = $(this).attr('href');
	$(this).attr('href', link+'#jump');

//    if ($(this).attr('class') != 'Home')
//        $(this).attr('href', '#');
});
/*
$('#edit-submitted-select-your-package').change(function(){
        var option;
        var opt_val;
        var opt_fee;
        option = $(this).find('option:selected').text();
        opt_val = $(this).find('option:selected').val();
        if(option == 'Small Business/Start Up Package'){ opt_fee = '2,500';}
        if(option == 'Market Penetrator Package'){ opt_fee = '7,000';}
        if(option == 'Market Dominator Package'){ opt_fee = '10,000';}
        if (option.indexOf('.') > 0){ option = 'invalid'; $('.marketing-pkg-review').hide();}
        else{
                $('.marketing-pkg-review span').each(function(){
                if($(this).attr('class') == 'pkg-name'){ $(this).html(option);}
                if($(this).attr('id') == 'pkg-initial-fee'){ $(this).html(opt_fee);}
                if($(this).attr('id') == 'pkg-month-fee'){ $(this).html(opt_val);}  });
           $('.marketing-pkg-review').show();
        }});
$('#edit-submitted-select-your-package').each(function(){
        if( document.referrer.indexOf('small-business') > 0){$(this).find('option').eq(1).attr('selected', 'selected');}
        if( document.referrer.indexOf('penetrator') > 0){$(this).find('option').eq(2).attr('selected', 'selected');}
        if( document.referrer.indexOf('dominator') > 0){$(this).find('option').eq(3).attr('selected', 'selected');}
        var option;
        var opt_val;
        var opt_fee;
        option = $(this).find('option:selected').text();
        opt_val = $(this).find('option:selected').val();
        if(option == 'Small Business/Start Up Package'){ opt_fee = '2,500';}
        if(option == 'Market Penetrator Package'){ opt_fee = '7,000';}
        if(option == 'Market Dominator Package'){ opt_fee = '10,000';}
        if (option.indexOf('.') > 0){ option = 'invalid'; $('.marketing-pkg-review').hide();}
        else{
                $('.marketing-pkg-review span').each(function(){
                if($(this).attr('class') == 'pkg-name'){ $(this).html(option);}
                if($(this).attr('id') == 'pkg-initial-fee'){ $(this).html(opt_fee);}
                if($(this).attr('id') == 'pkg-month-fee'){ $(this).html(opt_val);}  });
           $('.marketing-pkg-review').show();
        }});
*/
$('#nav > li > div').each(function(){
		$(this).hover(function(){
			$(this).parent().find('a').toggleClass('hover');
		},function(){
			$(this).parent().find('a').toggleClass('hover');
		});
});
/*
$(".seo-chart dt ul li").hover(
	function(){$(this).css('text-decoration', 'underline');}, 
	function(){$(this).css('text-decoration', 'none');}
);
$(".seo-chart dt:not(.last) span").each(function(){
	$(this).click(function(){
		$(this).toggleClass('slide-arrow-down').toggleClass('slide-arrow');
		if($(this).parent().next('dd').hasClass('show')){
			$(this).parent().next('dd').slideToggle('fast', function(){
				$(this).toggleClass('show');
			});
		}
		else{
			$(this).parent().next('dd').slideToggle('fast').toggleClass('show');
		}
	});
});
$(".seo-chart dt.last span").each(function(){
	$(this).click(function(){
		$(this).toggleClass('slide-arrow-down').toggleClass('slide-arrow');
		if($(this).parent().next('dd').hasClass('show')){
			$(this).parent().next('dd').slideToggle('fast', function(){
				$(this).toggleClass('show');
				$(".seo-chart").toggleClass('open-end');				
			});
		}
		else{
			$(".seo-chart").toggleClass('open-end');
			$(this).parent().next('dd').slideToggle('fast').toggleClass('show');
		}
	});
});

$(".seo-chart .pkg-smb").click(function(){
	var url = $(this).parent().parent().next('dd').find('a').attr('href');
	window.location = url;
	//window.location = "http://iws-v2.iwsdev.com/packages/small-business.html";
});

$(".seo-chart .pkg-mp").click(function(){
	var url = $(this).parent().parent().next('dd').find('a').attr('href');
	window.location = url;
	//window.location = "http://iws-v2.iwsdev.com/packages/market-penetrator.html";
});

$(".seo-chart .pkg-md").click(function(){
	var url = $(this).parent().parent().next('dd').find('a').attr('href');
	window.location = url;
	//window.location = "http://iws-v2.iwsdev.com/packages/market-dominator.html";
});
*/

/* get rid of dotted outline of in focus element */
for(var i in document.links)
	document.links[i].onfocus = document.links[i].blur;

/* digg this button  */
/*
	var title = $('title').html();
	var link = document.location;
	$('#SpecialOffers').css('display','block');
	//$('#tag-line + hr, #tag-line + p + hr').after('<a class="digg-link" href="http://digg.com/submit?url='+escape(link)+'&title='+escape(title)+'"> </a>');
	$('.dig-link').attr('href','http://digg.com/submit?url='+escape(link)).attr('title',escape(title));
	//$('.digg-link').css('margin', '-29px 0 20px 0').css('position', 'static').css('display','block');
	$('.digg-link').css('position', 'static').css('display','block');
	$('.offers-menu li:eq(0) a').attr('class','tab SpecialOffers active');
	$('a[href^=http://]:not([href^=http://'+location.hostname+'])').each(function(){$(this).attr('target','_blank')});
	$('.bread-box a[href=/blog/2008/imageworks-studio-launches-new-website-accordia-global-health-foundation]').each(function(){
		$(this).click(function(){return false;});
		$(this).hover(function(){$(this).css('textDecoration','none').css('cursor','text');},function(){});
	});
	$('ul#nav > li').each(function(){
		$(this).children('a:not(.portfolio)').click(function(){return false;}).attr('href', '#').css('cursor', 'default');
	});
*/



/* auto Ajax Landing Page form submissions */
/*
    $('#page.lan #sidebar form[id!="webform-client-form-837"]').each(function(i, domForm){
    	var $submit = $(domForm);
		var sfrid = $(this).attr('id');
    	$submit.submit(function(){return false;});
    	var $button = $(domForm).find('[type="submit"],[type="image"] ');
    	var $entry = $(domForm).find('[type="text"],textarea');
    	var $tarea = $(domForm).find('textarea');
    	var $drupal = $(domForm).find(':hidden');
    	var $action = $(domForm).attr('action');
    	var $container = $(domForm);
    	var $boundary = '-----------------------------1626259126772';
    	var $content_lead = '\nContent-Disposition: form-data;'
    	$button.unbind("click");
    	$(domForm).unbind("submit");
    	$button.click(function(){
    	if(validate(sfrid)==true){
    	    var $entered = '';
    		$entry.each(function(){
    			var $blah = $(this).attr('name');
    			var $blah2 = $(this).val();
    			$entered += $boundary + $content_lead + ' name="' + $blah + '"\n\n' + $blah2+'\n';
    		});
    		$drupal.each(function(){
    		    var $blah = $(this).attr('name');
    			var $blah2 = $(this).val();
    			$entered += $boundary + $content_lead + ' name="' + $blah + '"\n\n' + $blah2+'\n';
    		});
    		$entered += $boundary + '\nContent-Disposition: form-data; name="op"\n\nSubmit\n'+$boundary +'--\n\n';
    		$.ajaxSetup({contentType: 'multipart/form-data; boundary=---------------------------1626259126772', cache: false});
    		$container.fadeOut("slow"); 
			$.post($action, $entered  , function(data){
			        var $temp = data;
					$entry.css('color', '#989898');
					$tarea.css('font-weight','bold').val('Submitted. Thank you!');
					$entry.attr("disabled", "true");
					$button.attr("disabled", "true");
					$container.fadeIn("normal");}
				, "html");
			}
	    	return false;
	    });
    });
*/
/*
   $(".overview-of-services").each(function(){
		$(this).attr('href','#flash_box');
	});    
//    $(".overview-of-services").fancyZoom({directory:'/files/flash/images',closeOnClick: false, scaleImg: true});
    $(".slide form, .subscribe form").submit(function(){
    	var eml = $(this).find('input:first').val();
    	window.open('http://feedburner.google.com/fb/a/mailverify?uri=imageworks&email='+eml, 'popupwindow', 'scrollbars=yes,width=550,height=520');
    	return false;
    });
*/    
    /* sub page side bar menu animations */   
	//$("ul.e-media-menu .parent > a").toggleClass('minus');
	$("ul.e-media-menu .parent ul").css('display','none');
    $("ul#nav li > .subnav > .bg > div > ul li.parent ul").css('display','none');
	$("ul#nav li > .subnav > .bg > div > ul li.parent").each(function(){
		$(this).find('a:first').append('<span class="plus">&nbsp;</span>');
		$(this).children('a').click(function(){
			$(this).find('span.plus').toggleClass('minus');
			var count = $(this).parent().children('ul li').size();
			$(this).parent().children('ul').slideToggle(count * 150);
			return false;
		});		
	});

	$("#nav li:has(div.brand)").hover(
		function(){
			$(this).find(".brand .subnav").toggle();
		},
		function(){
			$(this).find(".brand .subnav").toggle();
		}
	);

	$("#nav .brand .subnav ul:not(.imlb) li.parent").each(function(){
		$(this).find('a:first').append('<span class="plus">&nbsp;</span>');
		$(this).children('ul').css('display','none');
		$(this).children('a').click(function(){
			$(this).find('span').toggleClass('minus');
			var count = $(this).parent().children('ul li').size();
			$(this).parent().children('ul').slideToggle(count * 150);
			return false;
		});
	});
	$("#nav .brand .subnav ul.imlb li.parent").each(function(){
		$(this).find('a:first').append('<span class="plus minus">&nbsp;</span>');	
		$(this).children('ul').show();
		$(this).children('a').click(function(){
			$(this).find('span').toggleClass('minus');
			var count = $(this).parent().children('ul li').size();
			$(this).parent().children('ul').slideToggle(count * 150);
			return false;
		});	
	});
	$("ul.e-media-menu li:has(ul)").each(function(i, domEle){
		var $kids = $(domEle).children('ul');
		var $wrap = $(domEle).children('span');
		var $alink = $(domEle).children('a');		
		$alink.click(
			function()
			{	var count = $kids.find(":hidden").size();
				if ($kids.is(":hidden")) {
		        	$kids.slideDown(count * 150);
				$alink.toggleClass('minus');
		      	}
		      	else{      	
		      		$kids.slideUp(count * 150);
		    		$(domEle).unbind('mouseover');    	
					$alink.toggleClass('minus');
		      	}
			return false; });
	});
	$(".pro-class .pro-expand a.expand")
		.each(function(){
			$(this).click(function(){
				$(this).parent().parent().find('.products').each(function(){$(this).slideToggle('fast');});
				var text = $(this).html();
				if(text != '<em>Collapse</em> [-]')
					$(this).html('<em>Collapse</em> [-]');
				else
					$(this).html('<em>Expand</em> [+]');
				return false;
		});
	});
	$(".pro-title a:not(.expand)").each(function(){ 
		$(this).click(function(){ return false; });
		$(this).css('cursor', 'text');
	});
	$(".pro-title a.expand")
		.each(function(){
			$(this).click(function(){
				$(this).parent().parent().find('.pro-desc').each(function(){$(this).slideToggle('fast');});
				var text = $(this).html();
				if(text != '[-]')
					$(this).html('[-]');
				else
					$(this).html('[+]');
				return false;
		});
	});	
	$(".pro-control .expand-all").click(function(){
			if($(this).html() == 'Expand All [+]'){
				$('.products').slideDown('fast');
				$('.pro-class .pro-expand .expand').each(function(){
					$(this).html('<em>Collapse</em> [-]');
				});
			}
			else{
				$('.products').slideUp('fast');
				$('.pro-class .pro-expand .expand').each(function(){
					$(this).html('<em>Expand</em> [+]');
				});
			}
			var text = $(this).html();
			if(text != 'Collapse All [-]')
				$(this).html('Collapse All [-]');
			else
				$(this).html('Expand All [+]');
			return false;
	});
	/* shopping cart image handling */
	$('.pro-class .hide').each(function(){
			var img_rel = $(this).attr('class').split(' ').slice(-1);
			var img_src = '';
			var img_title = '';
			$(this).find('img').each(function(){
				img_src = $(this).attr('src');
				img_title = $(this).attr('alt');
				//$(this).append('<a class="pro-image-liteup" href="'+img_src+'" rel="'+img_rel+'">sample</a>');
				$('a[rel="'+img_rel+'"]').parent().append('<a class="hide" href="'+img_src+'" title="'+img_title+'" rel="'+img_rel+'">sample</a>');
			});
			
			$('a[rel="'+img_rel+'"]:eq(0)').attr('href',img_src).attr('title',img_title);
			$('a[rel="'+img_rel+'"]:last').remove();
			
	});

/*
    $('.logo').flash({
        src: '/sites/'+location.hostname+'/files/flash/logo.swf',
	    width: 340,
    	height: 120,
    	version: '9.0.0',
		quality: 'high',
		wmode: 'transparent'
    },{ update: false });

    $('.main-flash').flash({
          src: '/sites/'+location.hostname+'/files/flash/cta-IWS.swf',
          version: '7.0.0',
		  width: 945,
		  height: 309,
          allowFullScreen: 'false',
		  base: '/sites/'+location.hostname+'/files/flash/',
		  wmode: 'opaque',		  
		  bgcolor: '#ffffff'},
		  { update: false }).children('.alt').css('display', 'none');
*/
	/* generate ticket number for additional work order form */
//	var randomnumber=Math.floor(Math.random()*90000)+10000;
//	$('#edit-submitted-ticket-number').attr('value',randomnumber);
	/*$('.box.message .messages.error ul li, .box.message .messages.error').each(function(){
		var errortext = $(this).text();
		if(errortext.indexOf('warning')!=-1){$(this).remove();}
	});*/
	//if(window.location == "http://"+document.domain+"/lounge/additional-work-order/index.html"){ window.location = window.location+"?tid="+randomnumber; }
	
	/* maintenance form hide/show options*/
	
//	$('#edit-submitted-please-select-a-support-package, #edit-submitted-please-select-a-billing-option').parent().css('display','none').find('label').css('font-weight','bold').append('<span title="This field is required." class="form-required">*</span>');
//	$("#edit-submitted-payment-method").change(function(){showopts();});
/*
	/* Menu Sounds 
	soundManager.flashVersion = 9;
	soundManager.debugMode = (window.location.toString().match(/debug=1/)?true:false); // set debug mode
	soundManager.defaultOptions.multiShot = false;
	soundManager.url = '/sites/'+location.hostname+'/themes/diamond/js_extra/soundman/swf/soundmanager2_flash9.swf';

  	$(".csp").hover(function(){
		var $hndl = $(this);
		if(soundManager.getSoundById($(this).attr('class')) == undefined){
			soundManager.stopAll();
              	sound = soundManager.createSound({
                	id: $(this).attr('class'),
                	url: '/sites/'+location.hostname+'/themes/diamond/js_extra/soundman/demo/_mp3/bass.mp3',
                	onfinish : function() {
                		sound.stop();
                		}
              	});
			sound.play($(this).attr('class'),{volume:45});
		}
		else{
			soundManager.getSoundById($(this).attr('class')).play($(this).attr('class'),{volume:45});
		}
	},function(){ soundManager.stopAll(); });

  	$(".imlb").hover(function(){
		var $hndl = $(this);
		if(soundManager.getSoundById($(this).attr('class')) == undefined){
			soundManager.stopAll();
              	sound2 = soundManager.createSound({
                	id: $(this).attr('class'),
                	url: '/sites/'+location.hostname+'/themes/diamond/js_extra/soundman/demo/_mp3/dtmf.mp3',
                	onfinish : function() {
                		sound2.stop();
                		}
              	});
			sound2.play($(this).attr('class'),{volume:45});
		}
		else{
			soundManager.getSoundById($(this).attr('class')).play($(this).attr('class'),{volume:45});
		}		
	},function(){ soundManager.stopAll();});	
*/

//peekbox rollovers
	$(".peekbox li").hover(
	function(){
		$(this).addClass('focused');
	},
	function(){
		$(this).removeClass('focused');
	}
	);
	$(".peekbox ul li a").attr('target','_blank');

/*
//accordion init code
	$("ul#slide-box").accordion({
		autoheight: false,
		header: '.opener'
	});
	$("#slide-box li:last").css('border-bottom','0 none');
	$("#page.inner1 img.slidebox-topper").attr('src','/sites/'+location.hostname+'/themes/diamond/Images/New/slidebox-top-sub.gif');
	$("#page.inner1 img.slidebox-bottom").attr('src','/sites/'+location.hostname+'/themes/diamond/Images/New/slidebox-bottom-sub.gif');
*/
/*
// service list boxes
	$('#servicelist .question a').click(function(){
		if($(this).parent().parent().hasClass('active')){
			$(this).parent().parent().find('.answer').slideToggle('normal', function(){
				$(this).parent().toggleClass('active');
			});
		}
		else{
			$(this).parent().parent().toggleClass('active');
			$(this).parent().parent().find('.answer').slideToggle();
		}
		return false;
	});	
*/
/*
//slider init code
	$("#content-slider").slider({
	handle: '.handle',
    animate: true,
    change: handleSliderChange,
    slide: handleSliderSlide
  });

	$('a.tab[href=#SpecialOffers]').html('Packages');
	$("ul.bread-crumbs li a:contains('scott's blog'), ul.bread-crumbs li a:contains('iwsadmin's blog')").html('imageworks blog');
	$('#edit-submitted-time-log-time-in-ampm-am, #edit-submitted-time-log-time-out-ampm-am, #edit-submitted-quickapply-time-ampm-am').parent().parent().parent().addClass('am-pm-radios');
	$("#edit-submitted-quickapply-date, #edit-submitted-talk-date").datepicker({dateFormat: 'DD, d MM, yy'});
	$('#edit-submitted-quickapply-time-minute').html('<option selected="selected" value="">minute</option><option value="00">00</option><option value="15">15</option><option value="30">30</option><option value="45">45</option>');
	$('#quote-box ul li a').click(function(){
		$(this).toggleClass('quote-check');
		return false;
	});
	$('#page.lan #main .web form, #page.lan #sidebar form').each(function(){
		$(this).prepend('<div class="box message"><ul><li></li></ul></div>').attr('onSubmit','return validate("'+$(this).attr('id')+'");')
	});
	$('#testimonial-slideshow').cycle({timeout:9000, speed:2000});
	$('#edit-submitted-phone-number-pdf').parent().hide();
	$('#edit-submitted-receive-a-quote-pdf-Yes').click(function(){$('#edit-submitted-phone-number-pdf').parent().show();});
	$('#edit-submitted-receive-a-quote-pdf-No').click(function(){$('#edit-submitted-phone-number-pdf').parent().hide();});
	
	$('#edit-submitted-website-hidden').parent().hide();
	$('#edit-submitted-website-hidden').parent().insertAfter("label[for='edit-submitted-areas-of-interest-Web-Site-Redesign']");
	$('#edit-submitted-areas-of-interest-Web-Site-Redesign').click(function(){$('#edit-submitted-website-hidden').parent().toggle();});
	
	$('#webform-client-form-275 #edit-submitted-brand-building').each(function(){
		$(this).parent().find('label').html("So, for your brand building-that's the initial stuff like marketing, consulting, planning, copywriting, web design, email campaigns, blogs, logos, brochures... you get the idea! What kind of budget do you have for this currently? Bear in mind that the very low end of the spectrum won't be enough for a full branding project; just a few components.")
	});
*/	
	/* request a quote form */
/*	$('input[id^="edit-submitted-strategic-planning--marketing-required-for-most-projects-Discovery-Strategic-Planning-and-Marketing"]').parent().parent().parent().parent().find('label.parent').hide();
	$('#webform-client-form-275 input[id^="edit-submitted-designing-or-rejuvenating-your-brand-Custom-Web-Design"]').parent().parent().parent().parent().addClass('twocolumn').find('label.parent').css('font-weight','bold');
	$('#webform-client-form-275 input[id^="edit-submitted-online-offline-marketing-Search-Engine-Optimization"]').parent().parent().parent().parent().addClass('twocolumn').addClass('smalltwo').find('label.parent').css('font-weight','bold');
	$('#webform-client-form-275 input[id^="edit-submitted-id-like-to-upload-an-rfp"]').parent().parent().parent().parent().find('label.parent').hide();
	$('#webform-client-form-275').parent().parent().css('margin-left','115px').css('width','590px').css('font-family','Georgia, Arial');
	$('#webform-client-form-275 input[id^="edit-submitted-id-like-to-upload-an-rfp"]').click(function(){
		$('#webform-client-form-275 #webform-component-rfp').toggle();
	});
	/* meet with us form */
/*	$('#webform-client-form-781').parent().parent().css('margin-left','115px').css('width','590px').css('font-family','Georgia, Arial');
	$('#webform-client-form-781 .form-radios').parent().find('label.parent').css('float','left');
	$('#webform-client-form-781 #edit-submitted-date').datepicker({dateFormat: 'DD, d MM, yy'}).parent().find('label').hide();
	$('#webform-client-form-781 #edit-submitted-brand-building').parent().find('label').html("What kind budget do you have for your brand building at the moment?  That's the initial stuff like marketing, consulting, planning, copywriting, web design, email campaigns, blogs, logos, brochures... you get the idea! Bear in mind that the very low end of this spectrum won't be enough for a full branding project; just for one or two components.");
	
	$('#edit-submitted-areas-of-interest-revival-Web-Site-Design ').parent().parent().parent().parent().hide();

	/*sidebar*/
	//email box blur/focus
/*	var defaultText = "enter email address here";
	$('#sidebar .free-down form input.email').blur(function(){if($(this).val() == ''){$(this).val(defaultText);}});
	$('#sidebar .free-down form input.email').focus(function(){if($(this).val() == defaultText){$(this).val('');}});
	$('#sidebar .free-down form input[type=checkbox]').click(function(){
		$('#sidebar .free-down form input[type=checkbox]').each(function(){$(this).attr('checked','');});
		$(this).attr('checked','true');
	});
	$('#sidebar .free-down .free-open').click(function(){
		$('#sidebar .free-content').slideToggle();
		return false;
	});

	/*hp tabs*/
/*	$('a.tab[href=#FreeKitsandGuides]').html('Free Kits & Guides');
	$('a.tab[href=#GetontheAList]').html('Get on the "A" List');
	
	$('.redesign .redes-img a[href="/lounge/website-revival-kit/index.html"]').parent().parent().css('background','url("images/slide-panel-new.png") no-repeat scroll 0 0');
*/	
//Work Order Functionality
/*	$("a.addrequest2").css('display','none');
	$("#edit-submitted-service-request-4, #edit-submitted-service-request-5, #edit-submitted-service-request-6, #edit-submitted-service-request-7, #edit-submitted-service-request-8, #edit-submitted-service-request-9").parent().parent().parent().css('display','none');
	$("a.addrequest").click(function(){
		$(this).css('display','none');
		$("#edit-submitted-service-request-4, #edit-submitted-service-request-5, #edit-submitted-service-request-6").parent().parent().parent().show("slow");
		$("a.addrequest2").show("slow");
		return false;
	});
	$("a.addrequest2").click(function(){
		$(this).css('display','none');
		$("#edit-submitted-service-request-7, #edit-submitted-service-request-8, #edit-submitted-service-request-9").parent().parent().parent().show("slow");
		return false;
	});
	
	$('#page p.qq_header').each(function(){
		if($('#edit-submitted-service').val()!=''){ $(this).html('Quick Quote: '+$('#edit-submitted-service').val()); }
	});
	//quick quote dialog
	/*var relt=$('a.openqq').attr('rel');
	$('#qqsuccess').dialog({autoOpen: false,height: 425,width: 400,modal: false,resizable: false,title: 'Success!',position: [490,'center'],buttons: {"Close": function() {$(this).dialog("close");}}});
	$('#quickquote').dialog({
		autoOpen: false,
		height: 425,
		width: 400,
		modal: false,
		title: relt,
		resizable: false,
		position: [490,'center'],
		buttons: {
			"Submit": function() {
				if(qq_validate()){
					var title = relt;
					var $submit = $('#quickquote form');
					$('#edit-submitted-quick-quote').attr('value',title);
			    	var $button = $submit.find('[type="submit"],[type="image"] ');
			    	var $entry = $submit.find('[type="text"],textarea, select, input.form-checkbox');
			    	var $tarea = $submit.find('textarea');
			    	var $drupal = $submit.find(':hidden');
			    	var $action = $submit.attr('action');
			    	var $boundary = '-----------------------------1626259126772';
			    	var $content_lead = '\nContent-Disposition: form-data;'
			    	$button.unbind("click");
		    	    var $entered = '';
		    		$entry.each(function(){
		    			var $blah = $(this).attr('name');
		    			var $blah2 = $(this).val();
		    			$entered += $boundary + $content_lead + ' name="' + $blah + '"\n\n' + $blah2+'\n';
		    		});
		    		$drupal.each(function(){
		    		    var $blah = $(this).attr('name');
		    			var $blah2 = $(this).val();
		    			$entered += $boundary + $content_lead + ' name="' + $blah + '"\n\n' + $blah2+'\n';
		    		});
		    		$entered += $boundary + '\nContent-Disposition: form-data; name="op"\n\nSubmit\n'+$boundary +'--\n\n';
		    		$.ajaxSetup({contentType: 'multipart/form-data; boundary=---------------------------1626259126772', cache: false});
					$.post($action, $entered  , function(data){}, "html");
					$('#quickquote').dialog("close");
					$('#qqsuccess').dialog("open");
					return false;
				}
			}, 
			"Cancel": function() {
				$(this).dialog("close");
			}
		}
	});
	
	$('a.openqq').click(function(){
		$('#quickquote').dialog("open");
		$('.ui-dialog-buttonpane button').each(function(){if($(this).html()=="Cancel"){$(this).addClass('cancel');}});
		$('#ui-dialog-title-quickquote').html('<span class="blu">Quick Quote: </span>'+relt);
		return false;
	});
	*/
/*
	$("#webform-client-form-906").addClass('servicesform');
	$('form.servicesform label.option').each(function(){
		var sinput = $(this).html();
		var gt = sinput.indexOf('>')+1;
		sinput = sinput.substring(0,gt);
		var txt = $(this).text();
		var sfor = $(this).attr('for');
		var shref = '';
		shref = $('a[name="'+sfor+'"]').attr('href');
		var labeltxt = sinput+'<a href="'+shref+'" class="serviceslink" target="_blank">'+jQuery.trim(txt)+'</a>';
		if((sfor!='edit-submitted-services-newsletter-I-want-the-IWS-newsletter!')&&(shref!='#')){
		$(this).html(labeltxt);
		}
	});
	$("form.servicesform input[id^='edit-submitted-services-newsletter']").parent().parent().parent().parent().find('label.parent').hide();
	$('a.serviceslink').each(function(){
		$(this).tooltip({ 
		    delay: 500,
		    track: true,
		    top:-53,
		    left:-3,
		    fade:100,
		    showURL: false, 
		    bodyHandler: function() { 
		        return '<p>Get Details (New Tab)</p>'; 
		    } 
		});
	});
*/	
var imghei = $('#leftnav .nav-opener img').outerHeight();
$('#leftnav .dbg').css('min-height',imghei);
$('#leftnav .ul-show').show();
$('#leftnav .nav-opener img').click(function() {
    var $marginLefty = $(this).parent().parent().parent();
    var imgsrc = $('#floating-dig .nav-opener img').attr('src');
    var imgnam = $('#floating-dig .nav-opener img').attr('name');
    $marginLefty.animate({
      marginLeft: parseInt($marginLefty.css('marginLeft'),10) == 0 ?
        -152:0
    },"normal");
    $('#floating-dig .nav-opener img').attr('src',imgnam);
    $('#floating-dig .nav-opener img').attr('name',imgsrc);
});	
$('#leftnav .e-media-menu li.parent a.online-marketing').addClass('minus').parent().find('ul').show();


//collapsible box
$('#main .collapsible .head a').click(function(){
		$(this).parent().parent().find('.collapse-cont').slideToggle();
		$(this).parent().parent().toggleClass('active');
		return false;
});

// Not need in LT -->$('#nav li a.creative').parent().find('.subnav').addClass('creative-drop').find('span.bottom-bg').html('<a href="/lounge/branding-online-marketing-combos/index.html" style="margin:8px 0 0 24px;"><img src="/Images/New/creative-packages.png"></a>');
	
$('.offers .redesign').each(function(){
	var imglink = $(this).find('.synch-menu li a').attr('href');
	$(this).find('.redes-img img').wrap('<a href="'+imglink+'">');
});
	
});
/*
	$(function() {
		$('a[rel="lightbox"]').lightBox();
		$('a.logoReel').lightBox();
		$('a[rel^="pro-"]').lightBox(); 
	});
*/
/* Menu Functionality [navigation.js] */
function initPage()
{
	var navRoot = document.getElementById("nav");
	var lis = navRoot.getElementsByTagName("li");
	for (var i=0; i<lis.length; i++)
	{
		lis[i].onmouseover = function()
		{
			this.className += " hover";
                }
		lis[i].onmouseout = function()
		{
			this.className = this.className.replace("hover","");
		}
	}
}
if (window.attachEvent && !window.opera)
	attachEvent("onload", initPage);

/* Tabs functionality [tabs.js] */
function initTabs()
{
	var sets = document.getElementsByTagName("ul");
	for (var i = 0; i < sets.length; i++)
	{
		if (sets[i].className.indexOf("tabset") != -1)
		{
			var tabs = [];
			var links = sets[i].getElementsByTagName("a");
			for (var j = 0; j < links.length; j++)
			{
				if (links[j].className.indexOf("tab") != -1)
				{
					tabs.push(links[j]);
					links[j].tabs = tabs;

					if (links[j].className.indexOf("active") != -1)
					{
						var c = document.getElementById(links[j].href.substr(links[j].href.indexOf("#") + 1));
						if (c)
							c.style.display = "block";
					}

					links[j].onclick = function ()
					{
						var c = document.getElementById(this.href.substr(this.href.indexOf("#") + 1));
						if (c)
						{
							//reset all tabs
							for (var i = 0; i < this.tabs.length; i++)
							{
								document.getElementById(this.tabs[i].href.substr(this.tabs[i].href.indexOf("#") + 1)).style.display = "none";
								this.tabs[i].className = this.tabs[i].className.replace("active", "");
							}
							this.className += " active";
							c.style.display = "block";
							return false;
						}
					}
				}
			}
		}
	}
}

if (window.addEventListener)
	window.addEventListener("load", initTabs, false);
else if (window.attachEvent)
	window.attachEvent("onload", initTabs);

	/* function for hiding and showing options in Maintenance form */
/*
	function showopts() {
		var input = document.getElementById("edit-submitted-payment-method");
            if ( input.selectedIndex == 3 ) {
                $('#edit-submitted-please-select-a-support-package, #edit-submitted-please-select-a-billing-option').parent().show('slow');
            } else {
                $('#edit-submitted-please-select-a-support-package, #edit-submitted-please-select-a-billing-option').parent().hide('slow');
            }
        }
var logocarousel_itemList = [
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-AI.png', title:'', height:'40', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-ATTUS.png', title:'', height:'147', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-BIOSCAN.png', title:'', height:'22', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-BT.png', title:'', height:'77', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-CV.png', title:'', height:'39', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-CY.png', title:'', height:'66', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-DD.png', title:'', height:'50', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-ET.png', title:'', height:'53', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-FBN.png', title:'', height:'37', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-HIS.png', title:'', height:'64', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-IR.png', title:'', height:'31', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-LA.png', title:'', height:'62', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-MAT.png', title:'', height:'61', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-MCB.png', title:'', height:'47', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-MG.png', title:'', height:'33', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-MT.png', title:'', height:'26', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-Mameluke.png', title:'', height:'35', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-OPS.png', title:'', height:'44', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-PL.png', title:'', height:'39', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-PdL.png', title:'', height:'74', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-SN.png', title:'', height:'39', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-SS.png', title:'', height:'127', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-SSI.png', title:'', height:'121', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-STO.png', title:'', height:'83', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-TI.png', title:'', height:'47', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-TL360.png', title:'', height:'128', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-WEPB.png', title:'', height:'46', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-ZAS.png', title:'', height:'42', width:'150'},
{url: 'http://iws-v2.iwsdev.com/sites/iws-v2.iwsdev.com/files/flash/logoReel/logo-bowhead-ips.png', title:'', height:'40', width:'150'}

];

 
function logocarousel_itemVisibleInCallback(carousel, item, i, state, evt)
{
    // The index() method calculates the index from a
    // given index who is out of the actual item range.
    var idx = carousel.index(i, logocarousel_itemList.length);
    carousel.add(i, logocarousel_getItemHTML(logocarousel_itemList[idx - 1]));
};
 
function logocarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
    carousel.remove(i);
    $('a.logoReel').lightBox();
};
/**
 * Item html creation helper.
 */
/*
function logocarousel_getItemHTML(item)
{
	
    return '<a href="' + item.url.replace('/logoReel','/logoReel/display').replace('.png','.jpg') + '" class="logoReel"><img src="' + item.url + '" width="150" height="'+item.height+'" alt="' + item.title + '" /></a>';
};
*/
 
$(document).ready(function() {
/*
    $('#logocarousel').jcarousel({
        wrap: 'circular',
        vertical: 'True',
        animation: 1100,
        scroll: 2, 
        itemVisibleInCallback: {onBeforeAnimation: logocarousel_itemVisibleInCallback},
        itemVisibleOutCallback: {onAfterAnimation: logocarousel_itemVisibleOutCallback}
    });
	$('a.logoReel').lightBox();   
	
	$('#flash_box').flash({
        		src: '/files/flash/iwsVid.swf',
           		width: 495,
	        	height: 285,
	        	quality: 'high',
	        	play: 'true',
				wmode: 'transparent',
				align: 'middle',
				scale: 'noscale',
				salign: '',
				loop: 'true',
                id: 'iwsVid',	
               	name: '/files/flash/iwsVid',
				allowfullscreen: 'false',
        		allowScriptAccess: 'sameDomain',
				menu: 'true',        		
        		movie: '/files/flash/iwsVid'
    	},{ update: false }).css('display', 'none');
    	
    	//$('#floating-dig').scrollFollow({speed: 500,offset: 80,relativeTo: 'top'});
*/
});
//horizontal slider functions
/*
function handleSliderChange(e, ui)
{
  var maxScroll = $("#SpecialOffers .xwrapper").attr("scrollWidth") - $("#SpecialOffers .xwrapper").width();
  $("#SpecialOffers .xwrapper").animate({scrollLeft: ui.value * (maxScroll / 100) }, 1000);
}

function handleSliderSlide(e, ui)
{
  var maxScroll = $("#SpecialOffers .xwrapper").attr("scrollWidth") - $("#SpecialOffers .xwrapper").width();
  $("#SpecialOffers .xwrapper").attr({scrollLeft: ui.value * (maxScroll / 100) });
}
*/
/*
function validate(fid){
	var frid = fid;
	var valid = true;
	$("#"+frid+" .message").hide();
	$("#"+frid+" .message ul").html('');
	$("#"+frid+" input[type='text'].required,#"+frid+" textarea.required, #"+frid+" select.required").each(function(){
		if($(this).val()==''){
			var label = $(this).parent().find('label').text();
			label = label.replace(': *', '');
			$("#"+frid+" .message ul").append('<li><strong>'+label+'</strong> field is required.</li>');valid=false;
		}
	});
	$("#"+frid+" .form-checkboxes").each(function(){
		if($(this).parent().find('label').find('span').hasClass('form-required') == true){
			if($(this).find("input[type='checkbox']:checked").length=='0'){
			var label = $(this).parent().find('label.parent').text();
			label = label.replace(': *', '');
			$("#"+frid+" .message ul").append('<li><strong>'+label+'</strong> is required.</li>');valid=false;
			}
		}
	});
	$("#"+frid+" input.email.required").each(function(){
		if(echeck($(this).val())==false){
			var label = $(this).parent().find('label').text();
			label = label.replace(': *', '');
			$("#"+frid+" .message ul").append('<li><strong>'+label+'</strong> is invalid.</li>');valid=false;
		}
	});
	
	if(frid=="webform-client-form-855"){
		if($("#edit-submitted-additional-info").val()==''){
			$("#"+frid+" .message ul").append('<li>Please tell us about your business. We neeed this insight to perform a good evaluation.</li>');valid=false;
		}
	}
	
	if(valid==false){$("#"+frid+" .message").fadeIn("fast");scroll(0,0);}
	return valid;
}
function qq_validate(){
	var qqvalid = true;
	$("#quickquote form input[type='text'].required,#quickquote form textarea.required, #quickquote form select.required").each(function(){
		if($(this).val()==''){$(this).parent().addClass('error');qqvalid=false;}
		else{$(this).parent().removeClass('error');}
	});
	$("#quickquote form .form-checkboxes").each(function(){
		if($(this).parent().find('label').find('span').hasClass('form-required') == true){
			if($(this).find("input[type='checkbox']:checked").length=='0'){$(this).parent().addClass('error');qqvalid=false;}
			else{$(this).parent().removeClass('error');}
		}
	});
	$("#quickquote form input.email").each(function(){
		var qqmail = $(this).val();
		if((qqmail=='')||(echeck(qqmail)==false)){$(this).parent().addClass('error');qqvalid=false;}
		else{$(this).parent().removeClass('error');}
	});
	return qqvalid;
}
function echeck(str){
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){ return false;	}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){  return false;	}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ return false; }
		if (str.indexOf(at,(lat+1))!=-1){ return false; }
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return false; }
		if (str.indexOf(dot,(lat+2))==-1){ return false; }
		if (str.indexOf(" ")!=-1){ return false; }
 		return true;			
}
*/
