
var skypeaidkey = "willwayskyepeaid";
var piriod = 30;


var aid = getskypeaid();
if( aid == "" ){
	var path = window.location.pathname;
	var re1 = new RegExp("skype", "");
	var re2 = new RegExp("skypeclient", "");
	var re3 = new RegExp("html", "");
	var re4 = new RegExp("/", "g");
	var re5 = new RegExp("client", "");
	var aid = path.replace(re1,"");
	aid = aid.replace(re2,"");
	aid = aid.replace(re3,"");
	aid = aid.replace(re4,"");
	aid = aid.replace(re5,"");
	aid = aid.replace(".","");	
	if( aid != "" ){
		setskypeaid(aid);
	}
}


function getskypeaid(){
	var aid = "";
	if(document.cookie){
		var buf = document.cookie.split("; ");
		for( var i=0; i<buf.length; i++){
			var str = buf[i].split("=");
			if( str[0] == skypeaidkey ){
				aid = unescape( str[1] );
			}
		}
	}
	return aid;
}

function setskypeaid(aid){
	var date = new Date();
	var time = date.getTime();
	time += ( piriod * 24 * 60 * 60 * 1000);
	date.setTime(time);
	var expiresString = date.toGMTString();
	// クッキーのパスは skype.html も追加しておく。
	document.cookie= skypeaidkey + "=" + aid +"; expires=" + expiresString + "; path=/skype";
	document.cookie= skypeaidkey + "=" + aid +"; expires=" + expiresString + "; path=/skype/";
	document.cookie= skypeaidkey + "=" + aid +"; expires=" + expiresString + "; path=/skype.html";
	document.cookie= skypeaidkey + "=" + aid +"; expires=" + expiresString + "; path=/skype.php";
	document.cookie= skypeaidkey + "=" + aid +"; expires=" + expiresString + "; path=/skypeclient.html";
}


/*** Copyright 2009 WillWay corporation. All rights reserved. ***/

