//Source of the user

var strSource;
	
strSource= document.location.href;
//alert(strSource+"1");
if (strSource.indexOf("#") > 0)
	strSource = strSource.substring(0, strSource.indexOf("#"));

if (strSource.indexOf("&source") > 0)
{
	//alert(strSource+"2");
	strSource = strSource.substring(strSource.indexOf("&source"), strSource.length);	
	strSource = strSource.replace("&","?");
}
else if (strSource.indexOf("?source") > 0) 	{
	//alert(strSource+"3");
	strSource = strSource.substring(strSource.indexOf("?source"), strSource.length); 	}
else{
	//alert(strSource+"4");
	strSource='';	
}

	

/*function fnSubmit(strPath){

	if (strSource != '') 
	{
		if (strPath.indexOf("#") > 0) 
		{
			//document.location.href=  strPath + strSource;
			strSource=strSource+'#';
			//document.location.href=  strPath.replace('#',strSource);
			if(strPath.indexOf("?")>0)		
			{
				//document.location.href= strPath.replace('#',strSource.replace("?","&"));
				if((strPath.indexOf("?/portugal/consumer/appform/step2.jsp?cboCcardApply=1")>0) || (strPath.indexOf("?/portugal/consumer/appform/step2.jsp?cboCcardApply=2")>0) ||(strPath.indexOf("?/portugal/consumer/appform/step2.jsp?cboCcardApply=3")>0) || (strPath.indexOf("?/portugal/consumer/appform/step2.jsp?cboCcardApply=4")>0) || (strPath.indexOf("?/portugal/consumer/appform/step2.jsp?cboCcardApply=5")>0))
					document.location.href= strPath.replace('#',strSource.replace("?","&"));
				else if(strPath.indexOf("?/portugal/consumer/appform/step1.jsp")>0)
					document.location.href= strPath.replace('#',strSource);
                else if(strPath.indexOf("?/portugal/consumer/appform/step2.jsp")>0)
					document.location.href= strPath + strSource;
                else if(strPath.indexOf("?/portugal/consumer/retailform/step3.jsp")>0)
					document.location.href= strPath + strSource;
				else					
					document.location.href= strPath.replace('#',strSource.replace("?","&"));
			}
			else
				document.location.href=  strPath.replace('#',strSource);
			
			strNavPromo=strSource;
		}
		else
		{		
			//document.location.href= strPath +  strSource;		
			if(strPath.indexOf("?")>0)
			{
				//document.location.href= strPath +  strSource.replace("?","&");
				if((strPath.indexOf("?/portugal/consumer/appform/step2.jsp?cboCcardApply=1")>0) || (strPath.indexOf("?/portugal/consumer/appform/step2.jsp?cboCcardApply=2")>0) ||(strPath.indexOf("?/portugal/consumer/appform/step2.jsp?cboCcardApply=3")>0) || (strPath.indexOf("?/portugal/consumer/appform/step2.jsp?cboCcardApply=4")>0) || (strPath.indexOf("?/portugal/consumer/appform/step2.jsp?cboCcardApply=5")>0))
					document.location.href= strPath + strSource.replace("?","&");
				else if(strPath.indexOf("?/portugal/consumer/appform/step1.jsp")>0)
					document.location.href= strPath + strSource;
			    else if(strPath.indexOf("?/portugal/consumer/appform/step2.jsp")>0)
					document.location.href= strPath + strSource;
                else if(strPath.indexOf("?/portugal/consumer/retailform/step3.jsp")>0)
					document.location.href= strPath + strSource;
				else
					document.location.href= strPath + strSource.replace("?","&");
			}				
			else
				document.location.href= strPath +  strSource;			
		}
	}
	else
	{
		document.location.href= strPath;
		strNavPromo='';
	}

}*/
function fnSubmit(strPath){
//alert("hooooooooooooo");
	if (strSource != '') 
	{
		if (strPath.indexOf("#") > 0) 
		{
			//document.location.href=  strPath + strSource;
			strSource=strSource+'#';
			//document.location.href=  strPath.replace('#',strSource);
			if(strPath.indexOf("?")>0)		
			{
				//document.location.href= strPath.replace('#',strSource.replace("?","&"));

				if((strPath.indexOf("?/portugal/consumer/appform/cartoescredito.htm?cboCcardApply1=1")>0) || (strPath.indexOf("?/portugal/consumer/appform/cartoescredito.htm?cboCcardApply1=2")>0) ||(strPath.indexOf("?/portugal/consumer/appform/cartoescredito.htm?cboCcardApply1=3")>0) || (strPath.indexOf("?/portugal/consumer/appform/cartoescredito.htm?cboCcardApply1=4")>0) || (strPath.indexOf("?/portugal/consumer/appform/cartoescredito.htm?cboCcardApply1=5")>0))
				document.location.href= strPath.replace('#',strSource.replace("?","&"));
				else if((strPath.indexOf("?/portugal/consumer/appform/step2.jsp?tsst=1")>0) || (strPath.indexOf("?/portugal/consumer/appform/step2.jsp?cboCcardApply=1")>0) || (strPath.indexOf("?/portugal/consumer/appform/step2.jsp?cboCcardApply=2")>0) ||(strPath.indexOf("?/portugal/consumer/appform/step2.jsp?cboCcardApply=3")>0) || (strPath.indexOf("?/portugal/consumer/appform/step2.jsp?cboCcardApply=4")>0) || (strPath.indexOf("?/portugal/consumer/appform/step2.jsp?cboCcardApply=5")>0))
				document.location.href= strPath.replace('#',strSource.replace("?","&"));
				else if(strPath.indexOf("?/portugal/consumer/appform/cartoescredito.htm")>0)
				{
					document.location.href= strPath.replace('#',strSource);
				//document.location.href= strPath + strSource;
				}
				else if(strPath.indexOf("?/portugal/consumer/appform/account/aberturaconta.htm")>0)
				{
					document.location.href= strPath.replace('#',strSource);
					//document.location.href= strPath + strSource;
				}
			    else if(strPath.indexOf("?/portugal/consumer/appform/loan/creditopessoal.htm")>0)
				{
					document.location.href= strPath.replace('#',strSource);
			    //document.location.href= strPath + strSource;
				}
				else if(strPath.indexOf("?/portugal/consumer/abandon/abandonment.jsp")>0)
				document.location.href= strPath.replace('#',strSource);
				else if(strPath.indexOf("?/portugal/consumer/appform/step2.jsp")>0)
					document.location.href= strPath.replace('#',strSource);
				else if(strPath.indexOf("?/portugal/consumer/retailform/step3.jsp")>0)
					document.location.href= strPath.replace('#',strSource);
				else					
					document.location.href= strPath.replace('#',strSource.replace("?","&"));
			}
			else
				document.location.href=  strPath.replace('#',strSource);
			
			strNavPromo=strSource;
		}
		else
		{		
			//document.location.href= strPath +  strSource;		
			if(strPath.indexOf("?")>0)
			{
				//document.location.href= strPath +  strSource.replace("?","&");
				if((strPath.indexOf("?/portugal/consumer/appform/cartoescredito.htm?cboCcardApply1=1")>0) || (strPath.indexOf("?/portugal/consumer/appform/cartoescredito.htm?cboCcardApply1=2")>0) ||(strPath.indexOf("?/portugal/consumer/appform/cartoescredito.htm?cboCcardApply1=3")>0) || (strPath.indexOf("?/portugal/consumer/appform/cartoescredito.htm?cboCcardApply1=4")>0) || (strPath.indexOf("?/portugal/consumer/appform/cartoescredito.htm?cboCcardApply1=5")>0))
					document.location.href= strPath + strSource.replace("?","&");
				else if((strPath.indexOf("?/portugal/consumer/appform/cartoescredito.htm?cboCcardApply=1")>0) || (strPath.indexOf("?/portugal/consumer/appform/cartoescredito.htm?cboCcardApply=2")>0) ||(strPath.indexOf("?/portugal/consumer/appform/cartoescredito.htm?cboCcardApply=3")>0) || (strPath.indexOf("?/portugal/consumer/appform/cartoescredito.htm?cboCcardApply=4")>0) || (strPath.indexOf("?/portugal/consumer/appform/cartoescredito.htm?cboCcardApply=5")>0))
					document.location.href= strPath + strSource.replace("?","&");
				else if(strPath.indexOf("?/portugal/consumer/appform/cartoescredito.htm")>0)
				document.location.href= strPath + strSource;
				else if(strPath.indexOf("?/portugal/consumer/appform/account/aberturaconta.htm")>0)
				document.location.href= strPath + strSource;
			    else if(strPath.indexOf("?/portugal/consumer/appform/loan/creditopessoal.htm")>0)
			    document.location.href= strPath + strSource;
			   else if(strPath.indexOf("?/portugal/consumer/abandon/abandonment.jsp")>0)
					document.location.href= strPath + strSource;
				else if(strPath.indexOf("?/portugal/consumer/appform/step2.jsp")>0)
					document.location.href= strPath + strSource;
				else if(strPath.indexOf("?/portugal/consumer/retailform/step3.jsp")>0)
					document.location.href= strPath + strSource;
				else{
					document.location.href= strPath + strSource.replace("?","&");
					
					}
			}				
			else
				document.location.href= strPath + strSource;			
		}
	}
	else
	{
		document.location.href= strPath;
		strNavPromo='';
	}

}

//Cookie usage

function replaceChars(entry) {
out = "##&&##"; // replace this
add = "'"; // with this
temp = "" + entry; // temporary holder

while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add + 
temp.substring((pos + out.length), temp.length));
}
url2 = temp;
}

function setXcookie2(xlang,url)
{
	var LangValue = xlang;
	setCookie('belang',LangValue,'60');
	replaceChars(url)
	//alert(url2);
	location.href = url2;
}
function setXcookie(xSource)
{
	var SourceValue = xSource;
	setCookie('ptsource',SourceValue,'60');
}


function setCookie(NameOfCookie, value, expiredays) 
{ var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
document.cookie = NameOfCookie + "=" + escape(value) + 
((expiredays == null) ? "" : "; path=/; expires=" + ExpireDate.toGMTString());
}

function getCookie(NameOfCookie)
{ if (document.cookie.length > 0)
{ begin = document.cookie.indexOf(NameOfCookie+"="); 
if (begin != -1) 
{ begin += NameOfCookie.length+1; 
end = document.cookie.indexOf(";", begin);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(begin, end)); } 
}
return null; 
}

function delCookie (NameOfCookie) 
{ if (getCookie(NameOfCookie)) {
document.cookie = NameOfCookie + "=" +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}

///- END 