﻿function getURLParam( name )
{ 
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results == null )
		return "pl";
	else    
		return results[1];
}


function gotoURLWithLng( websiteName )
{
	if (websiteName == 'home')
	{	
		switch(document.location.hostname.split('.')[document.location.hostname.split('.').length-1])
		{
			case 'de': url = "http://www.getsix.de"; break;
			case 'com': url = "http://www.getsix.com"; break;
			case 'pl': url = "http://www.getsix.pl"; break;
			default: url = "http://www.getsix.pl"; break;
		}
		window.location.href = url;
	}
	else if (websiteName == 'locationWR')
	{
	    var url;
	    switch(getURLParam("lng"))
		{
			case 'de': url = "/sitepages/team_wro_de.aspx?LeftMenuID=81&lng=de&TopMenuID=16"; break;
			case 'en': url = "/sitepages/team_wro_en.aspx?LeftMenuID=115&lng=en&TopMenuID=7"; break;
			case 'pl': url = "/sitepages/team_wro_pl.aspx?LeftMenuID=318&lng=pl&TopMenuID=1"; break;
			default: url = "/sitepages/team_wro_pl.aspx?LeftMenuID=318&lng=pl&TopMenuID=1"; break;
		}
		window.location.href = url;
	}
	else if (websiteName == 'locationPOZ')
	{
	    var url;
	    switch(getURLParam("lng"))
		{
			case 'de': url = "/sitepages/team_poz_de.aspx?LeftMenuID=82&lng=de&TopMenuID=16"; break;
			case 'en': url = "/sitepages/team_poz_en.aspx?LeftMenuID=116&lng=en&TopMenuID=7"; break;
			case 'pl': url = "/sitepages/team_poz_pl.aspx?LeftMenuID=319&lng=pl&TopMenuID=1"; break;
			default: url = "/sitepages/team_poz_pl.aspx?LeftMenuID=319&lng=pl&TopMenuID=1"; break;
		}
		window.location.href = url;
	}

	else
	{
		window.location.href = "/SitePages/" + websiteName + ".aspx?lng=" + getURLParam("lng");
	}
	 
	 return false;

}

function gotoCustomerPortal()
  {
  	var vars={};
  	var x=document.location.search.substring(1).split('&');
  	for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
  	var link = 'http://extranet.getsix.pl';
  	switch(vars['lng'])
  	{
 		case 'de': link = 'http://www.getsix.pl/sitepages/content.aspx?LeftMenuID=449&lng=de&TopMenuID=30'; break;
  		case 'pl': link = 'http://www.getsix.pl/sitepages/content.aspx?LeftMenuID=461&lng=pl&TopMenuID=31'; break;
  		case 'en': link = 'http://www.getsix.pl/sitepages/content.aspx?LeftMenuID=455&lng=en&TopMenuID=32'; break;
  		default: link = 'http://www.getsix.pl/sitepages/content.aspx?LeftMenuID=461&lng=pl&TopMenuID=31'; break;
  	}
  	
  	window.location = link;
	return false;
  }
  
  function gotoRegistrationPage()
  {
    var vars={};
  	var x=document.location.search.substring(1).split('&');
  	for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
  	var link = 'http://extranet.getsix.pl';
  	switch(vars['lng'])
  	{
  		case 'de': link = 'http://www.getsix.pl/SitePages/register_de.aspx?lng=de'; break;
  		case 'pl': link = 'http://www.getsix.pl/SitePages/register_pl.aspx'; break;
  		case 'en': link = 'http://www.getsix.pl/SitePages/register_en.aspx?lng=en'; break;
  		default: link = 'http://www.getsix.pl/SitePages/register_pl.aspx'; break;
  	}

  	window.location = link;
	return false;
  }


//function gotoCustomerPortal()
//{
	//window.location.href = "http://extranet.getsix.pl";
//	window.open('http://extranet.getsix.pl');
//	return false;
//}

function Add_Favorite_Link() 
{ 
	external.AddFavorite(location.href, document.title)
	// Add the document location and title to the AddFavorite window
}


function connectRedirect( websiteName )
{
	if( websiteName == 'Delicious')
	{
		window.open('http://del.icio.us/post?url='+location.href+'&title='+document.title)
	}
	if( websiteName == 'Google')
	{
		window.open('http://www.google.com/bookmarks/mark?op=add&bkmk='+location.href+'&title='+document.title)
	}
	if( websiteName == 'Digg')
	{
		window.open('http://digg.com/submit?phase=2&url='+location.href)
	}
	if( websiteName == 'Reddit')
	{
		window.open('http://reddit.com/submit?url='+location.href+'&title='+document.title)
	}
	if( websiteName == 'Yahoo')
	{
		window.open('http://myweb.yahoo.com/myresults/bookmarklet?t='+document.title+'&u='+location.href+'&ei=UTF-8')
	}



	


}



