﻿// JScript File
var intervalID;//for checking the width of the windows
/* Method Name: adjHighMoz
 * ---------------------------------------------------------------------
 * This method is to adjust the height for navigoter div.
 * Last Update: 30 08 2006 19:05
 */ 

 function adjHighMoz(){ 
           /* 
            var wMas= document.getElementById('header_main'); 
            wMas.style.height ='612'; 
             
            alert('height: '+wMas.style.height);     
      */
      
     }




/* Method Name: goToBanner
 * ---------------------------------------------------------------------
 * This method is to detect if client got pop-up blocker.
 * Last Update: 30 08 2006 19:05
 */ 

 function goToBanner(str){ 
          /* var WindowOpen = window.open(str,'_blank', 'resizable=yes,scrollbars=yes,toolbars=yes,status=yes,menubar=yes,location=yes') ;         */
         var WindowOpen = window.open(str,'_self', 'resizable=yes,scrollbars=yes,toolbars=yes,status=yes,menubar=yes,location=yes') ;
          if ( (!WindowOpen ) || (WindowOpen.closed))
                {
                    alert('You browser has Pop-Up Blocker enabled. \n Please disable the Pop-Up Blocker to view this offer OR simply try again ');                    
                }      
     }
/* Method Name: GetSuburbHomeList_CallBack
 * ---------------------------------------------------------------------
 * This method is to ajax callback function.
 * Last Update: 30 08 2006 19:05
 */ 
function GetSuburbHomeList_CallBack(response)
{
	if (response.error != null)
	{
		ShowDiv("DivSuburbHome", response.error);
		return;
	}
	
	if ((response.value == "") || (response.value == null))
	{
		HideDiv("DivSuburbHome");
		return;
	}
		
	ShowDiv("DivSuburbHome", response.value);
}
function GetPostCodeList_CallBack(response)
{
	if (response.error != null)
	{
		ShowDiv("DivZip", response.error);
		return;
	}
	
	if ((response.value == "") || (response.value == null))
	{
		HideDiv("DivZip");
		return;
	}
		
	ShowDiv("DivZip", response.value);
}
function ShowDiv(divid, text)
{
	if (document.layers) 
	{
		document.layers[divid].display = "block";
		document.layers[divid].innerHTML = text;
	}
	else 
	{
		document.getElementById(divid).style.display="block";
		document.getElementById(divid).innerHTML = text;
	}
}
function HideDiv(divid)
{
	if (document.layers) document.layers[divid].display="none";
	else 
	{
		document.getElementById(divid).style.display="none";
	}
	if(intervalID != null)
	{
	clearInterval(intervalID);
	}
}

function errEmail() 
        {   
           var error= document.getElementById('ctl00_ContentHolder_infoSignUp');
   	       if(error.innerHTML.length > 0){
   	           alert(error.innerHTML);
           }           
        } 

function checkErr()
        {
          var checkTerm= document.getElementById('ctl00_ContentHolder_TermsCheckBox');
          var checkEmail = document.getElementById('ctl00_ContentHolder_Email'); 
          var checkPass = document.getElementById('ctl00_ContentHolder_Password'); 
          var checkPassConfirm = document.getElementById('ctl00_ContentHolder_ConfirmPassword'); 
          var regStrEmail=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
          var regStrPass=/^(\w){6}(\w)*$/;
         // var regStrEmail=/[0-9a-zA-Z]+([-+.'][0-9a-zA-Z]+)*@[0-9a-zA-Z]+([-.][0-9a-zA-Z]+)*\.[0-9a-zA-Z]+([-.][0-9a-zA-Z]+)*/;
          //var regStrPass=/[0-9a-zA-Z]{6}[0-9a-zA-Z]*/;
          
           if(checkEmail.value.length == 0){
                    alert("Email address is required");
                    return false;           
           }else if( regStrEmail.test(checkEmail.value)== false){           
                    alert("Invalid email address: alphanumeric chararcters with no spaces");
                    return false;
           } else if(checkPass.value.length == 0){
                    alert("Password is required");
                    return false; 
           }else if(regStrPass.test(checkPass.value)== false){
                    alert("Password must be 6 or more alphanumeric chararcters");
                    return false;                              
           }else if(checkPassConfirm.value.length == 0){
                    alert("ConfirmPassword is required");
                    return false; 
           }else if(checkPassConfirm.value != checkPass.value){
                    alert("Password and confirm password must match.");
                    return false;         
           }else if(checkTerm.checked!=true){             
                    alert("Please agree to our terms and conditions");
                    return false;
           }
           else
           {
                    return true;
           }
        }
function checkConEmail(){
            var confirmEmail = document.getElementById('ctl00_ContentHolder_ConfirmEmail');
             var regStrEmail=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
            if(confirmEmail.value.length == 0){
                    alert("Email address is required");
                    return false;           
           }else if( regStrEmail.test(confirmEmail.value)== false){           
                    alert("Invalid email address: alphanumeric chararcters with no spaces");
                    return false;
           }
}
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					
	}
	
function getFocus(){
        var loginBtn= document.getElementById('ctl00_ContentHolder_Login1_LoginButton');
        loginBtn.focus();
}
function EndPageLoad() {
		/*
		        var x=document.getElementById("loadingErr")
			    x.innerText = 'loaded'
			    x.style.visibility = 'hidden'
			     loading image	
			    var img=document.getElementById("loadingTD")			   
			    img.style.visibility = 'hidden'	*/	   
			     			
		        document.getElementById('contentTBL').style.display = 'none';
		        
		        //uncomment this for activating the floating banner
		        //intervalID=window.setInterval(" getWidth4Fixbnr()", 500);
		        
		       // activateActiveX() ;
		       
		}

/* Method Name: getWidth4Fixbnr
 * ---------------------------------------------------------------------
 * This method is to get the width for navigoter div.
 * Last Update: 4 09 2006 11:05
 */ 

 function getWidth4Fixbnr(){ 
        var bWidth=  document.body.offsetWidth;
        var wL= document.getElementById('fixbannerL');
        var wR= document.getElementById('fixbannerR');
        if(bWidth<1003)
        {           
            wL.style.display = 'none'   
            wR.style.display = 'none'
        }else
		{
			wL.style.display = 'inline'
            wR.style.display = 'inline'
		}
       
     }
/* Method Name: moviefocus()
 * ---------------------------------------------------------------------
 * This method is to automatically focus on flash moive once it's hovering on the movie.
 * Last Update: 4 09 2006 11:05
 */  
function moviefocus(mId) 
{
   //document.mId.focus();
   alert("hover on flash movie");
}
/* Method Name: onDomReady()
 * ---------------------------------------------------------------------
 * This method is to activate the activeX for IE 6 and IE 7.
 * Last Update: 5 09 2006 15:05
 */  
function activateActiveX() {
	if ( !document.getElementsByTagName || !document.body.outerHTML || !document.compatMode ) return false;
		var objects = document.getElementsByTagName( "object" );
		for( var i = 0; i < objects.length; i++ ) {
			var params = "";
			for ( var j = 0; j < objects[i].childNodes.length; j++ ) {
				params += objects[i].childNodes[j].outerHTML;		
			}
			objects[i].outerHTML = objects[i].outerHTML.replace( "</object>", params + "</object>" );   		
		}
}
/* Method Name: showDtlTbl()
 * ---------------------------------------------------------------------
 * This method is to show the details of offer.
 * Last Update: 29 09 2006 10:05
 */  
function showDtlTbl(tblId)
{
    var tbl=document.getElementById(tblId);
  /*  var img=document.getElementById(tblId+'img');
    var imgSrc = img.src;*/ 
    tbl.style.display ='inline'; 
    /*img.src= imgSrc.replace('.jpg', 'Dtl.jpg');*/
}
/* Method Name: hideDtlTbl()
 * ---------------------------------------------------------------------
 * This method is to show the details of offer.
 * Last Update: 29 09 2006 10:05
 */ 
function hideDtlTbl(tblId)
{
    var tbl=document.getElementById(tblId);
    /*var img=document.getElementById(tblId+'img');
    var imgSrc = img.src; 
    img.src= imgSrc.replace('Dtl.jpg','.jpg');*/
    tbl.style.display ='none'; 
}
/* Method Name: hideDtlTbl()
 * ---------------------------------------------------------------------
 * This method is to show the details of offer.
 * Last Update: 29 09 2006 10:05

function showCttFrame(){
    
 
    var iframe=document.getElementById('frameShopping')
    var IFrameObj = document.frames['frameShopping'].contentWindow.document;
    if(iframe!=null)
    {
    //    alert('iframe');
       // alert(iframe.innerHTML);
        alert(IFrameObj.body.innerHTML; );
    }
} */ 

/* Method Name: showExtraTblById()
 * ---------------------------------------------------------------------
 * This method is to show and pass the extra details to global var for survey questions.
 * tblId : the hidden table id
 *  qId: the question id
 * Last Update: 14 11 2006 10:05
 */  
function showExtraTblById(e)
{
           if (e.target) targ = e.target;
               else if (e.srcElement) targ = e.srcElement;
           var srcId=targ.id;
           var commonId= srcId.substring(0,36);
           //alert('commonId '+commonId)
           globalId=commonId
//           if(srcId==globalId)
//           {
//               var extraTblid= commonId+tblId
//               //alert('extraTbl '+extraTblid)
//               
//               showDtlTbl(tblId)
//            }
}
/* Method Name: validateExtra()
 * ---------------------------------------------------------------------
 * This method is to validate the extra details for survey questions.
 * tblId : the hidden table id
 *  qId: the question id
 * Last Update: 14 11 2006 10:05
 */ 
function validateExtra()
{
    if(globalId.length>0)
    {
            //alert('globalId '+ globalId);
            var yesBtn=document.getElementById(globalId+'RadioButtonList1_0')
            var mNum=document.getElementById(globalId+'preferredNumber')
            if(yesBtn.checked ==true){
                if(mNum && (mNum.value.length==0)) 
                {
                    alert('Please provide preferred contact number, if your answer is yes for question 6');
                   mNum.focus() 
                    return false 
                }          
            }
    }
  
}
/* Method Name: CheckEmailNum()
 * ---------------------------------------------------------------------
 * This method is to count the number of entries fo BMW referrals emails
 * Last Update: 15 03 2007 10:05
*/ 


/**************************************************************************************
 *  Function    : toggleExpandCollapse()                                              *
 *  Description : Toggles the expanding and collapsing of the content region of       *
 *                    record and table panels; also swaps the "expand/collapse" icon, *
 *                    and "total records" count based upon the current                *
 *                    expand/collapse state.                                          *
 *  Parameters  : anchorNode, <a> tag node which is clicked upon to initiate toggling *
 *                    of expand/collapse                                              *
 *  Assumptions : The region which is expanded/collapsed is the table (with HTML      *
 *                    id, "CollapsibleRegion") within the sibling (row) of the table  *
 *                    row which contains the anchorNode.                              *
 *  Author      : Samson Wong                                                         *
 **************************************************************************************/
function toggleExpandCollapse(divNodeName,anchorNode)
{
	var collapsibleNode = 	document.getElementById(divNodeName);
    var imageNode =document.getElementById(anchorNode);
    
    // make sure this node is a collapsible region before collapsing
    if (collapsibleNode.tagName == "div" ||  collapsibleNode.tagName == "DIV")
    {
        collapsibleNode.style.display = (collapsibleNode.style.display == "block") ? "none" : "block";
    }
    // make sure this node contains the expand/collapse image before swapping icon
	imageNode.src = (collapsibleNode.style.display == "block") ? "Images/DialogHeaderIconCollapse.gif" : "Images/DialogHeaderIconExpand.gif";
	// show appropriate tool tip for current expand/collapse state (for section 508 compliance)
	imageNode.alt = (collapsibleNode.style.display == "block") ? "Collapse panel" : "Expand panel";
	imageNode.title = (collapsibleNode.style.display == "block") ? "Collapse panel" : "Expand panel";
}

