if(typeof widgets=="undefined"){
widgets=new Object();
}
widgets.wct=function(_1){
this.id=_1.id;
this.activeClass="active";
this.dateActiveClass="dateActive";
this.transType=null;
this.tansSpeed="normal";
this.noConflict=_1.noConflict|false;
var me=this;
var _3="#"+me.id+" ";
var jQ;
if(this.noConflict){
jQ=jQuery;
jQ.noConflict();
}else{
jQ=$;
}
jQ(document).ready(function(){
me.dateBoxes=[{start:jQ(_3+"#flights input.startDate"),end:jQ(_3+"#flights input.endDate")},{start:jQ(_3+"#hotels input.startDate"),end:jQ(_3+"#hotels input.endDate")},{start:jQ(_3+"#packages input.startDate"),end:jQ(_3+"#packages input.endDate")},{start:jQ(_3+"#activities input.startDate"),end:jQ(_3+"#activities input.endDate")}];
me.children=[{drop:jQ(_3+"#flightsChildren"),ages:jQ(_3+"#flights .minors")},{drop:jQ(_3+"#packagesChildren"),ages:jQ(_3+"#packages .minors")}];
me.initDates();
me.initChildren();
jQ(_3+"#flights form").submit(me.flights.validate);
jQ(_3+"#flights input[name='dateTypeSelect']").click(me.flights.activateDate);
jQ(_3+"#hotels form").submit(me.hotels.validate);
jQ(_3+"#packages form").submit(me.packages.validate);
jQ(_3+"#activities form").submit(me.activities.validate);
});
this.initChildren=function(){
childBoxes=me.children;
for(var _5=0;_5<childBoxes.length;_5++){
var _6=childBoxes[_5];
_6.drop.data("ages",_6.ages);
_6.drop.change(function(){
var _7=new Number(jQ(this).val());
var _8=jQ(this).data("ages");
for(var _9=1;_9<=4;_9++){
if(_9<=_7){
_8.find(".child"+_9+":hidden").fadeIn(me.transSpeed);
}else{
_8.find(".child"+_9+":visible").fadeOut(me.transSpeed);
}
}
var _a=_8.find("label");
if(_7>0){
_a.fadeIn(me.transSpeed);
}else{
_a.fadeOut(me.transSpeed);
}
});
}
};
this.initDates=function(){
var _b=me.dateBoxes,_c,_d;
if(!me.startDate){
_c=new Date();
_c.addDays(1);
}else{
_c=me.startDate;
}
if(!me.endDate){
_d=new Date();
_d.addDays(2);
}else{
_d=me.endDate;
}
var _e={minDate:new Date(),clickInput:true,createButton:false};
for(var i=0;i<_b.length;i++){
var _10=_b[i];
_10.start.datePicker(_e);
_10.end.datePicker(_e);
_10.start.val(_c.asString());
_10.end.val(_d.asString());
_10.start.bind("click",function(){
this.blur();
});
_10.end.bind("click",function(){
this.blur();
});
_10.start.siblings(".dp-choose-date").data("box",_10.start);
_10.end.siblings(".dp-choose-date").data("box",_10.end);
_10.start.siblings(".dp-choose-date").bind("click",function(){
jQ(this).data("box").dpDisplay();
return false;
});
_10.end.siblings(".dp-choose-date").bind("click",function(){
jQ(this).data("box").dpDisplay();
return false;
});
_10.start.data("end",_10.end);
_10.start.change(function(){
var _11=new Date(jQ(this).val().replace(/-/g,"/"));
var yr=String(_11.getYear());
yr="2"+String(Number(yr.substr(yr.length-2,2)).pad(3));
_11.setFullYear(yr);
if(_11.asString().length!=jQ(this).val().length){
jQ(this).val(_11.asString());
}
if(!isNaN(_11)){
jQ(this).dpSetSelected(_11.asString());
var end=jQ(this).data("end");
end.dpSetStartDate(_11.addDays(1).asString());
end.dpSetSelected(_11.addDays(2).asString());
end.val(_11.asString());
}
});
_10.end.change(function(){
var _14=new Date(jQ(this).val());
if(!isNaN(_14)){
jQ(this).dpSetSelected(_14.asString());
}
});
}
};
this.activate=function(tab){
var _16=jQ("#"+tab);
if(!_16.hasClass(me.activeClass)){
var _17=jQ(_3+".wctTab."+me.activeClass);
if(me.transType&&me.transType=="fade"){
_17.fadeOut(me.transSpeed,function(){
_17.removeClass(me.activeClass);
_16.addClass(me.activeClass);
_16.fadeIn(me.transSpeed);
});
}else{
_17.hide();
}
_17.removeClass(me.activeClass);
_16.addClass(me.activeClass);
_16.show();
jQ(_3+" #wctTabs li.active").removeClass("active");
jQ(_3+" #wctTabs li."+tab).addClass("active");
}
return false;
};
this.hotels=new Object();
this.hotels.activateRooms=function(_18){
var _19=jQ(_3+"#hotels .guests tr");
for(var i=0;i<=_19.length;i++){
if(i<=_18){
jQ(_19[i]).fadeIn(me.transSpeed);
}else{
jQ(_19[i]).fadeOut(me.transSpeed);
}
}
};
this.hotels.validate=function(){
var _1b="",_1c="",_1d="";
with(this){
if(jQ(city).val().length==0){
_1c+="\tHotels in\n";
}
if(jQ(hotelsStart).val().length==0){
_1c+="\tCheck-in\n";
}
if(jQ(hotelsEnd).val().length==0){
_1c+="\tCheck-out\n";
}
now=new Date();
checkInDate=new Date(hotelsStart.value.replace(/-/g,"/"));
checkOutDate=new Date(hotelsEnd.value.replace(/-/g,"/"));
if(_1c==""){
if(isNaN(checkInDate)){
_1d+="\tCheck-in\n";
}
if(isNaN(checkOutDate)){
_1d+="\tCheck-out\n";
}
}
if(checkInDate<now){
_1d+="\tCheck-in must be a date in the future.\n";
}
if(checkOutDate<=now){
_1d+="\tCheck-out must be a date in the future.\n";
}
if(checkOutDate<checkInDate){
_1d+="\tCheck-out must be a date later than Check-in.\n";
}
}
if(_1c.length>0){
_1b="The form could not be submitted because the following required fields are blank:\n"+_1c;
}
if(_1d.length>0&&_1c.length>0){
_1b+="\nAdditionally, the following fields are formated invalid:\n"+_1d;
}else{
if(_1d.length>0){
_1b="The form could not be submitted because the following fields are formatted invalid:\n"+_1d;
}
}
if(_1b.length>0){
alert(_1b);
return false;
}else{
with(this){
if(me.hotels.xml){
jQ(hotelsStart).val(hotelsStart.value.replace(/\//g,"-"));
jQ(hotelsEnd).val(hotelsEnd.value.replace(/\//g,"-"));
}else{
jQ(doa_mm).val((checkInDate.getMonth()+1).pad(2));
jQ(doa_dd).val(checkInDate.getDate().pad(2));
jQ(doa_yy).val(checkInDate.getFullYear());
jQ(dod_mm).val((checkOutDate.getMonth()+1).pad(2));
jQ(dod_dd).val(checkOutDate.getDate().pad(2));
jQ(dod_yy).val(checkOutDate.getFullYear());
}
}
return true;
}
};
this.hotels.xml=_1.hotelXml===true;
this.flights=new Object();
this.flights.activateDate=function(){
var _1e=jQ(this).val(),_1f;
if(_1e=="plusMinusDates"){
_1f="exactDates";
}else{
_1f="plusMinusDates";
}
var _20=jQ(_3+"#flights .date ."+_1f);
var _21=jQ(_3+"#flights .date ."+_1e);
_20.fadeOut(me.transSpeed,function(){
_21.fadeIn(me.transSpeed);
});
return true;
};
this.flights.validate=function(){
var _22="",_23="",_24="";
with(this){
if(jQ(leavingFrom).val().replace("Departing from","").length==0){
_24+="\tDeparting from\n";
}
if(jQ(goingTo).val().length==0){
_24+="\tGoing to\n";
}
if(jQ(leavingDate).val().length==0){
_24+="\tDepart\n";
}
if(jQ(returningDate).val().length==0){
_24+="\tReturn\n";
}
var now=new Date();
var _26=new Date(jQ(leavingDate).val().replace(/-/g,"/"));
var _27=new Date(jQ(returningDate).val().replace(/-/g,"/"));
if(_24==""){
if(isNaN(_26)){
_23+="\tDepart\n";
}
if(isNaN(_27)){
_23+="\tReturn\n";
}
}
if(_26<now){
_23+="\tDepart must be a date in the future.\n";
}
if(_27<=now){
_23+="\tReturn must be a date in the future.\n";
}
if(_27<_26){
_23+="\tReturn must be a date later than Depart.\n";
}
}
if(_24.length>0){
_22="The form could not be submitted because the following required fields are blank:\n"+_24;
}
if(_23.length>0&&_24.length>0){
_22+="\nAdditionally, the following fields are formated invalid:\n"+_23;
}else{
if(_23.length>0){
_22="The form could not be submitted because the following fields are formatted invalid:\n"+_23;
}
}
if(_22.length>0){
alert(_22);
return false;
}else{
with(this){
jQ(leavingDate).val(leavingDate.value.replace(/-/g,"/"));
jQ(returningDate).val(returningDate.value.replace(/-/g,"/"));
}
return true;
}
};
this.packages=new Object();
this.packages.validate=function(){
var _28="",_29="",_2a="";
with(this){
if(jQ(leavingFrom).val().replace("Departing from","").length==0){
_2a+="\tDeparting from\n";
}
if(jQ(goingTo).val().length==0){
_2a+="\tGoing to\n";
}
if(jQ(leavingDate).val().length==0){
_2a+="\tDepart\n";
}
if(jQ(returningDate).val().length==0){
_2a+="\tReturn\n";
}
var now=new Date();
var _2c=new Date(jQ(leavingDate).val().replace(/-/g,"/"));
var _2d=new Date(jQ(returningDate).val().replace(/-/g,"/"));
if(_2a==""){
if(isNaN(_2c)){
_29+="\tDepart\n";
}
if(isNaN(_2d)){
_29+="\tReturn\n";
}
}
if(_2c<now){
_29+="\tDepart must be a date in the future.\n";
}
if(_2d<=now){
_29+="\tReturn must be a date in the future.\n";
}
if(_2d<_2c){
_29+="\tReturn must be a date later than Depart.\n";
}
}
if(_2a.length>0){
_28="The form could not be submitted because the following required fields are blank:\n"+_2a;
}
if(_29.length>0&&_2a.length>0){
_28+="\nAdditionally, the following fields are formated invalid:\n"+_29;
}else{
if(_29.length>0){
_28="The form could not be submitted because the following fields are formatted invalid:\n"+_29;
}
}
if(_28.length>0){
alert(_28);
return false;
}else{
with(this){
jQ(dateLeavingMonth).val((_2c.getMonth()+1).pad(2));
jQ(dateLeavingDay).val(_2c.getDate().pad(2));
jQ(dateLeavingYear).val(_2c.getFullYear());
jQ(dateReturningMonth).val((_2d.getMonth()+1).pad(2));
jQ(dateReturningDay).val(_2d.getDate().pad(2));
jQ(dateReturningYear).val(_2d.getFullYear());
}
return true;
}
};
this.activities=new Object();
this.activities.validate=function(){
var _2e="",_2f="",_30="";
with(this){
if(actStart.value.length==0){
_2f+="\tStart Date\n";
}
if(actEnd.value.length==0){
_2f+="\tThru\n";
}
if(jQ("#activities input:checkbox").filter("input:checked").length==0){
_2f+="\tActivity\n";
}
var now=new Date();
var _32=new Date(actStart.value.replace(/-/g,"/"));
var _33=new Date(actEnd.value.replace(/-/g,"/"));
if(_2f==""){
if(isNaN(_32)){
_30+="\tStart Date\n";
}
if(isNaN(_33)){
_30+="\tThru Date\n";
}
}
if(_32<now){
_30+="\tStart date must be a date in the future.\n";
}
if(_33<=now){
_30+="\tThru must be a date in the future.\n";
}
if(_33<_32){
_30+="\tThru must be a date later than Start date.\n";
}
}
if(_2f.length>0){
_2e="The form could not be submitted because the following required fields are blank:\n"+_2f;
}
if(_30.length>0&&_2f.length>0){
_2e+="\nAdditionally, the following fields are formated invalid:\n"+_30;
}else{
if(_30.length>0){
_2e="The form could not be submitted because the following fields are formatted invalid:\n"+_30;
}
}
if(_2e.length>0){
alert(_2e);
return false;
}else{
return true;
}
};
};
Number.prototype.pad=function(_34){
var n=this.toString();
while(n.length<_34){
n="0"+n;
}
return n;
};

