function RGBtoHex(R,G,B) {return toHex(R)+toHex(G)+toHex(B)}
function toHex(N) { if (N==null) return "00"; N=parseInt(N); if (N==0 || isNaN(N)) return "00"; N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N); return "0123456789ABCDEF".charAt((N-N%16)/16) + "0123456789ABCDEF".charAt(N%16); }
$(document).ready(function(){
if(!document.getElementById || !document.createTextNode){return;}
$('a[href^=#]').each(function(){ $('a[href=#A]').parent().addClass('here'); var current = $(this).attr('href').replace(/#/,''); if(current != 'A'){ $('div#'+current).addClass('hide').removeClass('here'); }
$(this).click(function(){ var target = $(this).attr('href').replace(/#/,''); if(target != 'top'){ $('div#copy > div').each(function(i){ var div = $(this).attr('id'); if(div != target && div !='copy_action'){ $(this).addClass('hide').removeClass('here'); $('a[href^=#]').parent().removeClass('here'); } });
$('div#'+target).addClass('here').removeClass('hide'); $('a[href=#'+ target +']').parent().addClass('here'); return false; } }); });
$('select.main').each(function(){ var title = $(this).prev('label').text(); var tabOrd = $(this).attr('tabindex'); var selVal = $(this).find('option:selected').text();
if($(this).attr("value")=="" || $(this).attr("value")=="0"){ $(this).attr('title',title).prev('label').hide().end().SelectCustomizer(); var name = $(this).attr('id'); $('#'+name+'_iconselect').attr('tabindex',tabOrd);
} else { $(this).attr('title','').prev('label').hide().end().SelectCustomizer(); var name = $(this).attr('id'); $('#'+name+'_iconselect').attr('tabindex',tabOrd).append('<span>' + selVal + '</span>'); } });
$('div.text > label').addClass('text');
$('div.input.text > input').each(function(){
if ($(this).val() == ""){ $(this).keypress(function(){ $(this).prev('label').hide();
}).keyup(function(){ if($(this).val()==''){ $(this).prev('label').show(); } else{ $(this).prev('label').hide(); }
}).blur(function(){ if ($(this).val() == ""){ $(this).prev('label').show(); } }); } else { $(this).prev('label').hide(); } });
$('.submit > input').attr('tabindex','10');
$(document.createElement('img')).attr('class','privtip').attr({src:'/img/question.png',title:'Your contact info will not be used for third party marketing purposes.'}).appendTo($('input#LeadEmail').parent());
$(document.createElement('img')).attr('class','privtip').attr({src:'/img/question.png',title:'Your contact info will not be used for third party marketing purposes.'}).appendTo($('input#LeadPhone1').parent());
$('input').each(function(){ $(document.createElement('img')).attr('class','valCheck tooltip').hide().appendTo($(this).parent());
}).change(function(event){ var str = $(this).attr('id'); try{ var params = str + '=' + $('#'+str).val(); new $.ajax({url:'/leads/validate_lead', type:'POST', data: params, success: function(something){ var response = something || "Error in field"; var resptest = response.substr(0,1);
if(resptest != true){ $('#'+str).siblings('.valCheck').attr('src','/img/red-x.gif').attr('title',response).removeClass('green').show(); } else { $('#'+str).siblings('.valCheck').attr('src','/img/green-check.gif').attr('title','Valid response').addClass('green').show(); } } }); } catch(err){}; });
$('div#flashMessage').hide(); $('div.error-message').each(function(){ var erMsg = $(this).text() || 'Please enter a valid response'; $(this).hide();
try{ $(this).parent().append($(document.createElement('img')).attr('class','valCheck tooltip').attr('src','/img/red-x.gif').attr('title',erMsg).removeClass('green')); 
$(this).parent('div.select').click(function(){ $(this).find('div.selectitems').click(function(){ $(this).parent().parent().siblings('img.valCheck').attr('src','/img/green-check.gif').attr('title','Valid response').addClass('green'); }); }); } catch(err){};
try{ $(this).siblings('img.valCheck tooltip').attr('src','/img/red-x.gif').attr('title',erMsg).removeClass('green').show(); } catch(err){}; });
$(document.createElement('img')).attr('class','privtip').attr({src:'/img/question.gif',title:'Which program are you interested in?'}).appendTo($('#formcourseid_iconselect').parent()); 
$(".tooltip").ToolTip(10,20); $(".privtip").ToolTip(10,20); $(".heroA").ToolTip(10,20);	
var selText = $('#formcourseid :selected').text(); if(selText != ''){ $('<h3 id=program_name>' + '<strong>Program:</strong> ' + selText + '</h3>').insertAfter('h3#location').after('<a href="#" id=toggle>Change your program selection</a>'); 
$('a#toggle').click(function(){ $('div[id^=formcourseid]').show(); }); $('.selectitems').click(function(){ selText = $('#formcourseid :selected').text(); $('h3#program_name').html('<strong>Program:</strong> ' + selText); }); } 
});