////////////////setting Local connection session ID
var localconnectionsessionid = "";
function getRandomSessionString(){


	var a = Math.random();
	var b = Math.random();
	var c = Math.random();

	var sa = a.toString();
	var sb = b.toString();
	var sc = c.toString();

	var sessionid = sa+sb+sc;

	return sessionid;

}
function storeRandomSessionString(){

	if(localconnectionsessionid == ""){localconnectionsessionid = getRandomSessionString();}

}

function getLCSessionID(){

	return localconnectionsessionid;

}

///////////////////////////////////////////////////
///please do not remove this call in the JS file.
storeRandomSessionString();

//////////////////////////////////////////////////

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
function getVideoTimefromJavascriptCookie(titleorlocation){

	var title = readCookie("titleorlocation");

	if(title == titleorlocation){
		return readCookie("playtime");
	}else{
		return 0;
	}

}
function getSavedFilePlayedFromJavascriptCookie(){

	return readCookie("whichfileplayed");
}

function getMutedFromJavascriptCookie(){

	return readCookie("muted");
}

function saveDataToJavascriptCookie(titleorlocation,playtime,whichfileplayed,muted){

	createCookie("titleorlocation",titleorlocation,100);
	createCookie("playtime",playtime,100);
	createCookie("whichfileplayed",whichfileplayed,100);
	createCookie("muted",muted,100);

}