var url = document.URL.toLowerCase();
var urlArray = url.split("/");

lang = urlArray[3];
var domain = url.substring(0,url.indexOf("/"+urlArray[3]+"/") +1);
var path = "";

if((urlArray.length > 3) && (urlArray[3]=="en" || urlArray[3]=="kz"  || urlArray[3]=="ru")){
	path = url.substring(url.indexOf("/"+urlArray[3]+"/") + urlArray[3].length + 2,url.length);
} else {
	path = "";
}

// draw the rounded white div for content area
/*function roundedCorners() {
	
	if(document.getElementById('pageContainer')){
		var div = document.getElementById('pageContainer');
		var holder = document.createElement('div');
		
		holder.className = 'pageContainerHolder';
		
		div.parentNode.replaceChild(holder, div);
		
		var top = document.createElement('div');
		top.className = 'pageContainerTop';
		var bottom = document.createElement('div');
		bottom.className = 'pageContainerBottom';
		
		holder.appendChild(top);
		holder.appendChild(div);
		holder.appendChild(bottom);
	}
}*/

// for print button
function printpage() {
	window.print();
}

function swapLang(sLang){
	
	if(path == null || path == "") {
		Set_Cookie( 'TCO', sLang, '365', '/', '', '' );
		window.location = domain + sLang + "/";
		
	} else {
		window.location = domain + sLang + "/" + path;		
	}
}

function Set_Cookie( name, value, expires, path, domain, secure )
{
	var today = new Date();

	today.setTime( today.getTime() );
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		a_temp_cookie = a_all_cookies[i].split( '=' );
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

function getTitleNavContainerPos() {
	var winW = 978;
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth;
	  winH = window.innerHeight;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth;
	  winH = document.body.offsetHeight;
	 }
	}
	
	
	var conPos = (winW - 978)/2 + 20;
	conPos = conPos + '';
	return conPos;
}

//( Get_Cookie( 'test' ) ) ? alert( Get_Cookie('test')) : alert( 'it is gone');









