function Layout() {}

Layout.prototype.contentHeight = function() {
	if (document.getElementById) {		
		var windowHeight = getWindowHeight();		
		var headerHeight = document.getElementById('header').offsetHeight;
		var footerHeight = document.getElementById('idGoogleAds').offsetHeight;
		var contentElement = document.getElementById('mainContent');
		if(windowHeight > 600) {
			contentElement.style.height = (windowHeight - (headerHeight + footerHeight)) + 'px';			
	    }
		$("#sidecontent").height(contentElement.offsetHeight - 45);	
		if($("#idLeftSideBar")) $("#idLeftSideBar").height(contentElement.offsetHeight - 50);
		$(".verticalScrollBar").height(contentElement.offsetHeight - 46);		
		$(".verticalMyCarpoolScrollBar").height(contentElement.offsetHeight - 225);
		$(".verticalListMatchScrollBar").height(contentElement.offsetHeight - 258);
		$(".verticalMyAccountScrollBar").height(contentElement.offsetHeight - 285);			
		$(".processingLoading").height(contentElement.offsetHeight - 200);
		return contentElement.offsetHeight;
	}	
	$("#idLeftSideBar").css({height:525});
	return 725;
}

Layout.prototype.getWindowHeight = function() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight=window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight=document.documentElement.clientHeight  ;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight=document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

Layout.prototype.changeSidebar = function() { 
	document.getElementById('sidebar1').style.width= '500px'; //42%
	document.getElementById('mainContent').style.margin= '0 0 0 500px';   //42%
}

Layout.prototype.changeSidebarDefault = function() { 
	document.getElementById('sidebar1').style.width= '400px';	//30%
	document.getElementById('mainContent').style.margin= '0 0 0 400px';   //30%
}

Layout.prototype.scrollDown = function(idOuter, idInner) { 
	var objDiv = document.getElementById(idOuter);
	objDiv.scrollTop = objDiv.scrollHeight;
	var objDiv = document.getElementById(idInner);
	objDiv.scrollTop = objDiv.scrollHeight;
}

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight=window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight=document.documentElement.clientHeight  ;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight=document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function changeAboutUSMenu(tabNum) {
	$("#idWelcom_Con, #idHelp_Con, #idFAQ_Con, #idTermCondition_Con, #idContactus_Con, #idSiteCredit_Con").css({display:"none"});
	 $('#idWelcom, #idHelp, #idFAQ, #idTermCondition, #idContactus, #idSiteCredit').removeClass('bnt_aboutus_color');
	 
	switch(tabNum) {
		case -1:
			break;				
		case 0:
			$("#idWelcom").addClass('bnt_aboutus_color');
			$("#idWelcom_Con").css({display:""});
			break;		
		case 1:
			$('#idHelp').addClass('bnt_aboutus_color');
			$("#idHelp_Con").css({display:""});
			break;
		case 2:
			$("#idFAQ").addClass('bnt_aboutus_color');
			$("#idFAQ_Con").css({display:""});
			break;			
		case 3:
			$("#idTermCondition").addClass('bnt_aboutus_color');
			$("#idTermCondition_Con").css({display:""});
			break;		
		case 4:
			$("#idContactus").addClass('bnt_aboutus_color');
			$("#idContactus_Con").css({display:""});
			break;		
	    case 5:
			$("#idSiteCredit").addClass('bnt_aboutus_color');
			$("#idSiteCredit_Con").css({display:""});
			break;					
	}	
	if(objCPMap.jsAllAboutContent.tabNum == -1) {
		objCPMap.jsAllAboutContent.tabNum = tabNum;
		//objCPMap.map.getInfoWindow().maximize();	
	}
	/*if(objCPMap.map.getSize().width < 764)
		changCssMenuAboutUs();	*/
}

function changCssMenuAboutUs() {
	$('#idWelcom').addClass('menu_small');			 		
	$('#idHelp').addClass('menu_small');			 		
	$('#idFAQ').addClass('menu_small');			 		
	$('#idTermCondition').addClass('menu_small');			 		
	$('#idContactus').addClass('menu_small');			 		
	$('#idSiteCredit').addClass('menu_small');			 		
}

function changeCommuteDetailTab(tabNum) {
	$("#idCalculator, #idSchedule, #idCarParking, #idDisclaimer").css({display:"none"});		
	$("#idBtCalculator").css("color","white");
	$("#idBtSchedule").css("color","white");
	$("#idBtCarParking").css("color","white");
	$("#idBtDisclaimer").css("color","white");	 	
	switch(tabNum) {
		case 0:
			$("#idBtCalculator").css("color","#99ca3d");
			$("#idCalculator").css({display:""});
			break;		
		case 1:
			$("#idBtSchedule").css("color","#99ca3d");
			$("#idSchedule").css({display:""});
			break;
		case 2:
			$("#idBtCarParking").css("color","#99ca3d");
			$("#idCarParking").css({display:""});
			break;
		case 3:
			$("#idBtDisclaimer").css("color","#99ca3d");
			$("#idDisclaimer").css({display:""});
			break;	
	}	
}


function changeMatcheDetailSelect(tabNum) {
	
	$("#idSchedule_Con, #idSendMessage_Con, #idFeedback_Con, #idPhoto_Con").css({display:"none"});	
	
	$("#idSchedule").css("color","white");
	$("#idPhoto").css("color","white");
	$("#idSendMessage").css("color","white");
	$("#idFeedback").css("color","white");
	 
	/*$("#idSchedule").html("<img src='images/bt_schedule.png' style='border:none;'/>");
	$("#idSendMessage").html("<img src='images/bt_message.png' style='border:none;'/>");
	$("#idFeedback").html("<img src='images/bt_feedback.png' style='border:none;'/>");*/

	switch(tabNum) {
		case 0:
			//$("#idSchedule").html("<img src='images/bt_schedule_green.png' style='border:none;'/>");
			$("#idSchedule").css("color","#99ca3d");
			$("#idSchedule_Con").css({display:""});
			break;		
		case 1:
			//$("#idSendMessage").html("<img src='images/bt_message_green.png' style='border:none;'/>");
			$("#idSendMessage").css("color","#99ca3d");
			$("#idSendMessage_Con").css({display:""});
			break;
		case 2:
			//$("#idFeedback").html("<img src='images/bt_feedback_green.png' style='border:none;'/>");
			$("#idFeedback").css("color","#99ca3d");
			$("#idFeedback_Con").css({display:""});
			break;
		case 3:
			//$("#idPhoto").html("<img src='images/bt_feedback_green.png' style='border:none;'/>");
			$("#idPhoto").css("color","#99ca3d");
			$("#idPhoto_Con").css({display:""});
			break;	
	}	
}

function loadImageLink(idSelected, urlImage) {
	$("#" + idSelected).html('<img src="'+ urlImage + '" style="border:none;"/>');
}

//Lnnam create date : 13/08/2008
/*function countSMSMessage(maxChar, inputID, outPutNumCharID, outPutNumMessageID){
	var crtInput = document.getElementById(inputID);
	var outPutNumChar = document.getElementById(outPutNumCharID);	
	var numMessage = Math.round(crtInput.value.length / maxChar - 0.5);
	var intLog = maxChar * numMessage;
	if(outPutNumMessageID) {
		outPutNumChar.innerHTML = maxChar - (crtInput.value.length - intLog);			
		var outPutNumMessage = document.getElementById(outPutNumMessageID);
		outPutNumMessage.innerHTML = numMessage+1;
	}else {
		outPutNumChar.innerHTML = maxChar - crtInput.value.length;		
	}
}*/
function countSMSMessage(maxChar, SMS_MAXMESSAGE, SMS_MAXPREFIX, inputID, outPutNumCharID, outPutNumMessageID){
	maxChar = maxChar - SMS_MAXPREFIX;
	var crtInput = document.getElementById(inputID);
	var outPutNumChar = document.getElementById(outPutNumCharID);	
	var numMessage = Math.round(crtInput.value.length / maxChar - 0.5);
	var intLog = maxChar * numMessage;	
	//alert(SMS_MAXMESSAGE);
	if(numMessage < SMS_MAXMESSAGE) {
		if(outPutNumMessageID) {
			outPutNumChar.innerHTML = maxChar - (crtInput.value.length - intLog);			
			var outPutNumMessage = document.getElementById(outPutNumMessageID);
			outPutNumMessage.innerHTML = numMessage+1;
		}else {
			outPutNumChar.innerHTML = maxChar - crtInput.value.length;		
		}
	} else {
		outPutNumChar.innerHTML = 0;
	}
	
}
function ismaxlength(obj) {
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}

/*lnnam add this script 22/07/2009*/
 $("#idJoining, #idInvite, #idAbout, #idContact").click(function () { 
	  $("#idJoining, #idInvite, #idAbout, #idContact").removeClass('bnt_aboutus_color');															
      $(this).addClass('bnt_aboutus_color');
    });

/*End script */
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}