var j=jQuery.noConflict();
j(document).ready(function(){
						   
						   
						   
	//---------- for jqery tool tip--------------
	
	
	


		
	
	//--------- end of jquery tool tip-----------

	j('.sp').change(function(){
	
	if(j(this).val()==1)
	{
		j('#yes_spouse').show();
		j('#spouse_reg1').show();
		j('#spouse_reg2').show();
		j('#spouse_reg3').show();
		j('#spouse_reg4').show();
		j('#ad_spouse').show();
	
		j('#total').html(parseInt(j('#total').html())+150);
		
		j('#tot').val(parseInt(j('#total').html())+150);
		j('#pc2').attr('disabled',false);
		j('#sf2').attr('disabled',false);
		j('#k2').attr('disabled',false);
		j('#wt1').attr('disabled',false);
		j('#wld1').attr('disabled',false);
	} 
	if(j(this).val()==0)
	{
		j('#yes_spouse').hide();
		j('#spouse_reg1').hide();
		j('#spouse_reg2').hide();
		j('#spouse_reg3').hide();
		j('#spouse_reg4').hide();
		j('#ad_spouse').hide();
		//alert(parseInt(j('#total').html())-150);
		j('#total').html(parseInt(j('#total').html())-150);
		j('#tot').val(parseInt(j('#total').html())-150);
		j('#pc2').attr('disabled',true);
		j('#sf2').attr('disabled',true);
		j('#k2').attr('disabled',true);
		j('#wt1').attr('disabled',true);
		j('#wld1').attr('disabled',true);


	}
	//alert($(this).)
	
	
	
	});
	
	
	j('.activity').click(function(){
								  
								 // alert('sdfsd');
		if (j(this).is(':checked'))
		updateCost('activity_'+j(this).attr('rel'),'incr');
		else
		updateCost('activity_'+j(this).attr('rel'),'decr');
	});
	
	
	
	
	
	
	/*j('#pc1').click(function(){
					
							
							if (j('#pc1').is(':checked'))
							{
								var s=parseInt(j('#pc_qty').html());
								var a=parseInt(j('#amount').html());
								if(s==null)
								{
									j('#pc_qty').html('1');
									a=a+125.00;
									j('#amount').html(a);
								
								}
								else
								{
									s=(s+2-1);
									j('#pc_qty').html(s);
									a=a+125.00;
									j('#amount').html(a);
								
								}
							}
							else
							{
								var u=j('#pc_qty').html();
								
								u=(u-2+1);
									j('#pc_qty').html(u);
									if(a!=0)
									{
									a=a-125;
									j('#amount').html(a);
									}
									else
									{
											
									}
								
								
							}
							
					}); */
	
	/*j('#pc2').click(function(){
					
							
							if (j('#pc2').is(':checked'))
							{
								var s=parseInt(j('#pc_qty').html());
								var a=parseInt(j('#amount').html());
								if(s==null)
								{
									j('#pc_qty').html('1');
									a=a+125.00;
									j('#amount').html(a);
								}
								else
								{
									s=(s+2-1);
									j('#pc_qty').html(s);
									a=a+125.00;
									j('#amount').html(a);
								}
							}
							else
							{
								var u=j('#pc_qty').html();
								
								u=(u-2+1);
									j('#pc_qty').html(u);
									if(a!=0)
									{
									a=a-125;
									j('#amount').html(a);
									}
								
								
							}
							
					});*/
	
	
	
});


function updateCost(mainid,s)
{
	//alert(mainid);
	//alert(s);
	var qty = 0;
	var amt = 0;
	var qtyObj =j('#'+mainid+'_unit');
	var unitAmt =parseInt(j('#'+mainid+'_unitprice').html()); 
	var amtObj =j('#'+mainid+'_amount'); 
	var totalObj=j('#total');
	var totAmt = parseInt(totalObj.html());
	var subtotalObj = j('#subtotal');
	if (s=='incr')
	{
		qty = parseInt(qtyObj.html());
		qty++;
		qtyObj.html(qty);
		amt = unitAmt*qty;
		amtObj.html(amt.toFixed(2));
		totAmt=totAmt+unitAmt;
	}
	
	if (s=='decr')
	{
		qty = parseInt(qtyObj.html());
		qty--;
		qtyObj.html(qty);
		amt = unitAmt*qty;
		amtObj.html(amt.toFixed(2));
		totAmt=totAmt-unitAmt;
	}
	totalObj.html(totAmt);
	j('#tot').val(totAmt);
	var sum = 0;
	for(var i=1;i<=5;i++)
	sum += parseInt(j('#activity_'+i+'_amount').html());
	subtotalObj.html(sum.toFixed(2));
}




var dom = (document.getElementById) ? true : false;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;

var origWidth, origHeight;
if (ns4) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

if (nodyn) { event = "nope" }
var tipFollowMouse	= true;	
var tipWidth		= 400;
var offX		 	= 0;	// how far from mouse to show tip
var offY		 	= 100; 
var tipFontFamily 	= "Verdana, arial, helvetica, sans-serif";
var tipFontSize		= "8pt";
var tipFontColor		= "#000000";
var tipBgColor		= "#DDECFF"; 
var origBgColor 		= tipBgColor; // in case no bgColor set in array
var tipBorderColor 	= "#000080";
var tipBorderWidth 	= 2;
var tipBorderStyle 	= "ridge";
var tipPadding	 	= 4;

var messages = new Array();

messages[0] = new Array('http://planmagic.com/images/plmbiz.jpg','Professional business planning software.',"#FFFFFF");
messages[1] = new Array('','<h1>State Farm Evaluating Performance</h1>George Avery<p>Please join State Farm Insurance as they discuss evaluating performance, future direction, latest information, and what is important to State Farm when it comes to customer care. There will also be an opportunity for you to ask questions. If you are on the Select Service program or desire to be on the Select Service program this is a can’t miss opportunity to understand the latest requirements of the program.</p>',"#FFFFFF");
messages[2] = new Array('','<h1>Industry Trends - The Positive Impact on Your Collision Repair Business</h1>Greg Horn<p></p>',"#FFFFFF");
messages[3] = new Array('','<h1>FIX Full Performance Claims Solution</h1>Rich Pannazzo<p>In today\'s environment relationships of trust and outstanding performance are the single most defining factors for business growth and longevity.  FIX AUTO now provides our members and insurer partners with administrative and management resources to enhance their customers experience, manage severity, reduce LAE, and minimize administrative expenses by creating self managed single point of contact DRP programs. Don’t miss this opportunity to learn how the FIX AUTO Claims Solution can answer the call for you! </p>',"#FFFFFF");
messages[4] = new Array('http://conference.fixautousa.com/images/images/enterprise - silver.jpg','<h1>How to Grow Talent from Within</h1>Enterprise Rent-a-Car<p>Learn how to capitalize on the talent within your own organization or where to find great candidates from the recognized leader in “growing from within,” Enterprise-Rent-A-Car.  In 2009, BusinessWeek Magazine named Enterprise one of the “50 Best Places to Launch A Career” for the fourth year in a row based on compensation, rapid advancement and best training programs.  Enterprise also has been recognized for its adaptation to the evolving workforce, its commitment to cross-functional training programs and for embracing social causes that matter to Gen Y.</p>',"#FFFFFF");
messages[5] = new Array('','<h1>Esurance and FIX AUTO Partnering for Success</h1>Don Finley, Tim Glenn and Dan Tessadri<p>Please join Esurance as they discuss their customer service initiatives, specifically how they affect FIX AUTO and how the ultimate experience can be delivered to the customer.  They will share their E-star vision and provide insight into company and departmental changes.  There will also be an opportunity for you to provide feedback on ways to improve the E-star program.  </p>',"#FFFFFF");
messages[6] = new Array('','<h1>The FIX AUTO System: Marketing Dealerships</h1>Keith McCrone<p>This class will explore the art of successfully marketing to a dealership and maintaining the relationship.  In this class participants will learn the FIX AUTO program for marketing to dealerships how to address the “What’s in it for me” from everyone from the dealership GM to the Parts Manager.  </p>',"#FFFFFF");
messages[7] = new Array('','<h1>State Farm Evaluating Performance</h1>George Avery<p>Please join State Farm Insurance as they discuss evaluating performance, future direction, latest information, and what is important to State Farm when it comes to customer care. There will also be an opportunity for you to ask questions. If you are on the Select Service program or desire to be on the Select Service program this is a can’t miss opportunity to understand the latest requirements of the program.</p>',"#FFFFFF");
messages[8] = new Array('','<h1>Employee Ownership – A path to success</h1>Ron Kuehn<p>In this break-out learn how to create an environment where employees share in the success of your business through ownership, teamwork and common goals. Achieve consistent and repeatable results through culture and process without creating increasingly difficult work processes.</p>',"#FFFFFF");
messages[9] = new Array('http://conference.fixautousa.com/images/images/DupontSmall.jpg','<h1>How to Make Lean Work for You in Collision Repair Today</h1>Steve Trapp and Chad Ramberg<p>This class will have you reexamine where you are with your lean implementation.  It will explore the myths around what is lean and discuss what the reality is in the organization you are in today. It will go over the 5 key principals in solving problems utilizing employees to find the solutions.  </p>',"#FFFFFF");
messages[10] = new Array('','<h1>Rethinking Shop Profits and Labor Hours Through Performance Analysis</h1>John Spoto and Scott Peirce<p>The Collision Repair industry is more dynamic than ever before. Taking a new look at your numbers can reveal some new strategies and opportunities. This class focuses on capturing "Lost Labor Hours and Improving your Bottom Line.”  In this class 3M will also show some new tools for measuring and managing labor and material costs to improve your bottom line.</p>',"#FFFFFF");
messages[11] = new Array('','<h1>Ask the President</h1>Paul Gange<p>Want to know where FIX is headed?  In this class, Paul will discuss FIX’s culture of continuous improvement, and FIX USA moving forward our strategies and opportunities. There will be opportunities to ask Paul questions and find out what member shops need to do in their businesses to prepare for thriving in the new “Normal.”</p>',"#FFFFFF");
messages[12] = new Array('','<h1>How to Convert the Online Customer </h1>Rose Rippey<p>The online customer has become more and more relevant as referral sites, such as Yelp, have become more important in today’s marketplace.  This session will look at what the online customer is looking for and what deters them from going to your place of business.</p>',"#FFFFFF");
messages[13] = new Array('','<h1>The FIX AUTO Program Marketing Insurance Agents</h1>Michelle Clark<p>This class will educate participants on the FIX AUTO Program for marketing to insurance agents.  Participants will learn how to create mutual Win/Win opportunities between the shop and the insurance agent to increase referrals.  </p>',"#FFFFFF");
messages[14] = new Array('','<h1>Shop Succession Plan Roundtable Working through the Challenges to Create Opportunities</h1><p>What is your shop’s legacy?  Do you have a solid succession plan?  Have a discussion with your peers about the challenges you are currently facing to find the opportunities you may not have uncovered with regards to the future of your business.</p>',"#FFFFFF");
messages[15] = new Array('http://conference.fixautousa.com/images/images/enterprise - silver.jpg','<h1>How to Grow Talent from Within</h1>Enterprise Rent-a-Car<p>Learn how to capitalize on the talent within your own organization or where to find great candidates from the recognized leader in “growing from within,” Enterprise-Rent-A-Car.  In 2009, BusinessWeek Magazine named Enterprise one of the “50 Best Places to Launch A Career” for the fourth year in a row based on compensation, rapid advancement and best training programs.  Enterprise also has been recognized for its adaptation to the evolving workforce, its commitment to cross-functional training programs and for embracing social causes that matter to Gen Y.</p>',"#FFFFFF");
messages[16] = new Array('','<h1>Rethinking Shop Profits and Labor Hours Through Performance Analysis</h1>John Spoto and Scott Peirce<p>The Collision Repair industry is more dynamic than ever before. Taking a new look at your numbers can reveal some new strategies and opportunities. This class focuses on capturing "Lost Labor Hours and Improving your Bottom Line.”  In this class 3M will also show some new tools for measuring and managing labor and material costs to improve your bottom line.</p>',"#FFFFFF");

messages[17] = new Array('','<h1>Vehicle Technology & Trends for 2010</h1>Instructor Gene Lopez<p>As technology evolves, keeping pace with change is important to completing a safe repair and in doing so efficiently.  Changes in vehicle makers’ repair procedures and instructions, the use of new materials, and changes in government regulations all play a contributing role in a shifting environment.  From electronic park-assist systems and collision-warning systems, to innovations in paint materials and new construction materials, keeping up with today’s technology can be seen as a challenge.  Being able to identify trends is a key to success in a world of change.</p><p>The content found in this training program pertains to industry professionals in the collision repair and insurance fields and is of interest to anyone wishing to learn more about the impact of current and future technology on collision repairs.</p>',"#FFFFFF");
messages[18] = new Array('','<h1>Wine Tasting &nbsp;&amp; Art Tour</h1>Wednesday, September 22nd<p>This half day tour gives the spouses an opportunity to spend time getting to know each other. It will also give them an inside look at the world famous artistic community of Laguna Beach. They will meet 6 to 10 of Laguna Canyon\'s Premier Artists in their private working studios. They will also have the privilege of tasting fine wines, cheese and hors d\'oeuvres at Laguna\'s famous and very own local winery.</p><ul><li>Includes wine, hors d\'oeuvres, transportation and private guide</li><li>3-4.5 hours</li><li>$125 per person</li></ul>' ,"#FFFFFF");
messages[19] = new Array('','<h1>Surf Lessons</h1>&nbsp;<p>The 2 hour lessons begin on the beach with paddle out techniques, getting into the lineup, how to "pop up" and then ride the wave.</p><ul><li>Wednesday, September 22nd 6am-8am</li><li>Includes wetsuit, surf board and instructor</li><li>2 hours</li><li>$100 per person</li></ul>',"#FFFFFF");
messages[20] = new Array('','<h1>Kayak Lessons</h1><p>The kayak lesson brings you on a tour that gives the opportunity to glide past crescentbeaches, remote coves, dramatic sea cliffs, million dollar homes, and see wildlife along the way, including pelicans, cormorants and our colony of sea lions.</p><ul><li>Thursday, September 23rd 6:30am - 8am</li><li>Includes life jackets and seat backs, lessons on the beach, and optional mask and snorkel</li><li>2 hours</li><li>$75 per adult</li></ul>', "#FFFFFF");
messages[21] = new Array('', '<h1>Wildlife and Beach Eco-Tour (Tidepool Tour)</h1>Thursday, September 23rd<p>The wildlife and beach eco-tour gives a unique opportunity to explore the wildlife that inhabits the tide pools of the Southern California coastline. Participants will also observe seals and sea lions up close, and explore the beautiful, hidden beach coves.</p><ul><li>Includes transportation, educational guide, beverage and snack</li><li>$125 per adult</li></ul>',  "#FFFFFF");

/*function doTooltip(evt,msg)
{
	alert(messages[msg]);
}*/

if (document.images) {
	var theImgs = new Array();
	for (var i=0; i<messages.length; i++) {
  	theImgs[i] = new Image();
		theImgs[i].src = messages[i][0];
  }
}

var tooltip, tipcss;
function initTip() {
	if (nodyn) return;
	tooltip = (ns4)? document.tipDiv.document: (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
	tipcss = (ns4)? document.tipDiv: tooltip.style;
	if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
		tipcss.width = tipWidth+"px";
		//alert(tipcss.width);
		tipcss.fontFamily = tipFontFamily;
		tipcss.fontSize = tipFontSize;
		tipcss.color = tipFontColor;
		tipcss.backgroundColor = tipBgColor;
		tipcss.borderColor = tipBorderColor;
		tipcss.borderWidth = tipBorderWidth+"px";
		tipcss.padding = tipPadding+"px";
		tipcss.borderStyle = tipBorderStyle;
	}
	if (tooltip&&tipFollowMouse) {
		if (ns4) document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = trackMouse;
	}
}

window.onload = initTip;

var t1,t2;	// for setTimeouts
var tipOn = false;	// check if over tooltip link
function doTooltip(evt,num) {
    var startStr = '';
    var midStr = '';
    var endStr = '';
    
    if (messages[num][0] == '')
    {
        startStr = '<div style="z-index:9999;"><table width="' + tipWidth + '">';
        midStr = '<tr><td valign="top">';
        endStr = '</td></tr></table></div>';
    }
    else
    {
        startStr = '<table width="' + tipWidth + '"><tr><td align="center" width="100%"><img src="';
        midStr = '" border="0"></td></tr><tr><td valign="top">';
        endStr = '</td></tr></table>';
    }

	if (!tooltip) return;

	if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);
	tipOn = true;
	// set colors if included in messages array
	if (messages[num][2])	var curBgColor = messages[num][2];
	else curBgColor = tipBgColor;
	if (messages[num][3])	var curFontColor = messages[num][3];
	else curFontColor = tipFontColor;
	if (ns4) {
		var tip = '<table bgcolor="' + tipBorderColor + '" width="' + tipWidth + '" cellspacing="0" cellpadding="' + tipBorderWidth + '" border="0"><tr><td><table bgcolor="' + curBgColor + '" width="100%" cellspacing="0" cellpadding="' + tipPadding + '" border="0" ><tr><td>'+ startStr;
		if (messages[num][0] == '')
		{
    		tip = tip;
		}
		else
		{
    		tip = tip + messages[num][0];
		}
		tip = tip + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr + '</td></tr></table></td></tr></table>';
		tooltip.write(tip);
		tooltip.close();
	} else if (ie4||ie5||ns5) {
		var tip = startStr;
		if (messages[num][0] == '')
		{
    		tip = tip;
		}
		else		
		{
		    tip = tip + messages[num][0];
		}
		tip = tip + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr;
		tipcss.backgroundColor = curBgColor;
	 	tooltip.innerHTML = tip;
	}
	if (!tipFollowMouse) positionTip(evt);
	else t1=setTimeout("tipcss.visibility='visible'",100);
}

var mouseX, mouseY;
function trackMouse(evt) {
	mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + (document.documentElement.scrollLeft ?   document.documentElement.scrollLeft :   document.body.scrollLeft);
	mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + (document.documentElement.scrollTop ?   document.documentElement.scrollTop :   document.body.scrollTop);
	if (tipOn) positionTip(evt);
}

function positionTip(evt) {
	if (!tipFollowMouse) {
		mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft;
		mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
	}
	// tooltip width and height
	var tpWd = (ns4)? tooltip.width: (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
	var tpHt = (ns4)? tooltip.height: (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
	// document area in view (subtract scrollbar width for ns)
	var winWd = (ns4||ns5)? window.innerWidth-80+window.pageXOffset: document.body.clientWidth+document.body.scrollLeft;
	var winHt = (ns4||ns5)? window.innerHeight-80+window.pageYOffset: document.body.clientHeight+document.body.scrollTop;
	// check mouse position against tip and window dimensions
	// and position the tooltip 
	if ((mouseX+offX+tpWd)>winWd) 
		tipcss.left = (ns4)? mouseX-(tpWd+offX): mouseX-(tpWd+offX)+"px";
	else tipcss.left = (ns4)? mouseX+offX: mouseX+offX+"px";
	if ((mouseY+offY+tpHt)>winHt) 
		tipcss.top = (ns4)? winHt-(tpHt+offY): winHt-(tpHt+offY)+"px";
	else tipcss.top = (ns4)? mouseY+offY: mouseY+offY+"px";
	if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);
}

function hideTip() {
	if (!tooltip) return;
	t2=setTimeout("tipcss.visibility='hidden'",100);
	tipOn = false;
	}
