// JavaScript Document

function checkhome()
{
//to check the cookie to find the home page and direct to that pahe when the home link on the header is clicked

var count=0;
var ca = document.cookie.split(";");
var d2;
var d3;
	for(var i=0;i < ca.length;i++)
		{
			var c = ca[i];
			var ckval=ca[i].split("=")
			var d1=ckval[0]
			d2=ckval[1]
			if(d2=="/personal/default.htm" || d2=="/wholesale/default.htm" || d2=="/nri/europe.htm" || d2=="/nri/middleeast.htm" || d2=="/nri/northamerica.htm" || d2=="/nri/africa.htm" || d2=="/nri/southeastasia.htm" || d2=="/nri/others.htm" || d2=="/nri/canada.htm" || d2=="/nri/australia.htm")
				{
					document.location=d2;
					count=count+1;
				}
		}
		if(count=="0")
			{
				document.location="/personal/default.htm";
			}

}

function change_tab(_id)	{

	var getTab='tab'+_id;
	var getLiTab='li_tab_'+_id;
	var getDocTab=document.getElementById(getTab);
	var getDocLi=document.getElementById(getLiTab);
		for(i=1; i<=100;i++){
			
			var chkTab = 'tab'+i;
			var chkLiTab = 'li_tab_'+i;
			var selDocTab = document.getElementById(chkTab);
			var selDocLi = document.getElementById(chkLiTab);
			
			if(selDocTab!=null){
			
			selDocTab.style.display='none';
			selDocLi.className='';
			}
			else{break;}
		}
		
		getDocTab.style.display='block';	
		getDocLi.className='selected';
}
var $g = jQuery.noConflict();
function tooltip(no,flag,ref)
{	
		for (var i=0; i<=50; i++) {
		if (document.getElementById("tooltipcontent"+i)!=null){
			
			if (i==no){
				
				if(flag=="block"){flag=="none"}
				if(flag=="block")
				$g(ref).addClass("rel");
				else
				$g(ref).removeClass("rel");
			document.getElementById("tooltipcontent"+i).style.display=flag;
			}
			else {
				document.getElementById("tooltipcontent"+i).style.display="none";	
			}
		}
		
		}
}	
$g(document).ready(function(){
	$g("#nre_savings_acc ul li h3").click(function(){			
				$g(this).next(".nresaving_content").slideToggle(500).siblings(".nresaving_content").slideUp(500);
				$g(this).toggleClass("active"); return false;
	});
});

function gotopg(flnm)
{
	if(flnm!='')
	{
		window.location.href=flnm;
	}	
}

function closewindow(page)
{
	
	if(page=="privacy")
		{
			window.opener.location="http://www.hdfcbank.com/aboutus/terms_conditions/privacy.htm"
		}
	if(page=="security")
		{
			window.opener.location="http://www.hdfcbank.com/aboutus/security/security_landing.htm"
		}
	if(page=="tnc")
		{
			window.opener.location="http://www.hdfcbank.com/aboutus/terms_conditions/default.htm"
		}
	self.close()
}

function opennewwindow(filename)
		{
		
		var winheight=screen.height - 65;
		var winwidth=screen.width - 15;
		window.open(filename,"","width="+winwidth+",height="+winheight+",scrollbars=yes ,menubar=no,location=no,left=0,top=0")
			
		}


function emailwindow(x)
{

window.open("/applications/misc/sendemail/mail.asp?filepath="+x,"","width=500,height=350, left=50, top=50");
	}

// Print 
function printpage() {
window.print();  
}

function drop(selSelectObject)
{
	if(selSelectObject.options[selSelectObject.selectedIndex].value!="")
	{
	var val=selSelectObject.options[selSelectObject.selectedIndex].value;
	window.open (val,"","width=800,height=555,scrollbars=yes ,menubar=no,location=no,left=0,top=0");
	}
}

function drop2(selSelectObject)
{
	var val=selSelectObject.options[selSelectObject.selectedIndex].value;
	if (val !="")  
	  document.findyounearest.where.selectedIndex=0;
	  //window.open (val,"","width=680,height=410,scrollbars=yes ,menubar=yes,location=yes,left=0,top=0,Resize=yes");
	  open(val);
}

//Closes the current window
function windowClose(){
  window.close();
}

function pageloc()
{
	//alert(document.location.href);
	document.form1.pagelocation.value=document.location.href;
	document.form1.submit();

}

function setwbparam()
{
	document.getElementById('WT.oss').value = document.form1.searchtext.value;
}
function abc()
	{
			var date = new Date();
			date.setTime(date.getTime()+(10000*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
			lnk=document.location.href.split("/")
			ref="/"+lnk[3]+"/"+lnk[4]
			document.cookie="defaultpage"+"="+ref+expires+"; path=/";
			alert("On your next visit to hdfcbank.com, you will see this page first.")
	}
	
function eraseCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

// Used for selecting window size
function openWindow(winUrl, winName, properties) {

switch (properties) {

    case "win_a":
        newWindow = window.open(winUrl,winName,"scrollbars,menubar,toolbar,resizable,HEIGHT=460,WIDTH=790");
        newWindow.focus();
	break

    case "win_b":
	  	var enhancePopup = true;	
		var checkPath1 = winUrl.indexOf("www.login.hsbc.com");		// hard coded path 1
		var checkPath2 = winUrl.indexOf("www.register.hsbc.com");	// hard coded path 2

		if(checkPath1 > -1 || checkPath2 > -1) // special handling for the URLs
		{
			var appName = navigator.appName.toLowerCase();
			var appVersion = parseFloat(navigator.appVersion);

			if(appName.indexOf("netscape") > -1 && !isNaN(appVersion) && appVersion >= 5 ) // netscape 6.0+
			{
				var appProduct = navigator.product.toLowerCase();
				if(appProduct.indexOf("gecko") > -1) // Gecko is being used
				{
					if(navigator.vendorSub != "6.2") // skip Netscape 6.2
					{
						if(!isNaN(parseFloat(navigator.vendorSub)) && parseFloat(navigator.vendorSub) >= 6.2) // Should be Netscape 6.21+
						{
							enhancePopup = false;
						}				
					}
				}
				else // Gecko is not being used
				{
					var ua = navigator.userAgent.toLowerCase();
					var ns6_index = ua.lastIndexOf("netscape6");
					var versionNum = 0;
				
					if(ns6_index > -1)  // Netscape 6
					{
						if(ua.substring(ns6_index+10, ua.length) != "6.2")
						{
							versionNum = parseFloat(ua.substring(ns6_index+10, ua.length));
						}
					}	
					else
					{
						var ns_index = ua.lastIndexOf("netscape");
						if(ns_index > -1)  // Netscape 7 or +
						{
							versionNum = parseFloat(ua.substring(ns_index+9, ua.length));
						}
					}
					if(!isNaN(versionNum) && versionNum >= 6.2)
					{
						enhancePopup = false;
					}
				}		
			}
		}
		if(enhancePopup) // usual case
		{
			newWindow = window.open(winUrl,winName,"scrollbars,HEIGHT=470,WIDTH=525");
			newWindow.focus();
		}
		else
		{
			self.location.href=winUrl;
		}
	break

    case "win_b_no_scroll":
        newWindow = window.open(winUrl,winName,"HEIGHT=470,WIDTH=525");
        newWindow.focus();
        break
		
	
	
    default:
		if(properties==undefined)
			{
				
				newWindow = window.open(winUrl,winName,"scrollbars=yes,menubar=no,toolbar=no,resizable=no,HEIGHT=410,WIDTH=680");
        		newWindow.focus();
			}
		else
			{
									
				newWindow = window.open(winUrl,winName,properties);
        		newWindow.focus();
			}
    }
}

function funcnrifrmDownload(pdffilename)
{
	window.open ("https://leads.hdfcbank.com/applications/webforms/apply/nrifrmDownload.asp?pdffilename="+pdffilename+"","NRIFrmDownload","location=1,status=1,scrollbars=1,width=700,height=500");
}

function showSurvey()
{
	var SurveyWin=window.open("http://www.hdfcbank.com/nri/survey","NRI_Survey","left=20,top=20,height=500,width=750,resizable=1,scrollbars=1");
//	SurveyWin.blur();
}

function showFeedbackWindow()
{
	window.open("http://www.hdfcbank.com/applications/misc/surveyModule/survey_Qut_form.asp?SID=41","Feedback","width=750,height=500,scrollbars=yes,resizable=yes,location=false");
}

//window.onunload=showSurvey;

