function externalLinks() {
	var i;
	var anchor;
	var anchors = document.getElementsByTagName("a");
	
	for (i = 0; i < anchors.length; i++) {
		anchor = anchors[i];
		
		if(anchor.getAttribute("href") && anchor.getAttribute("rel") == "external"){
			anchor.target = "_blank";
		}
	}
}


window.onload = function() {
	externalLinks();
	initForm();
}

function $(_id){return document.getElementById(_id);}
var exObj="";
var exClickObj="";
var selecterFlag=0;

function showHideElement(_elm, clickObj){	
		myElement = $(_elm)
		if (myElement){
			if (myElement.style.display == ""){
				myElement.style.display = "none";
			}
			else{
				myElement.style.display = "";
			}
		}
		
		if(exObj!="" && exObj != _elm){
			$(exObj).style.display = "none";
		}
		
		if(exObj != _elm){
			exObj = _elm;
		}
		
		if (exClickObj != ""){					
			exClickObj.className = "";
		}
		if (clickObj){
			if (clickObj != exClickObj){
				selecterFlag=1;
			}
			else{
				if (selecterFlag==1){selecterFlag=0;}
				else{selecterFlag=1;}
			}
						
			if (selecterFlag==1){
				clickObj.className += " selected";
			}
			
			
			exClickObj = clickObj;
		}
		
}


function goToPage(_href)
{
window.location.href=_href;
}



function winopennew(x) {
	otherSiteInternetSube(x)

	/*if (x=="xfr") {   
		internetWindow();
	} else if (x=="bilgi") {  
		newFreeWindow('http://www.hsbc.com.tr/OnlineServisler/Bireysel/Bilgi.asp');
	} else if (x=="demo") {
		newWindow('http://www.hsbc.com.tr/OnlineServisler/Bireysel/Demo/','780','560');
	} else if (x=="guvenlik") {
		newWindow('http://www.hsbc.com.tr/Security.asp','780','560');
	} else if (x=="basvuru") {
		newFreeWindow('http://www.hsbc.com.tr/OnlineServisler/Bireysel/Basvuru.asp');
	} else if (x=="facebook") {
		newFreeWindow('http://www.avantajtoplamaca.com');
	}
	return;*/
}

function getCenter(pwidth,pheight){
	wwidth=screen.width;
	wheigth=screen.height;
	lpos= (wwidth - pwidth)/2;
	tpos= (wheigth - pheight)/2;
	return lpos, tpos;
}
function PopItUp(src,w,h,s) {
	if(s) w=w+17;
	getCenter(w,h);
	Popwin = window.open(src,"pop_up","toolbar=0,width=" + w + ", height=" + h + ", left="+ lpos +", top="+ tpos +"; location=0, directories=0, status=1, scrollbars="+s+", menubar=0, resizable=1, copyhistory=0");
	Popwin.focus();
	//return false;
}

function PopItUp_New(src,w,h,s) {
	getCenter(w,h);
	Popwin = window.open(src,"pop_up","toolbar=0,width=" + w + ", height=" + h + ", left="+ lpos +", top="+ tpos +"; location=0, directories=0, status=1, scrollbars="+s+", menubar=0, resizable=1, copyhistory=0");
	Popwin.focus();
	//return false;
}

function PopItUp_other(src,w,h,s) {
	if(s) w=w+17;
	getCenter(w,h);
	PopwinOther = window.open(src,"PopwinOther","toolbar=0,width=" + w + ", height=" + h + ", left="+ lpos +", top="+ tpos +"; location=0, directories=0, status=1, scrollbars="+s+", menubar=0, resizable=1, copyhistory=0");
	PopwinOther.focus();
	//return false;
}

function PopItUp_Return(src,w,h,s) {
	if(s) w=w+17;
	getCenter(w,h);
	Popwin = window.open(src,"pop_up","toolbar=0,width=" + w + ", height=" + h + ", left="+ lpos +", top="+ tpos +"; location=0, directories=0, status=1, scrollbars="+s+", menubar=0, resizable=1, copyhistory=0");
	Popwin.focus();
	return false;
}

function otherSiteLinks(redirectionSite){
//blank page
	w="586";
	h="530"
	getCenter(w,h);
	PopItUp('/pop_uyari.asp?' + redirectionSite, w, h, 0);
	return false;
}

function otherHSBCSiteLinks(redirectionSite){
//blank page
	w="586";
	h="530"
	getCenter(w,h);
	PopItUp('/pop_uyariOtherHsbc.asp?' + redirectionSite, w, h, 0);
	return false;
}




function otherSiteLinksboyutlu(redirectionSite){
//blank page
	w="586";
	h="530"
	getCenter(w,h);
	PopItUp('/pop_basvuru.asp?' + redirectionSite, w, h, 0);
	return false;
}


function otherSiteLinksboyutlu_2(redirectionSite){
//blank page
	w="586";
	h="530"
	getCenter(w,h);
	PopItUp('/pop_basvuru_ck.asp?' + redirectionSite, w, h, 0);
	return false;
}




function nonHSBCSiteLinks(redirectionSite){
//blank page
	w="586";
	h="530"
	getCenter(w,h);
	PopItUp('/pop_uyari_nh.asp?' + redirectionSite, w, h, 0);
	return false;
}

function nonHSBCSiteLinksTR(redirectionSite){
//blank page
	w="586";
	h="530"
	getCenter(w,h);
	PopItUp('/pop_uyari_tr.asp?' + redirectionSite, w, h, 0);
	return false;
}


function nonHSBCSiteLinks_2(redirectionSite){
//blank page
	w="586";
	h="530"
	getCenter(w,h);
	PopItUp('/pop_uyari_nh.asp?' + redirectionSite, w, h, 0);
}



function otherSiteInternetSube(openparameter){
//internet subesi
	w="586";
	h="530"
	getCenter(w,h);
	PopItUp('/pop_uyari_internet_bankaciligi.asp?' + openparameter, w, h, 0);
	return false;
}

function otherSiteBasvuru(gelen){
//internet subesi
	w="586";
	h="530"
	getCenter(w,h);
	PopItUp(gelen, w, h, 0);
	return false;
}

function findThisPage(uri) {
	var url = window.location.href;
	var root = document.getElementById('menu');
	var subRoot = document.getElementById('menu');
	var node;
	var nodea;
	var subNode;
	var subNodea;
	var src;
	var srcNode;
	var i;
	var j;
	
	if(uri) {
		url = 'http://'+window.location.hostname+uri;
	}
	root = root.getElementsByTagName('ul')[0];
	
	for(i=0; i < root.childNodes.length; i++) {
		node = root.childNodes[i];
		if(node.nodeName == '#text') {
			continue;
		}

		nodea = node.getElementsByTagName('a')[0];
		

		if(root.childNodes[i].getElementsByTagName('ul')[0] != undefined){
			if(root.childNodes[i].getElementsByTagName('ul').length > 0){
				subRoot  = root.childNodes[i].getElementsByTagName('ul')[0];

				for(j=0; j < subRoot.childNodes.length; j++){
					subNode = subRoot.childNodes[j];
					if(subNode.nodeName == '#text') {
						continue;
					}
					subNodea = subNode.getElementsByTagName('a')[0];
					//alert('sub :'+subNodea + ' '+'n :'+nodea+ ' '+ 'url :'+url +' sna :'+subNodea)
					
					if(subNodea != undefined && subNodea.href == url && (root.childNodes[i].getElementsByTagName('ul')[0] != undefined)) {
						//alert(subNodea.getAttribute('href'))
						node.className = 'selected';
						node = nodea.getElementsByTagName('img')[0];
						src = node.getAttribute('src');
						src = src.replace(".gif", "_act.gif");
						node.src = src;
						
						subNode.className = 'selected';
						subNode = subNodea.getElementsByTagName('img')[0];
						//alert(subNode.attributes.src.nodeValue)
						srcNode = subNode.getAttribute('src');
						srcNode = srcNode.replace(".gif", "_act.gif");
						subNode.src = srcNode;
							
					}
				}
			}
		}
		if(nodea != undefined && nodea.href == url && (root.childNodes[i].getElementsByTagName('ul')[0] == undefined)) {
			node.className = 'selected';
			node = nodea.getElementsByTagName('img')[0];
			src = node.getAttribute('src');
			src = src.replace(".gif", "_act.gif");
			node.src = src;
			//break;
		}
		
	}
}





function initForm() {
	var i;
	var j;
	var frm;
	var elm;
	var val;
	
	for(i=0; i < document.forms.length; i++) {
		frm = document.forms[i];
		
		for(j=0; j < frm.elements.length; j++) {
			elm = frm.elements[j];
			
			if((elm.type == 'text' || elm.type == 'textarea') && elm.value != '') {
				if(!elm.alt) {
					elm.alt = elm.value;
				}
				
				elm.onblur = function() {
					if(this.value == '') {
						this.value = this.alt;
					}
				}
				
				elm.onfocus = function() {
					if(this.value == this.alt) {
						this.value = '';
					}
				}
			}
		}
	}
}

function showTD(trID) {
	var tr = document.getElementById(trID);
	var td;
	var i;
	
	for(i=0; i < tr.childNodes.length; i++) {
		td = tr.childNodes[i];
		
		if(td.nodeName == '#text') {
			continue;
		}
		
		td.className = td.className.replace('invis', '');
	}
}

function hideTD(trID) {
	var tr = document.getElementById(trID);
	var td;
	var i;
	
	for(i=0; i < tr.childNodes.length; i++) {
		td = tr.childNodes[i];
		
		if(td.nodeName == '#text') {
			continue;
		}
		
		td.className = td.className+' invis';
	}
}



Array.prototype.shuffle = function() {
						for (var i=0; i<this.length*10; i++) {
							var a = parseInt(Math.random()*this.length);
							var b = parseInt(Math.random()*this.length);
							var swap = this[a];
							this[a] = this[b];
							this[b] = swap;
						}
						return this;
					};


_GET = new Object();
function parseLS() {
	var _queryString = location.search.substring(1);
	var _eachQuery = _queryString.split("&");
	for (q=0;q<_eachQuery.length;q++) {
		var _kv = _eachQuery[q].split("=");
		_GET[_kv[0]] = _kv[1];
	}
}

	var DWin 
	function bireysel_int(url,name){	
		DWin = window.open(url,name,"toolbar=0,top=0,left=0,width=777,height=570,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,copyhistory=1"); 
	}
	
	function DemirWin_2(url,name){
		DWin = window.open(url,name,"toolbar=0,top=0,left=0,width=790,height=610,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,copyhistory=1");
	}

	
	
	var DWin 
	function kurumsal_int(url,name){	
		DWin = window.open(url,name,"toolbar=0,top=0,left=0,width=777,height=570,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,copyhistory=1"); 
	}	




	function getUrl(url,target) {
		if(url=='blank') return false;
		if(target && target=='blank') window.open(url);
	else document.location.href=url;
	  }




function pageType(type){

						var myContainer = document.getElementById("sright")
						if (type =="small"){
							myContainer.className = "sright";
						}
						else if(type =="big"){
					
							myContainer.className = "sRight_big";
						}

			}




function msignKWindow() //m-Sign için gerekli pencereyi açar.
{
var scrwidth=(screen.width>1000 ? 785:790); var scrheight=(screen.height>800 ? 608:522); var CWin = window.open("https://kurumsal.hsbc.com.tr/TUR/MSGNOR_01.asp","MsignB","toolbar=0,top=0,left=0,width="+scrwidth+",height="+scrheight+",location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,copyhistory=1,dependent=0");
}


function msignWindow() //m-Sign için gerekli pencereyi açar.
{
var scrwidth=(screen.width>1000 ? 785:790); var scrheight=(screen.height>800 ? 608:522); var CWin = window.open("https://kurumsal.hsbc.com.tr/TUR/MSGNAP_01.asp","Msign","toolbar=0,top=0,left=0,width="+scrwidth+",height="+scrheight+",location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,copyhistory=1,dependent=0");
}


function newWindow(url,width,height) //Yeni pencere açar.
{
	day = new Date();
	id = day.getTime();
	PageName="Page"+id
	PageName = window.open(url,id,"toolbar=0,top=0,left=0,width="+width+",height="+height+",location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,copyhistory=0"); 
}

function internetWindow() //İnternet Bankacılığı için gerekli pencereyi açar.
{
	var url="https://bireysel.hsbc.com.tr/TUR"
	var DWin = window.open(url,"HSBCNET","toolbar=0,top=0,left=0,width=798,height=555,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,copyhistory=1"); 
}

function winopenKK(x,s)
{
    var strRf = s ;     //Url'e eklenecek strRef değişkeni

    var url="https://bireysel.hsbc.com.tr/TUR/transactions/CAPPLY_01.asp?strRef="+ strRf
    var DWin = window.open(url,"BASVURUFORMU","toolbar=0,top=0,left=0,width=785,height=555,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,copyhistory=1");

}













