﻿var daysInMonthArray = [31,28,31,30,31,30,31,31,30,31,30,31];
var icmt;
var member_id='';
var viewsearch_x=0;
var varHtviewsearch=0;
var viewprogram_x=0;
var varHtviewprogram=0;
var viewvedio_x=0;
var varHtviewvideo=0;
var dupemail='0';
var DT_Long;
var DT_Watcher;
var DT_Watcher_out;
var HintClass = "hintTextbox";
var HintActiveClass = "hintTextboxActive";
var setfocus_user_pwd;
var email_dup=0;
var meclip_id='';
var childPage;
var countCloseFree ;
String.prototype.alltrim = function() { return this.replace(/^\s+|\s+$/g, ''); };


function open_close(){
	togglesearch('viewsearch',500,9);
	if (viewprogram_x==1)
		toggleprogram('viewprogram',500,9);
}

function togglevideo(tagid,Height,Speed) {
	
	if (Speed == 1) { y = 100; z = 1; } else
	if (Speed == 2) { y = 70; z = 1; } else
	if (Speed == 3) { y = 40; z = 1; } else
	if (Speed == 4) { y = 20; z = 1; } else
	if (Speed == 5) { y = 10; z = 1; } else
	if (Speed == 6) { y = 10; z = 2; } else
	if (Speed == 7) { y = 10; z = 4; } else
	if (Speed == 8) { y = 10; z = 7; } else
	if (Speed == 9) { y = 10; z = 10; } else
	{ y = 10; z = 4}
	
	if (document.getElementById(tagid).style.display != 'inline')
		document.getElementById(tagid).style.display = 'inline';
	if (viewvedio_x==0){
		document.getElementById(tagid).style.visibility="visible";
		document.getElementById(tagid).style.padding='0px';
		//document.getElementById(tagid).style.border="1px solid #666";
	}
	if (viewvedio_x === 0) {
		document.getElementById(tagid).style.height = varHtviewvideo+'px';
		if (((Height-varHtviewvideo) < z) && (varHtviewvideo !== Height)) {
			varHtviewvideo = Height;
		} else {
			varHtviewvideo = varHtviewvideo+z;
		}
		if (varHtviewvideo <= Height) {
			setTimeout("togglevideo('"+tagid+"',"+Height+","+Speed+")",y);
		}
		if (varHtviewvideo > Height) {
			varHtviewvideo = Height;
			viewvedio_x = 1;
			document.getElementById("anchor1").style.height=container_height_max+'px';

			//movetopplayer();
		}
	} else {
		document.getElementById(tagid).style.height = varHtviewvideo+'px';
		varHtviewvideo = varHtviewvideo-z;
		if ((Height-varHtviewvideo) <= Height) {
			setTimeout("togglevideo('"+tagid+"',"+Height+","+Speed+")",y);
		}
		if ((Height-varHtviewvideo) > Height) {
			varHtviewvideo = 0;
			document.getElementById(tagid).style.height = varHtviewvideo+'px';
			document.getElementById(tagid).style.visibility="hidden";
			document.getElementById(tagid).style.padding='0px';
			//document.getElementById(tagid).style.border="0px solid #666";
			viewvedio_x = 0;
			document.getElementById("anchor1").style.height=container_height_min+'px';
			//document.getElementById('playingvideo').controls.stop();
			//document.getElementById('playmovie').stop();
			stoplayershowblank();
		}
		
	}
	//alert("1varHt="+varHtviewvideo+",Ht="+Height+",x"+viewvedio_x);
}

function togglesearch(tagid,Height,Speed) {
	
	if (Speed == 1) { y = 100; z = 1; } else
	if (Speed == 2) { y = 70; z = 1; } else
	if (Speed == 3) { y = 40; z = 1; } else
	if (Speed == 4) { y = 20; z = 1; } else
	if (Speed == 5) { y = 10; z = 1; } else
	if (Speed == 6) { y = 10; z = 2; } else
	if (Speed == 7) { y = 10; z = 4; } else
	if (Speed == 8) { y = 10; z = 7; } else
	if (Speed == 9) { y = 10; z = 10; } else
	{ y = 10; z = 4}
	
	if (document.getElementById(tagid).style.display != 'inline')
		document.getElementById(tagid).style.display = 'inline';
	if (viewsearch_x==0){
		document.getElementById(tagid).style.visibility="visible";
		document.getElementById(tagid).style.padding='3px';
		//document.getElementById(tagid).style.border="1px solid #666";
	}
	if (viewsearch_x === 0) {
		document.getElementById(tagid).style.height = varHtviewsearch+'px';
		if (((Height-varHtviewsearch) < z) && (varHtviewsearch !== Height)) {
			varHtviewsearch = Height;
		} else {
			varHtviewsearch = varHtviewsearch+z;
		}
		if (varHtviewsearch <= Height) {
			setTimeout("togglesearch('"+tagid+"',"+Height+","+Speed+")",y);
		}
		if (varHtviewsearch > Height) {
			varHtviewsearch = Height;
			viewsearch_x = 1;
		}
	} else {
		document.getElementById(tagid).style.height = varHtviewsearch+'px';
		varHtviewsearch = varHtviewsearch-z;
		if ((Height-varHtviewsearch) <= Height) {
			setTimeout("togglesearch('"+tagid+"',"+Height+","+Speed+")",y);
		}
		if ((Height-varHtviewsearch) > Height) {
			varHtviewsearch = 0;
			document.getElementById(tagid).style.height = varHtviewsearch+'px';
			document.getElementById(tagid).style.visibility="hidden";
			document.getElementById(tagid).style.padding='0px';
			//document.getElementById(tagid).style.border="0px solid #666";
			viewsearch_x = 0;
			//alert("1varHt="+varHtviewsearch+",Ht="+Height+",x"+viewsearch_x);
			//alert("div height="+document.getElementById(tagid).offsetHeight+",varHtviewsearch:"+varHtviewsearch);
		}
		
	}
	//alert("1varHt="+varHtviewsearch+",Ht="+Height+",x"+viewsearch_x);
}

function toggleprogram(tagid,Height,Speed) {
	
	if (Speed == 1) { y = 100; z = 1; } else
	if (Speed == 2) { y = 70; z = 1; } else
	if (Speed == 3) { y = 40; z = 1; } else
	if (Speed == 4) { y = 20; z = 1; } else
	if (Speed == 5) { y = 10; z = 1; } else
	if (Speed == 6) { y = 10; z = 2; } else
	if (Speed == 7) { y = 10; z = 4; } else
	if (Speed == 8) { y = 10; z = 7; } else
	if (Speed == 9) { y = 10; z = 10; } else
	{ y = 10; z = 4}
	
	if (document.getElementById(tagid).style.display != 'inline')
		document.getElementById(tagid).style.display = 'inline';
	if (viewprogram_x==0){
		document.getElementById(tagid).style.visibility="visible";
		document.getElementById(tagid).style.padding='3px';
		//document.getElementById(tagid).style.border="1px solid #666";
	}
	if (viewprogram_x === 0) {
		document.getElementById(tagid).style.height = varHtviewprogram+'px';
		if (((Height-varHtviewprogram) < z) && (varHtviewprogram !== Height)) {
			varHtviewprogram = Height;
		} else {
			varHtviewprogram = varHtviewprogram+z;
		}
		if (varHtviewprogram <= Height) {
			setTimeout("toggleprogram('"+tagid+"',"+Height+","+Speed+")",y);
		}
		if (varHtviewprogram > Height) {
			varHtviewprogram = Height;
			viewprogram_x = 1;
		}
	} else {
		document.getElementById(tagid).style.height = varHtviewprogram+'px';
		varHtviewprogram = varHtviewprogram-z;
		if ((Height-varHtviewprogram) <= Height) {
			setTimeout("toggleprogram('"+tagid+"',"+Height+","+Speed+")",y);
		}
		if ((Height-varHtviewprogram) > Height) {
			varHtviewprogram = 0;
			document.getElementById(tagid).style.height = varHtviewprogram+'px';
			document.getElementById(tagid).style.visibility="hidden";
			document.getElementById(tagid).style.padding='0px';
			//document.getElementById(tagid).style.border="0px solid #666";
			viewprogram_x = 0;
		}
		
	}
}


function Call_Inint_AJAX()
{
	var _HttPRequest = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		_HttPRequest = new XMLHttpRequest();
		if (_HttPRequest.overrideMimeType) {
			_HttPRequest.overrideMimeType('text/html');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			_HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				_HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	} 
	return _HttPRequest;
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function userloginfrm(frm){
	var email=trim(frm.user_email.value);
	if (email.length>0){
		document.getElementById("msgloginid").innerHTML = " ";
		save_loginfrm();
		var user_email=frm.user_email.value;
		var user_pwd=frm.user_pwd.value;

		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			}
		
		var url = "loginmember.php?user_email="+user_email+"&user_pwd="+user_pwd;
		
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("msgloginid").innerHTML = "<img src='images/waiting/doothaitv-loading.gif' height='15'/>";
				}
			if(HttPRequest.readyState == 4) // Return Request
				{
					document.getElementById("msgloginid").innerHTML = " ";
					if (HttPRequest.responseText=='0')
						alert("กรุณาสมัครเป็นสมาชิกก่อนค่ะ : Please register to member.");
					else
					  document.getElementById("loginmemberid").innerHTML = HttPRequest.responseText;
					  window.location="home.php";
				}
		}
		
	}
}

function loadupdatetoday(){
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			}
		
		var url = "updatetoday.php";
		
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("updatetoday").innerHTML = "<img src='images/waiting/doothaitv-loading.gif' height='15'/>";
				}
			if(HttPRequest.readyState == 4) // Return Request
				{
					document.getElementById("updatetoday").innerHTML = " ";
					document.getElementById("updatetoday").innerHTML = HttPRequest.responseText;
				}
		}
	
}

function searchar(ch){
	smoothScroll('anchor3');
	var HttPRequest = Call_Inint_AJAX();
	if (!HttPRequest) {
		alert('Cannot create XMLHTTP instance');
		return false;			}
	
	var url = "searchchar.php?ch="+ch;
	
	HttPRequest.open('GET',url,true);
	HttPRequest.send(null);
	
	
	HttPRequest.onreadystatechange = function()
	{
		if(HttPRequest.readyState == 3)  // Loading Request
			{
				document.getElementById("searchresult").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:365px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
			}
		if(HttPRequest.readyState == 4) // Return Request
			{
				document.getElementById("searchresult").innerHTML = HttPRequest.responseText;
			}
	}
}

function searchclipname(){
	smoothScroll('anchor3');
	//var keysearch=trim(searchfrm.keysearch.value);
	var keysearch= document.getElementById("keysearch").value;
	//alert(searchfrm.keysearch.value);
	if (keysearch.length>0 && keysearch!="ค้นหารายการ"){
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			}
		
		var url = "searchclipname.php?keysearch="+keysearch;
		
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("searchresult").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:365px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
				}
			if(HttPRequest.readyState == 4) // Return Request
				{
					document.getElementById("searchresult").innerHTML = HttPRequest.responseText;
					
				}
		}
		
	}
}

function searchclipnameold(){

	var keysearch=trim(searchfrm.keysearch.value);
	if (keysearch.length>0 && keysearch!="ค้นหารายการ"){
		if (viewprogram_x==1)
			toggleprogram('viewprogram',500,9);

		if (viewsearch_x==0)
			togglesearch('viewsearch',500,9);

			var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			}
		
		var url = "searchclipname.php?keysearch="+keysearch;
		
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("searchresult").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:365px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
				}
			if(HttPRequest.readyState == 4) // Return Request
				{
					gTop=-500;
					while (gTop!=0)
						scrollMe(-1);
					document.getElementById("searchresult").innerHTML = HttPRequest.responseText;
					
				}
		}
		
	}
}

function livetime(tagid){
	TabbedPanels1.showPanel(0);
	smoothScroll('anchor3');
	
	var id=parseInt(tagid);
	var url;
	if (id==1) //Live Radio
		url = "freetvchannel.php";
	else if (id==2)
		url = "live_radio.php";
	else if (id==3){
		if (viewvedio_x==1)
			setTimeout("togglevideo('playvedio',545,9);",500);
	
		url = "radio_doothaitv.php";
		document.getElementById('playingvideo').controls.stop();
	}

	var HttPRequest = Call_Inint_AJAX();
	if (!HttPRequest) {
		alert('Cannot create XMLHTTP instance');
		return false;			
	}
		
	HttPRequest.open('GET',url,true);
	HttPRequest.send(null);
		
		
	HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("listprogram").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
					//"<img src='images/ajax/ajax-loader-light.gif' height='15'/>";
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("listprogram").innerHTML = HttPRequest.responseText;				
					smoothScroll('anchor3');
				}
		}
		
	
}

function loadmovie(clip_id){
	if (parseInt(clip_id)>0){
		if (viewvedio_x==0)
			setTimeout("togglevideo('playvedio',545,9);",500);
		
	}
}

function listmoviechapter(clip_id,chapter_id,clip_trailer){
	meclip_id=clip_id;
	if (document.getElementById("member_expire")!=null&&parseInt(document.getElementById("member_expire").value)==1)
		var me_expire=1;
	else
		var me_expire=0;
	if (document.getElementById("member_id")!=null&&parseInt(document.getElementById("member_id").value)>0)
		var me_id=parseInt(document.getElementById("member_id").value);
	else
		var me_id=0;
	if (parseInt(chapter_id)>0){
		if (me_expire==1){
			loadmoviechapter(clip_id);
			runmovie(clip_id,chapter_id);
		}else{
			if (clip_trailer==1){
				if (me_id>0){
					loadmoviechapter(clip_id);
					runmovie(clip_id,chapter_id);
					playtimerlogin();
				}else{
					loadmoviechapter(clip_id);
					runmovie(clip_id,chapter_id);
					playtimer();
				}
			}else{
				if (me_id>0)
					linkdoc("member_payment.php");
				else
					linkdoc("registermember.php");
			}
		}
	}else
		loadmoviechapter(clip_id);
}

function loadmoviechapter(clip_id){
	if (parseInt(clip_id)>0){
		//movetopplayer();
		meclip_id=clip_id;
		// smoothScroll('anchor2');  wiway
		
		var HttPRequest = Call_Inint_AJAX();
		
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		
		var url = "moviechapter.php?clip_id="+clip_id;
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("moviechapter").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:597px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("moviechapter").innerHTML = HttPRequest.responseText;				
					//movetopplayer();
					//if (viewvedio_x==0)
						//newwindowplayer();
						
				}
		}
		loadmoviedetail(clip_id);		
	}
}

function loadchapterplayerout(clip_id){
	if (parseInt(clip_id)>0){
		
		var HttPRequest = Call_Inint_AJAX();
		
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		
		var url = "moviechapter.php?clip_id="+clip_id;
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("playeroutmoviechapter").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:597px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("playeroutmoviechapter").innerHTML = HttPRequest.responseText;				
					
				}
		}
		loadmoviedetail(clip_id);		
	}
}

function loadmoviedetail(clip_id){
	if (parseInt(clip_id)>0){
		

		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		
		var url = "moviedetail.php?clip_id="+clip_id;
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("moviedetail").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:130px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("moviedetail").innerHTML = HttPRequest.responseText;				
				}
		}
		loadmovietitle(clip_id);
	}
}

function loadmovietitle(clip_id){
	if (parseInt(clip_id)>0){
		
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		
		var url = "movietitle.php?clip_id="+clip_id;
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("movietitle").innerHTML = "<img src='images/waiting/doothaitv-loading.gif' align='absmiddle'>";   
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("movietitle").innerHTML = HttPRequest.responseText;				
				}
		}
		
	}
}

function searchpromgram(group_id,pageno){
	if (group_id.length>0){
		if (parseInt(pageno)==0)
			pageno='1';
		//smoothScroll('anchor3');
		TabbedPanels1.showPanel(0);
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		document.getElementById("listprogram").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
		var url = "searchprogram.php?group_id="+group_id+"&pageno="+pageno;
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("listprogram").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
					//"<img src='images/ajax/ajax-loader-light.gif' height='15'/>";
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("listprogram").innerHTML = HttPRequest.responseText;
					//smoothScroll('anchor3');
				}
		}
		
	}
}

function searchlastprograms(group_id,pageno){
	if (group_id.length>0){
		if (parseInt(pageno)==0)
			pageno='1';
		//smoothScroll('anchor3');
		TabbedPanels1.showPanel(0);
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		document.getElementById("listprogram").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
		var url = "searchlastprograms.php?group_id="+group_id+"&pageno="+pageno;
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("listprogram").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
					//"<img src='images/ajax/ajax-loader-light.gif' height='15'/>";
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("listprogram").innerHTML = HttPRequest.responseText;
					//smoothScroll('anchor3');
				}
		}
		
	}
}

function searchlakorn(group_id,pageno){
	if (group_id.length>0){
		if (parseInt(pageno)==0)
			pageno='1';
		smoothScroll('anchor3');
		TabbedPanels1.showPanel(0);
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		document.getElementById("listprogram").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
		var url = "searchlakorn.php?group_id="+group_id+"&pageno="+pageno;
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("listprogram").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
					//"<img src='images/ajax/ajax-loader-light.gif' height='15'/>";
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("listprogram").innerHTML = HttPRequest.responseText;
					smoothScroll('anchor3');
				}
		}
		
	}
}

function search_trailer(group_id,pageno){
	if (group_id.length>0){
		if (parseInt(pageno)==0)
			pageno='1';
		smoothScroll('anchor3');
		TabbedPanels1.showPanel(0);
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		document.getElementById("listprogram").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
		var url = "searchtrailer.php?group_id="+group_id+"&pageno="+pageno;
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("listprogram").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
					//"<img src='images/ajax/ajax-loader-light.gif' height='15'/>";
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("listprogram").innerHTML = HttPRequest.responseText;
					smoothScroll('anchor3');
				}
		}
		
	}
}
function search_lakorn(group_id,pageno){
	if (group_id.length>0){
		if (parseInt(pageno)==0)
			pageno='1';
		smoothScroll('anchor3');
		TabbedPanels1.showPanel(1);
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		document.getElementById("listprogram").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
		var url = "searchlakorn.php?group_id="+group_id+"&pageno="+pageno;
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("listprogram").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
					//"<img src='images/ajax/ajax-loader-light.gif' height='15'/>";
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("listprogram").innerHTML = HttPRequest.responseText;
					smoothScroll('anchor3');
				}
		}
		
	}
}

function search_maxview(group_id,pageno){
	if (group_id.length>0){
		if (parseInt(pageno)==0)
			pageno='1';
		smoothScroll('anchor3');
		TabbedPanels1.showPanel(2);
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		document.getElementById("listprogram").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
		var url = "searchmaxview.php?group_id="+group_id+"&pageno="+pageno;
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("listprogram").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
					//"<img src='images/ajax/ajax-loader-light.gif' height='15'/>";
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("listprogram").innerHTML = HttPRequest.responseText;
					smoothScroll('anchor3');
				}
		}
		
	}
}




function useredit(){
	alert(document.getElementById("member_id").value);
}

function usersignout(){
	if((childPage != null)&& (!childPage.closed))
	{
		window.open('','_self','');
		childPage.window.close();
		window.location="usersignout.php";
	}else{window.location="usersignout.php";}

}

function save_loginfrm(){
	var i_username=document.loginfrm.user_email.value;
	var i_password=document.loginfrm.user_pwd.value;
	var days=30; 
	var date = new Date();
	date.setTime(date.getTime()+(days*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = "chk_user_email=" +i_username+ "; expires=" + expires + "; path=/";
	document.cookie = "chk_user_password=" +i_password+ "; expires=" + expires + "; path=/";
	//alert(document.cookie);
}

function playvideofull(){
	try{
		if (document.getElementById("playbrowser").value=='firefox')
		{
			document.getElementById('playingvideo2').fullScreen=true;
		}
	else{
		
			document.getElementById('playingvideo').fullScreen=true;
		}
		
		}catch(e){
			alert("Please click again when video already playing[กรุณาคลิกอีกครั้งหลังจากวีดีโอเล่นแล้วนะคะ]")
	}
}

function playerfullscreen(){

	try{
			document.getElementById('doothaitvplayingvideo').fullScreen=true;
	}catch(e){
			alert("Please click again when video already playing[กรุณาคลิกอีกครั้งหลังจากวีดีโอเล่นแล้วนะคะ]")
		}
}

function runmovie(clip_id,chapter_id,row){
	if ((parseInt(clip_id)>0)&&(parseInt(chapter_id)>0)){
		var table = document.getElementById("moviechaptertbl");
		var rowCount = table.rows.length;
		if (rowCount>0)
			for (var n=0; n<rowCount; n++){
				if (n==parseInt(row))
					table.rows[n].cells[0].innerHTML="<img src='images/button_blue_play.png' style='float:left;'  width='15' height='15'/>";
				else
					table.rows[n].cells[0].innerHTML="<img src='images/play_button.png' style='float:left;'  width='15' height='15'/>";
			}
		smoothScroll('anchor2');
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		
		var url = "runmovie.php?clip_id="+clip_id+"&chapter_id="+chapter_id+"&longplay=5";
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("movieplay").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("movieplay").innerHTML = HttPRequest.responseText;
					starticmt();
				}
		}
		
	}
}

function doothaitvrunmovie(clip_id,chapter_id,row){
	if ((parseInt(clip_id)>0)&&(parseInt(chapter_id)>0)){
		var table = document.getElementById("doothaitvchaptertbl");
		var rowCount = table.rows.length;
		
		if (rowCount>0)
			for (var n=0; n<rowCount; n++){
				if (n==parseInt(row))
					table.rows[n].cells[0].innerHTML="<img src='images/button_blue_play.png' style='float:left;'  width='15' height='15'/>";
				else
					table.rows[n].cells[0].innerHTML="<img src='images/play_button7.png' style='float:left;'  width='15' height='15'/>";
			}
		
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		
		var url = "doothaitvrunmovie.php?clip_id="+clip_id+"&chapter_id="+chapter_id+"&longplay=5";
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("doothaitvmovieplay").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
				}
				
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("doothaitvmovieplay").innerHTML = HttPRequest.responseText;
					//var res = document.getElementById("doothaitvplayingjw").innerHTML;
					//eval(res);
					if(document.getElementById("doothaitvplayingjw")){
						var path_file = document.getElementById("doothaitvplayingjw").value
						 jwplayer('doothaitvplayingvide').setup({
						    'flashplayer': './jwplayer/player.swf',
						    'file': path_file,
						    'start': '0',
						    'provider': 'http',
						    'controlbar': 'bottom',
						    'width': '100%',
						    'height': '100%',
						    'autostart':true,
							'bgcolor':'undefined',
							'allowfullscreen':'true',
							'allowscriptaccess':'always',
							'skin':'/SkinPlayer/modieus/modieus2.zip',
							'bufferlength':'15',
							'stretching':'exactfit',
							'wmode':'transparent',
							'events':{
								'onError': function(event){
									var $j = jQuery.noConflict();
									var memberid = $j('#member_id').val();
									var pathfileid = $j('#doothaitv_nowpathfileid').val();
									var pathfilechapter = $j('#doothaitv_nowpathfilechapter').val();
									var clipid = $j('#clip_id').val();

									var HttpPost = 'pathfileid=' + pathfileid + '&pathfilechapter=' + pathfilechapter + '&memberid=' + memberid + '&clipid=' + clipid + '&type=jwplayer';

									$j.ajax({
											type:	"POST",
											url:	"reportfile.php",
											data:	HttpPost,
											cache:	false,
											success:	function(html){
																			//alert('ทางทีมงานได้รับเรื่องเรียบร้อยแล้ว ขอบคุณค่ะ'); 
											}
									});

								}
							}
						  });
					}
					
					starticmt();
					Last_clipID = clip_id;
					Last_chapterID = chapter_id;
					Last_row = row;
				}
		}
		
	}
}

function androidrunmovie(clip_id,chapter_id,row){
	if ((parseInt(clip_id)>0)&&(parseInt(chapter_id)>0)){
		var table = document.getElementById("doothaitvchaptertbl");
		var rowCount = table.rows.length;
		
		if (rowCount>0)
			for (var n=0; n<rowCount; n++){
				if (n==parseInt(row))
					table.rows[n].cells[0].innerHTML="<img src='images/button_blue_play.png' style='float:left;'  width='15' height='15'/>";
				else
					table.rows[n].cells[0].innerHTML="<img src='images/play_button7.png' style='float:left;'  width='15' height='15'/>";
			}
		
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		
		var url = "androidrunmovie.php?clip_id="+clip_id+"&chapter_id="+chapter_id+"&longplay=5";
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("doothaitvmovieplay").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("doothaitvmovieplay").innerHTML = HttPRequest.responseText;
					starticmt();
					Last_clipID = clip_id;
					Last_chapterID = chapter_id;
					Last_row = row;
					
				}
		}
		
	}
}

function runfreemovie(address,caption){
		smoothScroll('anchor3');

		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		
		var url = "runfreemovie.php?address="+address;
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("movieplay").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("movieplay").innerHTML = HttPRequest.responseText;
					document.getElementById("movietitle").innerHTML=caption;
					document.getElementById("moviedetail").innerHTML=" ";
					document.getElementById("moviechapter").innerHTML=" ";
					starticmt();
					if (viewvedio_x==0)
						setTimeout("togglevideo('playvedio',545,9);",500);
				}
		}
		
}

function checkspeed2(){
	var PopWidth=400;
	var PopHeight=600;
	if (navigator.appName.indexOf('Netscape') != -1){ var PopHeight=500; }
 
	var PopLeft = (window.screen.width-PopWidth)/2;
	var PopTop = (window.screen.height-PopHeight)/2;
	var demo=window.open('speedcheck.php','demo','toolbar=no,status=no,menuPopWidnowbar=no,location=no,directories=no,resizable=no,scrollbars=no,width='+PopWidth+',height='+PopHeight+',top='+PopTop+',left='+PopLeft);
}

function checkspeed(){
	var PopWidth=400;
	var PopHeight=600;
	if (navigator.appName.indexOf('Netscape') != -1){ var PopHeight=500; }
 
	var PopLeft = (window.screen.width-PopWidth)/2;
	var PopTop = (window.screen.height-PopHeight)/2;
	if (chkspeed)
		chkspeed.close();
	var chkspeed=window.open('','chkspeedfrm','toolbar=no,status=no,menuPopWidnowbar=no,location=no,directories=no,resizable=no,scrollbars=no,width='+PopWidth+',height='+PopHeight+',top='+PopTop+',left='+PopLeft);
	
	chkspeed.document.write("<html><head></head>");
	chkspeed.document.write("<style type='text/css'><!-- body{background-image: url(bandwidthmeter/bg.jpg); background-repeat: no-repeat;} ");
	chkspeed.document.write(" .style7 {color: #3366FF} .style12 {color: #3366FF; font-weight: bold; font-size: 10px; } --></style>");
	chkspeed.document.write("<center><br /><br /><br /><br /><br /><br/><br/>");
	chkspeed.document.write("<div id='speedcheckerdiv'></div>");
	chkspeed.document.write("<div id='speedchecker_link'>");
    
	chkspeed.document.write("<div id='speedcheckerdiv'></div><div id='speedchecker_link'>");
    chkspeed.document.write("<p>Provided by <a href='http://www.broadbandspeedchecker.co.uk'>Internet Speed Test</a></p>");
    chkspeed.document.write("<table width='290' border='1' bordercolor='#333333' bgcolor='#F0F0F0'>");
    chkspeed.document.write("<tr><td width='170'><div align='center'><span class='style12'>&#3649;&#3609;&#3632;&#3609;&#3635;&#3651;&#3627;&#3657;&#3626;&#3641;&#3591;&#3585;&#3623;&#3656;&#3634;</span></div></td>");
    chkspeed.document.write("<td width='209'><div align='center'><span class='style12'>&gt; 12,000 Kbps</span></div></td>");
    chkspeed.document.write("</tr><tr><td><div align='center'><span class='style12'>&#3588;&#3623;&#3634;&#3617;&#3648;&#3619;&#3655;&#3623;&#3617;&#3634;&#3605;&#3619;&#3600;&#3634;&#3609;</span></div></td>");
    chkspeed.document.write("<td><div align='center'><span class='style12'>8,000 Kbps  - 12,000 Kbps</span></div></td>");
    chkspeed.document.write("</tr><tr><td><div align='center'><span class='style12'>&#3629;&#3634;&#3592;&#3592;&#3632;&#3605;&#3657;&#3629;&#3591;&#3619;&#3629;&#3650;&#3627;&#3621;&#3604;&#3648;&#3621;&#3655;&#3585;&#3609;&#3657;&#3629;&#3618;</span></div></td>");
	chkspeed.document.write("<td><div align='center'><span class='style12'>&lt; 8000 Kbps</span></div></td></tr></table>");
	chkspeed.document.write("<p class='style7'><a href='#' onclick='window.close();'><img src='bandwidthmeter/back.png' width='202' height='50' border='0' usemap='#Map' />");
    chkspeed.document.write("</a></p></div></center>");
	chkspeed.document.write("<script language='javascript'>sc_hc='0xFF9933';sc_bc='0xACACAC';sc_bgc='0xFFFFFF';sc_cc='0x000000';sc_h=235;sc_w=375;sc_location='TH';sc_skin='1'</script><script src='http://s3.amazonaws.com/speedchecker/speedchecker.js'></script>");
	chkspeed.document.close();
	
}
function disableEnterLeftKey(e)
{
	 var key;

     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox
		  
	if(key==13)
	{
		searchByKey();
		return false;
	}else
          return true;
        
}

function disableEnterKey(e)
{
	
     var key;

     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox

     if(key == 13){
		//document.getParameterById("searchbtn").focus();
		searchclipname();
        return false;
	}
     else
          return true;
}

function disableEnterKeyLogin(e,frm)
{
     var key;

     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox

     if(key == 13){
		//document.getParameterById("searchbtn").focus();
		
		userloginfrm(frm);
        return false;
	}
     else
          return true;
}

function editcustomer(){
		
		TabbedPanels1.showPanel(0);
		smoothScroll('anchor3');
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		
		var url = "customerfrm.php";
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("listprogram").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("listprogram").innerHTML = HttPRequest.responseText;				
					smoothScroll('anchor3');
				}
		}
}

function savecustomerperson(frm){
	var member_firstname=trim(frm.member_firstname.value);
	var member_lastname=trim(frm.member_lastname.value);
	var email_address=trim(frm.email_address.value);
	var member_password1=trim(frm.member_password1.value);
	var member_password2=trim(frm.member_password2.value);
	var msg="";
	var flag_pass=true;
	if (member_firstname.length==0){
		flag_pass=false;
		msg+="Required First Name\n";
	}
	if (member_lastname.length==0){
		flag_pass=false;
		msg+="Required Last Name\n";
	}
	if (email_address.length==0){
		flag_pass=false;
		msg+="Required E-Mail Address\n";
	}
	if (leng(member_password1)<5){
		flag_pass=false;
		msg+="Your password must contain a minimum of 5 characters.\n";
	}
	if (member_password1!=member_password2){
		flag_pass=false;
		msg+="The password confirmation must match your password.\n";
	}
	if (flag_pass){
		if ((flag_pass)&&confirm('Are you sure save?/คุณแน่ใจที่ต้องการบันทึกใช่หรือไม่?')){
			frm.member_password.value=member_password1;
			frm.submit();
		}
	}else alert(msg);
}

function linkdoc(url){
		TabbedPanels1.showPanel(0);
		
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		
		//var url = "contactus.php";
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("listprogram").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("listprogram").innerHTML = HttPRequest.responseText;
					//smoothScroll('anchor3');
				}
		}	
}

function checkdupemail(e_mail){
	
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		
		var url = "dupemail.php?email="+e_mail;
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		email_dup=0;
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("msgemail").innerHTML = 'Loading...';
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					var dupemail=HttPRequest.responseText;
					if (parseInt(dupemail)!=0){
						document.getElementById("msgemail").innerHTML = e_mail+" is not available";
						email_dup=1;
					}
					else{
						email_dup=0;
						document.getElementById("msgemail").innerHTML = " ";
					}
				}
		}	
}

function savecustomer(frm){

	var HttPRequest = Call_Inint_AJAX();
	if (!HttPRequest) {
		alert('Cannot create XMLHTTP instance');
		return false;			
	}

		var gender=radio_value(frm.gender);
		var firstname=frm.firstname.value;
		var lastname=frm.lastname.value;
		var email=frm.email.value;
		var passwd=frm.passwd.value;
		var refer_id=radio_value(frm.refer_id);
		var refer=frm.refer.value;
		
		var url = "savecustomer.php?gender="+gender+"&firstname="+firstname+"&lastname="+lastname+"&email="+email+"&passwd="+passwd;
		url+="&refer_id="+refer_id+"&refer="+refer;
		
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("msgcustomer").innerHTML = 'Loading...';
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("msgcustomer").innerHTML = HttPRequest.responseText;
				}
		}

}


function emailCheck (emailStr) {
emailStr=trim(emailStr);
if (emailStr.length==0)
	return false;
/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

alert("Email address seems incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters.");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("The username doesn't seem to be valid.");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The address must end in a well-known domain or two letter " + "country.");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("This address is missing a hostname!");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}

function checkEmail(txtobj){
	
	var chk=emailCheck(txtobj.value);
	if (!chk)
		txtobj.value="";
}

function leng(s){
	var t=trim(s);
	return t.length;
}
function checkregister(frm){
	var error_flag=false;
	var error_message = "Errors have occured during the process of your form.\n\nPlease make the following corrections:\n\n";
	frm.firstname.value=trim(frm.firstname.value);
	frm.email.value=trim(frm.email.value);
	frm.email_confirm.value=trim(frm.email_confirm.value);
	frm.passwd.value=trim(frm.passwd.value);
	frm.passwd_confirm.value=trim(frm.passwd_confirm.value);
	
	//error_message+="Your Password must contain a minimum of 5 characters.\n";
	if (leng(frm.firstname.value)<2){
		error_flag=true;
		error_message+="Your First Name must contain a minimum of 2 characters.\n";
	}
	frm.lastname.value=trim(frm.lastname.value);
	if (leng(frm.lastname.value)<2){
		error_flag=true;
		error_message+="Your Last Name must contain a minimum of 2 characters.\n";
	}
	if (leng(frm.email.value)<6){
		error_flag=true;
		error_message+="Your E-Mail Address must contain a minimum of 6 characters.\n";
	}
	if (parseInt(email_dup)!=0){
		error_flag=true;
		error_message+="*Your E-Mail Address already in use.\n";
	}
	if (frm.email.value!=frm.email_confirm.value){
		error_flag=true;
		error_message+="Your E-Mail Address Confirmation must match your E-Mail Address.\n";
	}
	if (leng(frm.passwd.value)<5){
		error_flag=true;
		error_message+="Your Password must contain a minimum of 5 characters.\n";
	}
	if (frm.passwd.value!=frm.passwd_confirm.value){
		error_flag=true;
		error_message+="The Password Confirmation must match your Password.\n";
	}
	var chkrefer=false;
	for (i=0; i<frm.refer_id.length; i++){
		if (frm.refer_id[i].checked)
			chkrefer=true;
	}
	if (!chkrefer){
		error_flag=true;
		error_message+="Your need to select reference website\n";
	}
	if (parseInt(dupemail)>0){
		error_flag=true;
		error_message+="E-Mail >>"+frm.email.value+"<< is not available";
	}
	if (error_flag)
		alert(error_message);
	else{
		if (confirm("Are you sure register?\nคุณต้องการสมัครสมาชิกใช่หรือไม่?")){
			document.getElementById("registerbtn").value="บันทึกเสร็จแล้วกรุณาเติมเงินด้วยค่ะ";
			document.getElementById("registerbtn").disabled=true;
			//registerfrm.submit();
			frm.submit();
		}
	}
}

function refer_click(frm){
	for (i=0; i<frm.refer_id.length; i++){
		frm.refer.value="";
		if ((frm.refer_id[i].checked)&&(frm.refer_id[i].value=='9')){
			document.getElementById("refer").style.visibility="visible";
		}
		else
			document.getElementById("refer").style.visibility="hidden";
	}
}

function radio_value(obj){
	var value="";
	for (i=0; i<obj.length; i++){
		if (obj[i].checked)
			value=obj[i].value;
	}
	return value;
}

function setradio(objname,v){
	var obj=form2.member_gender;
	for (var i=0; i<obj.length; i++){
		if (obj[i].value==v)
			obj[i].checked=true;
	}
}

function loadsubgroup(data){
	if (data.length>0){
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		
		var url = "loadsubgroup.php?data="+data;
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("subgroup").innerHTML = 'Loading...';
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("subgroup").innerHTML = HttPRequest.responseText;
				}
		}	
	
	}
}

function loadclipsubgroup(data){
	if (data.length>0){
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		
		var url = "loadclipsubgroup.php?data="+data;
		
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("subgroup").innerHTML = 'Loading...';
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("subgroup").innerHTML = HttPRequest.responseText;
				}
		}	
	
	}
}

function loadclip(data){
	if (data.length>0){
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		
		var url = "loadclip.php?data="+data;
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("clip").innerHTML = 'Loading...';
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("clip").innerHTML = HttPRequest.responseText;
				}
		}	
	
	}
}

function openclip(data){
	var groupid=groupfrm.group.value;
	var subgroupid=groupfrm.subgroup.value;
	window.location="AddClip.php?groupid="+groupid+"&subgroupid="+subgroupid;
}
function openclip2(data){
	var groupid=groupfrm.group.value;
	var subgroupid=groupfrm.subgroup.value;
	window.location="addClip.php?groupid="+groupid+"&subgroupid="+subgroupid;
}

function loadchapter(data){
	var groupid=groupfrm.group.value;
	var subgroupid=groupfrm.subgroup.value;
	var clipid=groupfrm.clip.value;
	//location.replace("UpdateChapter.php?groupid="+groupid+"&subgroupid="+subgroupid+"&clipid="+clipid);
	window.location="MODChapter.php?groupid="+groupid+"&subgroupid="+subgroupid+"&clipid="+clipid;
	//alert("UpdateChapter.php?groupid="+groupid+"&subgroupid="+subgroupid+"&clipid="+clipid);
	/*
	if (data.length>0){
		
		
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		
		var url = "loadchapter.php?data="+data;
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("chapter").innerHTML = 'Loading...';
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("chapter").innerHTML = HttPRequest.responseText;
				}
		}	
	}
	*/
}

function checkall(){
	var tbl=document.getElementById("chaptertbl");
	for (i=1; i<tbl.rows.length; i++){
		tbl.rows[i].cells[0].childNodes[0].checked=tbl.rows[0].cells[0].childNodes[0].checked;
	}
}

function DelChapter(cptid){
	cptid=trim(cptid);
	if (parseInt(cptid)>0){
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		var url = "DelChapter.php?cptid="+cptid;
		
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("msgcaption").innerHTML = "Loading...";
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("msgcaption").innerHTML = HttPRequest.responseText;
					//alert(url);
				}
		}	
	}
}

function DelRow(){
	tbl=document.getElementById("chaptertbl");
	if ((tbl.rows.length>1)&&(CheckRow())&&(confirm("ต้องการลบข้อมูลใช่หรือไม่?"))){
		rowCount=tbl.rows.length;
		try{
			for (var j=1; j<rowCount; j++){
				var row=tbl.rows[j];
				var check = row.cells[0].childNodes[0]
				if ((check!=null)&&(check.checked)){
					var chapterid=row.cells[0].childNodes[0].value;
					if (rowCount<=2){
						AddRow("chaptertbl");
						tbl.rows[0].cells[0].childNodes[0].checked=false;
						tbl.rows[1].cells[1].childNodes[0].value="1";
						j++;
					}
					DelChapter(check.value);
					tbl.deleteRow(j);
					rowCount--;
					j--;
					
				}
			}
		}catch(e){
			alert("เกิดข้อผิดพลาด:"+e);
		}
		//alert("เสร็จสิ้นการลบข้อมูลแล้วครับ");
		loadnewutilthaitv();
	}
}

function InsertRow(){
	AddRow("chaptertbl");
	setAttrib();
}

function InsertClipRow(){
	AddClipRow("cliptbl");
}

function AddClipRow(t){
	tbl=document.getElementById(t);
	
	if (tbl.rows.length>1){
		var sortid=tbl.rows[1].cells[1].childNodes[0].value;
		var row=tbl.insertRow(1);
		var col=tbl.rows[0].cells.length;
		for (i=0; i<col; i++){
			var newcell=row.insertCell(i);
			newcell.innerHTML=tbl.rows[2].cells[i].innerHTML;
			switch(newcell.childNodes[0].type){
				case "text":
					newcell.childNodes[0].value="";
					break;
				case "checkbox":
					newcell.childNodes[0].checked=false;
					newcell.childNodes[0].value="";
					break;
				case "select-one":
					newcell.childNodes[0].selectedIndex=0;
					break;
				case "textarea":
					newcell.childNodes[0].value="";
					break;
			}
			tbl.rows[1].cells[i].setAttribute("valign","top");
		}
		//tbl.rows[1].cells[0].innerHTML="&nbsp;";
		tbl.rows[1].cells[5].childNodes[0].value="0";
		tbl.rows[1].cells[7].childNodes[0].value="0";
		tbl.rows[1].cells[8].childNodes[0].value="1";
		tbl.rows[1].cells[9].childNodes[0].value="0"
	}
}

function AddRow(t){
	tbl=document.getElementById(t);
	
	if (tbl.rows.length>1){
		var sortid=tbl.rows[1].cells[1].childNodes[0].value;
		var row=tbl.insertRow(1);
		var col=tbl.rows[0].cells.length;
		for (i=0; i<col; i++){
			var newcell=row.insertCell(i);
			newcell.innerHTML=tbl.rows[2].cells[i].innerHTML;
			switch(newcell.childNodes[0].type){
				case "text":
					newcell.childNodes[0].value="";
					break;
				case "checkbox":
					newcell.childNodes[0].checked=false;
					newcell.childNodes[0].value="";
					break;
				case "select-one":
					newcell.childNodes[0].selectedIndex=0;
					break;
				case "textarea":
					newcell.childNodes[0].value="";
					break;
			}
		}
		if (parseInt(sortid)<1)
			sortid="1";
		tbl.rows[1].cells[1].childNodes[0].value=(parseInt(sortid)+1);
	}
}

function CheckRow(){
	tbl=document.getElementById("chaptertbl");
	if (tbl.rows.length>1){
		var flag=true;
		var i=1;
		while ((flag)&&(i<tbl.rows.length)){
			var row=tbl.rows[i];
			if ((row.cells[0].childNodes[0]!=null)&&(row.cells[0].childNodes[0].checked))
				flag=false;
			i++;
		}
		return !flag;
	}else
		return false;
}

function SaveChapter(obj){
	tbl=document.getElementById("chaptertbl");
	var r=parseInt(obj.parentNode.rowIndex);
	var chapter_name=tbl.rows[r].cells[2].childNodes[0].value;
	var path_name=tbl.rows[r].cells[3].childNodes[0].value;
	if ((tbl.rows.length>1)&&(chapter_name.length>0)&&(path_name.length>0)){
		
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		var clip_id=groupfrm.clip.value;
		var chapter_id=tbl.rows[r].cells[0].childNodes[0].value;
		var chapter_sort=tbl.rows[r].cells[1].childNodes[0].value;
		var url = "savechapter.php?clip_id="+clip_id+"&chapter_id="+chapter_id+"&chapter_sort="+chapter_sort+"&chapter_name="+chapter_name+"&path_name="+path_name;
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("msgcaption").innerHTML = 'Loading...';
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("msgcaption").innerHTML = "Chapter Id:"+HttPRequest.responseText+" บันทึกแล้ว";
					tbl.rows[r].cells[0].childNodes[0].value=HttPRequest.responseText;
					tbl.rows[r].cells[4].innerHTML="<span style='color:gray;'><b>OK</b></span>";
					tbl.rows[r].cells[4].onclick=function(){alert('บันทึกแล้ว');};
				}
		}	
	}else alert("ไม่สามารถทำการบันทึกได้");
}

function setAttrib(){
	tbl=document.getElementById("chaptertbl");
	if (tbl.rows.length>1){
		tbl.rows[1].cells[4].onclick=function(){SaveChapter(this);};
		tbl.rows[1].cells[4].setAttribute("align","center");
		tbl.rows[1].cells[4].setAttribute("style","cursor:pointer;");
		tbl.rows[1].cells[4].innerHTML="<b>Save</b>";
	}
}

function loadnewutilthaitv(){
	
	var groupid=groupfrm.group.value;
	var subgroupid=groupfrm.subgroup.value;
	var clipid=groupfrm.clip.value;
	window.location="MODChapter.php?groupid="+groupid+"&subgroupid="+subgroupid+"&clipid="+clipid;
}

function saveclip(){
	table=document.getElementById("cliptbl");
	if ((table.rows.length>1)&&(confirm("ต้องการบันทึกข้อมูลใช่หรือไม่"))){
		clipfrm.clip_group.value=groupfrm.group.value;
		clipfrm.clip_subgroup.value=groupfrm.subgroup.value;
		clipfrm.submit();
	}
}
function saveclip2(){
	table=document.getElementById("cliptbl");
	if ((table.rows.length>1)&&(confirm("ต้องการบันทึกข้อมูลใช่หรือไม่"))){
		clipfrm.clip_group.value=groupfrm.group.value;
		clipfrm.clip_subgroup.value=groupfrm.subgroup.value;
		clipfrm.submit();
	}
}

function getnow(){
var dt = new Date();
var dtstring = dt.getFullYear()
    + '-' + pad(dt.getMonth()+1,2)
    + '-' + pad(dt.getDate(),2)
    + '_' + pad(dt.getHours(),2)
    + '-' + pad(dt.getMinutes(),2)
    + '-' + pad(dt.getSeconds(),2);
	/*
	var now=new Date();
	var t=formatDateTime(now,'yyyy-mm-dd');
	return t;
	*/
	return dtstring;
}

function pad(number, length) {
   
    var str = '' + number;
    while (str.length < length) {
        str = '0' + str;
    }
   
    return str;

}

function getFileExtension(filename) 
{ 
  var ext = /^.+\.([^.]+)$/.exec(filename); 
  return ext == null ? "" : ext[1]; 
}

function setFileName(file,l){
	table=document.getElementById("cliptbl");
	var ext=getFileExtension(file);
	var newname=getnow()+"."+ext;
	table.rows[parseInt(l)].cells[3].childNodes[0].value=newname;
}


function urlEncode(inputString, encodeAllCharacter){
       var outputString = '';
       if (inputString != null){
         for (var i = 0; i < inputString.length; i++ ){
            var charCode = inputString.charCodeAt(i);
            var tempText = "";
            if (charCode < 128) {
                if (encodeAllCharacter)
                {
                  var hexVal = charCode.toString(16);
                  outputString += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();  
                } else {
                  outputString += String.fromCharCode(charCode);
                }
                            
            } else if((charCode > 127) && (charCode < 2048)) {
                tempText += String.fromCharCode((charCode >> 6) | 192);
                tempText += String.fromCharCode((charCode & 63) | 128);
                outputString += escape(tempText);
            } else {
                tempText += String.fromCharCode((charCode >> 12) | 224);
                tempText += String.fromCharCode(((charCode >> 6) & 63) | 128);
                tempText += String.fromCharCode((charCode & 63) | 128);
                outputString += escape(tempText);
            }
         }
       }
       return outputString;
}

function member_payment(){
if (document.getElementById('member_id')!=null && parseInt(document.getElementById('member_id').value)>0){
	TabbedPanels1.showPanel(0);
	
	var HttPRequest = Call_Inint_AJAX();
	if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
	}
	var url = "Member_Payment.php";
	HttPRequest.open('GET',url,true);
	HttPRequest.send(null);
		
		
	HttPRequest.onreadystatechange = function()
	{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("listprogram").innerHTML = 
					"<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("listprogram").innerHTML = HttPRequest.responseText;
					smoothScroll('anchor3');
				}
	}
}else{
	alert("กรุณาเข้าสู่ระบบก่อนค่ะ \nPlease Login into systems.");
}
}
function memberPurchasePopup()
{
	var frm=document.getElementById("memberpaypalfrm");
	var memberpayment=radio_value(frm.memberpayment);
	var payment=radio_value(frm.payment);
	//if (parseInt(memberpayment)>0&&parseInt(payment)){
	if (parseInt(memberpayment)>0){
		window.location = "Member_Payment_Confirm.php?memberpayment="+memberpayment+"&payment="+payment;
	}
	else
		alert("กรุณาเลือกแพคเกจที่ต้องการค่ะ \nPlease select your packege.");
}
function member_purchase(){
	
	var frm=document.getElementById("memberpaypalfrm");
	var memberpayment=radio_value(frm.memberpayment);
	var payment=radio_value(frm.payment);
	//if (parseInt(memberpayment)>0&&parseInt(payment)){
	if (parseInt(memberpayment)>0){
		
			var HttPRequest = Call_Inint_AJAX();
			if (!HttPRequest) {
				alert('Cannot create XMLHTTP instance');
				return false;			
			}
			var url = "Member_Payment_Confirm.php?memberpayment="+memberpayment+"&payment="+payment;
			HttPRequest.open('GET',url,true);
			HttPRequest.send(null);
			
			
			HttPRequest.onreadystatechange = function()
			{
				if(HttPRequest.readyState == 3)  // Loading Request
					{
						document.getElementById("listprogram").innerHTML = 
						"<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
					}
				if(HttPRequest.readyState == 4) // Return Request
					{	
						document.getElementById("listprogram").innerHTML = HttPRequest.responseText;
						smoothScroll('anchor3');
					}
			}
		
	}else
		alert("กรุณาเลือกแพคเกจที่ต้องการค่ะ \nPlease select your packege.");
}

function ObjectPosition(obj) {
    var curleft = 0;
    var curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

function save_purchase(payment){
	switch(parseInt(payment)){
		case 1:
			payVisible('layerDebitCredit');
			break;
		case 2:
			payVisible('layerPayPal');
			break;
	}
}

function payVisible(objname){
	placeIt(objname);
	setVisible(objname)
}

function setVisible(objname)
{
	obj = document.getElementById(objname);
	obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';
}

function placeIt(objname)
{
	
	obj = document.getElementById(objname);
	var aryListPos=ObjectPosition('listprogram');
	var aryObjPos=ObjectPosition(objname);
	//aryListPos.scrollLeft=0;
	//aryListPos.scrollTop=0;
	//aryListPos.documentElement.scrollTop=0;
	/*
	obj.style.left = (570+theLeft) + 'px' ;
	obj.style.top = (20+theTop)+ 'px' ;
	obj.style.margin-top='-50px';
	obj.style.margin-left='-100px';
	*/
}

function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

function paynow(){
	document.forms["Paypalfrm"].submit();
	//var submitToPaypal = document.getElementById(Paypalfrm);
//		if(submitToPaypal!=null)
//		{
//		submitToPaypal.submit();
//		}else{
//			alert("try again");
//		}
	
 }

function stoplayershowblank(){
	var HttPRequest = Call_Inint_AJAX();
	if (!HttPRequest) {
		alert('Cannot create XMLHTTP instance');
		return false;			
	}
		
	var url = "runmovieblank.php";
	HttPRequest.open('GET',url,true);
	HttPRequest.send(null);
		
	HttPRequest.onreadystatechange = function()
	{
		if(HttPRequest.readyState == 3)  // Loading Request
			{
				document.getElementById("movieplay").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
			}
		if(HttPRequest.readyState == 4) // Return Request
			{	
				document.getElementById("movieplay").innerHTML = HttPRequest.responseText;
				starticmt();
				
				//smoothScroll('anchor3');
			}
	}
		
}
 
function playtimer(){
	clearTimeout(DT_Watcher);
	DT_Watcher=setTimeout("stoplay()",(5*60*1000));
	
	
	//DT_Watcher=setTimeout("stoplay()",(1*60*1000));
}

function playFornotMember()
{
		clearTimeout(DT_Watcher);
		DT_Watcher=setTimeout("stoplay_notMember()",(1000));
}
function stoplay_notMember()
{
	var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		
		var url = "runblank_out.php";
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("doothaitvmovieplay").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					if (document.getElementById('member_id')!=null && parseInt(document.getElementById('member_id').value)>0){
						document.getElementById("doothaitvmovieplay").innerHTML = "<img src='images/payment_bg.png' width='639' height='396' />";
					}
					else
					document.getElementById("doothaitvmovieplay").innerHTML = "<img src='images/signup_bg.png' width='639' height='396' />";
					
				}
		}	
}
function playtimer_out(){
	clearTimeout(DT_Watcher_out);
	DT_Watcher_out=setTimeout("stoplay_out()",(5*60*1000));
	
	//DT_Watcher=setTimeout("stoplay()",(1*60*1000));
}

function closePlayfreeWindow()
{
	clearTimeout(countCloseFree);
	countCloseFree = setTimeout("closeActionPlayfree()",((5*60*1000)+10000));

}

function closeActionPlayfree()
{
		window.open('','_self','');
		window.close();
}

function stoplay_out(){
	if (document.getElementById("doothaitvplaybrowser").value=="firefox")
		player = document.getElementById("doothaitvplayingvideo2");
	else
		player = document.getElementById("doothaitvplayingvideo");
	try{
		player.controls.stop();
	}
	catch (e){
	}
	
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		
		var url = "runblank_out.php";
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("doothaitvmovieplay").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("doothaitvmovieplay").innerHTML = HttPRequest.responseText;
				}
		}	
}

function stoplay(){
	if (document.getElementById("playbrowser").value=="firefox")
		player = document.getElementById("playingvideo2");
	else
		player = document.getElementById("playingvideo");
	try{
		player.controls.stop();
	}
	catch (e){
	}
	if (viewvedio_x==1)
		togglevideo('playvedio',545,9);
	
	//member_payment();
	setTimeout("linkdoc('registermember.php');",2300);
	/*
	var HttPRequest = Call_Inint_AJAX();
	if (!HttPRequest) {
		alert('Cannot create XMLHTTP instance');
		return false;			
	}
		
	var url = "runmovieblank.php";
	HttPRequest.open('GET',url,true);
	HttPRequest.send(null);
		
	HttPRequest.onreadystatechange = function()
	{
		if(HttPRequest.readyState == 3)  // Loading Request
			{
				document.getElementById("movieplay").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
			}
		if(HttPRequest.readyState == 4) // Return Request
			{	
				document.getElementById("movieplay").innerHTML = HttPRequest.responseText;
				starticmt();
				//smoothScroll('anchor3');
			}
	}
	*/
}

function playtimerlogin(){
	clearTimeout(DT_Watcher);
	DT_Watcher=setTimeout("stoplaylogin()",(5*60*1000));
	
	
}
 
function stoplaylogin(){
	if (document.getElementById("playbrowser").value=="firefox")
		player = document.getElementById("playingvideo2");
	else
		player = document.getElementById("playingvideo");
	try{
		player.controls.stop();
	}catch (e){
	}
	
	if (viewvedio_x==1)
		togglevideo('playvedio',545,9);
	
	setTimeout("linkdoc('member_payment.php');",2300);
	/*
	var HttPRequest = Call_Inint_AJAX();
	if (!HttPRequest) {
		alert('Cannot create XMLHTTP instance');
		return false;			
	}
		
	var url = "runmovieblank.php";
	HttPRequest.open('GET',url,true);
	HttPRequest.send(null);
		
	HttPRequest.onreadystatechange = function()
	{
		if(HttPRequest.readyState == 3)  // Loading Request
			{
				document.getElementById("movieplay").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
			}
		if(HttPRequest.readyState == 4) // Return Request
			{	
				document.getElementById("movieplay").innerHTML = HttPRequest.responseText;
				starticmt();
				//smoothScroll('anchor3');
			}
	}
	*/
}

function startTimer(){
	//DT_Long=setTimeout("document.location='usersignout.php'", 3*60*60*1000);
}

function stopTimer(){
	//clearTimeout(DT_Long);
	
}

function starticmt(){
	clearTimeout(icmt);
	icmt=setTimeout("lobfam()",10000);
}

function lobfam(){

	var HttPRequest = Call_Inint_AJAX();
	if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
	return false;
	}

	var url = "lobfam.php";
	HttPRequest.open('GET',url,true);
	HttPRequest.send(null);
	var vtitle=document.getElementById("movietitle").innerHTML;
	HttPRequest.onreadystatechange = function()
	{
		if(HttPRequest.readyState == 3)  // Loading Request
			{
				document.getElementById("movietitle").innerHTML = vtitle;
			}
		if(HttPRequest.readyState == 4) // Return Request
			{	
				document.getElementById("movietitle").innerHTML = vtitle;
			}
	}

}

function exitlogin(){
	window.location="usersignout.php";
}

function send_us(){
	if (confirm("Are you sure?")){
		contactusfrm.submit();
	}
}

function clearboxtext(obj,txt,type){
	if (obj.value==txt){
		obj.value='';
	}
	obj.select();
}

function restoreboxtext(obj,txt,type){
	if (trim(obj.value)==''){
		obj.value=txt;
	}
}

function movetoplistprogram(){
	if (viewvedio_x==1)
		window.scrollTo(0,705+545);
	else
		window.scrollTo(0,705);
}

function movetopplayer(){
	if (viewvedio_x==1)
		window.scrollTo(0,160+545);
	else
		window.scrollTo(0,160);
}

function initHintTextboxes() {
	if (document.getElementById('user_email')!=null){
		var input = document.getElementById('user_email');
		input.hintText = "Enter Your E-Mail";
		input.onfocus = onHintTextboxFocus;
		input.onblur = onHintTextboxBlur;
		var input = document.getElementById('user_pwd');
		input.hintText = "Enter Your Password";
		input.onfocus = HintTextFocusPassword;
		input.onblur = onHintTextboxBlurPassword;
	}
}

function initHintTextboxes2() {
  var inputs = document.getElementsByTagName('input');
  for (i=0; i<inputs.length; i++) {
    var input = inputs[i];
	
    if (input.type!="text" && input.type!="password")
      continue;
    alert(i+":name="+input.name+",type="+input.type+",value="+input.value+",classname="+input.className+",indexOf="+input.className.indexOf(HintClass));
      
    if (input.className.indexOf(HintClass)!=-1) {
      input.hintText = input.value;
      input.className = HintClass;
      input.onfocus = onHintTextboxFocus;
      input.onblur = onHintTextboxBlur;
    }
  }
}

function onHintTextboxFocus() {
  var input = document.getElementById('user_email');
  if (input.value=="Enter Your E-mail") {
    input.value = "";
    input.className = HintActiveClass;
  }
}

function HintTextFocusPassword(){
  var input = document.getElementById('user_pwd');
  if (trim(input.value)=='Enter Your Password') {
	clearTimeout(setfocus_user_pwd);
	document.getElementById("passwordid").innerHTML="<input type='password' name='user_pwd' id='user_pwd' value='' size='25' class='HintActiveClass' onfocus ='HintTextFocusPassword();' onblur = 'onHintTextboxBlurPassword();'/>";
	setfocus_user_pwd=setTimeout("focus_user_pwd();",50);
  }
}

function focus_user_pwd(){
	document.getElementById("user_pwd").focus();
}

function onHintTextboxBlur() {
  var input = document.getElementById('user_email');
  if (trim(input.value).length==0) {
    input.value = "Enter Your E-Mail";
    input.className = HintClass;
  }
}

function onHintTextboxBlurPassword() {
	var input = document.getElementById('user_pwd');
  if (trim(input.value).length==0) {
	document.getElementById("passwordid").innerHTML="<input type='text' name='user_pwd' id='user_pwd' value='Enter Your Password' size='25' class='hintTextbox' onfocus ='HintTextFocusPassword();' onblur = 'onHintTextboxBlurPassword();'/>";
	//document.getElementById("user_pwd").focus();
  }
}

function currentYPosition() {
	if (self.pageYOffset)
		 return self.pageYOffset;
	if (document.documentElement && document.documentElement.scrollTop)
		return document.documentElement.scrollTop;
	if (document.body.scrollTop)
		 return document.body.scrollTop;
	return 0;
}
function elmYPosition(eID) {
	var elm  = document.getElementById(eID);
	var y    = elm.offsetTop;
	var node = elm;
	while (node.offsetParent && node.offsetParent != document.body) {
		node = node.offsetParent;
		y   += node.offsetTop;
	} return y;
}
function smoothScroll(eID) {
	var startY   = currentYPosition();
	var stopY    = elmYPosition(eID);
	var distance = stopY > startY ? stopY - startY : startY - stopY;
	if (distance < 100) {
		scrollTo(0, stopY); return;
	}
	var speed = Math.round(distance / 100);
	if (speed >= 20) speed = 20;
	var step  = Math.round(distance / 25);
	var leapY = stopY > startY ? startY + step : startY - step;
	var timer = 0;
	if (stopY > startY) {
		for ( var i=startY; i<stopY; i+=step ) {
			setTimeout("window.scrollTo(0, "+leapY+")", timer * speed);
			leapY += step; if (leapY > stopY) leapY = stopY; timer++;
		} return;
	}
	for ( var i=startY; i>stopY; i-=step ) {
		setTimeout("window.scrollTo(0, "+leapY+")", timer * speed);
		leapY -= step; if (leapY < stopY) leapY = stopY; timer++;
	}
}

function showhide(obj_id){
	if (document.getElementById('member_id')!=null&&document.getElementById('member_expire')!=null
	    &&parseInt(document.getElementById('member_expire').value)>0&&parseInt(document.getElementById('member_id').value)>0)
		setVisible(obj_id);
}

function list_year(objyear){
	var myear=parseInt(objyear.value);
	if (myear>0){
		var j=1;
		for (i=myear-10; i<=myear+10; i++){
			objyear.options[j].value=i;
			objyear.options[j].text=i+543;
			if (i==myear)
				objyear.options[j].selected=true;
			j++;
		}
	}
}

function list_day(objday,mm,yy){
	var myear=parseInt(yy);
	var mmonth=parseInt(mm);
	if (myear>0 && mmonth>0){
		var mday=parseInt(objday.value);
		if (mmonth>0 && myear>0){
			var maxday=daysInMonthArray[mmonth-1];
			if (mmonth==2 && (myear%400==0||(myear%4==0&&myear%100!=0)))
				maxday=29;
		}
		else
			var maxday=0;
		objday.length=maxday+1;
		for (d=1; d<=maxday; d++){
			objday.options[d].value=d;
			objday.options[d].text=d;
			if (mday==d)
				objday.options[d].selected=true;
		}
	}
}

function statistic_email(frm){
	
	var startday=frm.start_day.value;
	var startmonth=frm.start_month.value;
	var startyear=frm.start_year.value;
	
	var endday=frm.end_day.value;
	var endmonth=frm.end_month.value;
	var endyear=frm.end_year.value;
	if (parseInt(startday)>0&&parseInt(startmonth)>0&&parseInt(startyear)&&confirm('Are you sure?')){
		if(parseInt(endday)<=0)
			endday=startday;
		if(parseInt(endmonth)<=0)
			endmonth=startmonth;
		if(parseInt(endyear)<=0)
			endyear=startyear;
		
			var HttPRequest = Call_Inint_AJAX();
			if (!HttPRequest) {
				alert('Cannot create XMLHTTP instance');
				return false;			
			}
			var url = "qrystatisticemail.php?startday="+startday+"&startmonth="+startmonth+"&startyear="+startyear+"&endday="+endday+"&endmonth="+endmonth+"&endyear="+endyear;
			HttPRequest.open('GET',url,true);
			HttPRequest.send(null);
			
			
			HttPRequest.onreadystatechange = function()
			{
				if(HttPRequest.readyState == 3)  // Loading Request
					{
						document.getElementById("idstatistic").innerHTML = "Loading...";
					}
				if(HttPRequest.readyState == 4) // Return Request
					{	
						document.getElementById("idstatistic").innerHTML = HttPRequest.responseText;
						
					}
			}
		
	}
}

function expire_date(frm){
	
	var dd=frm.exp_day_cnt.value;
	var mm=frm.exp_month_cnt.value;
	var yy=frm.exp_year_cnt.value;
	
	if (parseInt(dd)>0&&parseInt(mm)>0&&parseInt(yy)){
		
			var HttPRequest = Call_Inint_AJAX();
			if (!HttPRequest) {
				alert('Cannot create XMLHTTP instance');
				return false;			
			}
			var url = "CountExpireDate.php?exp_day="+dd+"&exp_month="+mm+"&exp_year="+yy;
			HttPRequest.open('GET',url,true);
			HttPRequest.send(null);
			
			
			HttPRequest.onreadystatechange = function()
			{
				if(HttPRequest.readyState == 3)  // Loading Request
					{
						document.getElementById("expire_amount").innerHTML = "Loading...";
					}
				if(HttPRequest.readyState == 4) // Return Request
					{	
						document.getElementById("expire_amount").innerHTML = HttPRequest.responseText;
						
					}
			}
		
	}
}

function sendfriendemail(frm,tbl){
	var table = document.getElementById(tbl);
	var rowCount = table.rows.length;
	var numrow = 0;
	for(var k=1; k<rowCount-1; k++) {
		var row = table.rows[k];
		var chkbox = row.cells[4].childNodes[0];
		row.cells[5].childNodes[0].value="0";
		if (null != chkbox && chkbox.checked){
			row.cells[5].childNodes[0].value=row.cells[4].childNodes[0].value;
			row.cells[4].innerHTML="ส่งแล้วค่ะ  : E-Mail sent";
			numrow++;
		}
	}
	if (numrow>0&&confirm('ต้องการส่งอีเมล์ใช่หรือไม่ค่ะ : Are you sure to send E-Mail ?')){
		frm.submit();
		alert('ส่งอีเมล์แล้วค่ะ : E-Mail sent');
	}
}

function nimda_member(frm,t){
	if (t=='1'){
		frm.action="findcustomer.php";
		frm.submit();
	}else if (t=='2'&&confirm('ต้องการบันทึกใช่หรือไม่')){
		frm.action="savecustomer.php"
		frm.submit();
	}
}

function show(id_opject,height){
	if (document.getElementById('member_id')!=null&&document.getElementById('member_expire')!=null
	    &&parseInt(document.getElementById('member_expire').value)>0&&parseInt(document.getElementById('member_id').value)>0){
	
		if(document.getElementById(id_opject).style.visibility=='hidden'){
				document.getElementById(id_opject).style.visibility="visible";
				document.getElementById(id_opject).style.height=height+'px';
		}else{
				document.getElementById(id_opject).style.visibility="hidden";
				document.getElementById(id_opject).style.height='0px';
		}
	}
}

function send_reward(frm){
	if (document.getElementById('member_id')!=null&&document.getElementById('member_expire')!=null
	  &&parseInt(document.getElementById('member_expire').value)>0&&parseInt(document.getElementById('member_id').value)>0&&
	  confirm('คุณต้องการส่งใช่หรือไม่\nAre you sure send')){
		frm.submit();
		linkdoc('send_reward.html');
	}else alert('กรุณาล๊อกอินเข้าสู่ระบบก่อนค่ะ\nPlease Login');
}

function alertRenew()
{
	try{
		player.controls.stop();
	}
	catch (e){
	}
	
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			
		}
		
		var url = "runblank_out.php";
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("doothaitvmovieplay").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:145px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
				}
			if(HttPRequest.readyState == 4) // Return Request
				{	
					document.getElementById("doothaitvmovieplay").innerHTML = HttPRequest.responseText;
				}
		}	
}
function renewPopup()
{
	if (document.getElementById('member_id')!=null && parseInt(document.getElementById('member_id').value)>0){
	window.open("Member_Payment_Popup.php","paymentPopup");
	}
	else{
	alert("กรุณาเข้าสู่ระบบก่อนค่ะ \nPlease Login into systems.");
	}
}
function newwindowplayer(){
	//alert(document.getElementById('member_expire').value+',meclip_id='+meclip_id);
	if (document.getElementById('member_expire')!=null&&document.getElementById('member_expire').value=='1'&&parseInt(meclip_id)>0){
		stoplayershowblank();
		if (parseInt(meclip_id)>0)
			childPage = window.open("player.php?clip_id="+meclip_id,
			"doothaitv_player_window","status=0,width=1040,height=640,scrollbars=false,titlebar=1,resizable=false,location=1");
		else
			alert("กรุณาเลือกรายการด้วยค่ะ : Please select Movies Clip");
	}else alert('กรุณาเข้าสู่ระบบหรือเติมเงินก่อนนะคะ : Please login or refill your account before watching.');
}

function newTrailerPlayer()
{
		childPage = window.open("player.php?clip_id="+meclip_id,"doothaitv_player_window","status=0,width=1040,height=640,scrollbars=false,titlebar=1,resizable=false,location=1");
}

function searchByKey()
{
	smoothScroll('anchor3');
	var keysearch= document.getElementById("keyLeftsearch").value;
	linkdoc('searchclipname.php?keysearch='+keysearch);
	
	if (keysearch.length>0 && keysearch!="ค้นหารายการ"){
		var HttPRequest = Call_Inint_AJAX();
		if (!HttPRequest) {
			alert('Cannot create XMLHTTP instance');
			return false;			}
		
		var url = "searchclipname.php?keysearch="+keysearch;
		
		HttPRequest.open('GET',url,true);
		HttPRequest.send(null);
		
		
		HttPRequest.onreadystatechange = function()
		{
			if(HttPRequest.readyState == 3)  // Loading Request
				{
					document.getElementById("searchresult").innerHTML = "<table height='100%' align='center' valign='top'><tr><td valign='top' style='height:365px'><img src='images/waiting/doothaitv-loading.gif' align='absmiddle'></td></tr></table>";   
				}
			if(HttPRequest.readyState == 4) // Return Request
				{
					document.getElementById("searchresult").innerHTML = HttPRequest.responseText;
					
				}
		}
		
	}

}

function sendpassword(){
	
	
		
			var HttPRequest = Call_Inint_AJAX();
			if (!HttPRequest) {
				alert('Cannot create XMLHTTP instance');
				return false;			
			}
			var url = "sendpasswordmember.php?email_account="+form1.email_account.value;
			
			HttPRequest.open('GET',url,true);
			HttPRequest.send(null);
			
			
			HttPRequest.onreadystatechange = function()
			{
				if(HttPRequest.readyState == 3)  // Loading Request
					{
						document.getElementById("form1id").innerHTML = "Loading...";
					}
				if(HttPRequest.readyState == 4) // Return Request
					{	
						document.getElementById("form1id").innerHTML = HttPRequest.responseText;
						window.close();
					}
			}
		
	
}

function increasingSize()
{
	//var playerLayout = document.getElementById("doothaitvmovieplay");
//	playerLayout.style.height = "540px";
//	playerLayout.style.width = "960px";
window.open('','_self','');
window.moveTo(0, 0);

window.resizeTo(screen.width, screen.height);	

var IsMediaPlayer = document.getElementById("linkType");
var browser = navigator.userAgent;

//if(IsMediaPlayer!= null)
//{
//	alert("IsMedia");
//	document.getElementById("doothaitvmovieplay").style.width = "950px";
//	document.getElementById("doothaitvmovieplay").style.height = "585px";
//}else
//{
		if(browser.indexOf('MSIE')>0)
		{
			$("doothaitvmovieplay").resize({delay:100,to:{width:950,height:540}});
		}else{
			$("doothaitvmovieplay").resize({delay:300,to:{width:950,height:540}});
		}
//}
	document.getElementById("mirrorlist").style.width = "950px";
	document.getElementById("clipDescription").style.width = "950px";
	document.getElementById("divChapterList").style.width = "275px";
	document.getElementById("changeToMedium").innerHTML = "<img src='images/decreasesize.png' alt='Decreasing screen size' name='playerDecreaeSize' border='0' id='playerDecrease' onclick='decreasingSize();'/>";
	
	document.getElementById("changeToMedium").style.position = "absolute";
	document.getElementById("changeToMedium").style.left = "916px";
	document.getElementById("changeToMedium").style.bottom = "725px"
	if(document.getElementById("fullScnBT")) //Check Element exists
	{
		document.getElementById("fullScnBT").style.position = "absolute";
		document.getElementById("fullScnBT").style.left = "977px";
		document.getElementById("fullScnBT").style.top = "545px";
	}
	
}


function manageFullScrnBT()
{
	
	var playerLayout = document.documentElement.clientWidth;
	
	
	if((playerLayout > 1040 )&& playerLayout != 0)
	{	
		document.getElementById("fullScnBT").style.left = "977px";
		document.getElementById("fullScnBT").style.top = "545px";
	}else{
		document.getElementById("fullScnBT").style.left = "665px";
		document.getElementById("fullScnBT").style.top = "351px";
	}
}
function setFullScrnVisible()
{	
	document.getElementById("changeToMedium").style.visibility = 'hidden';
	document.getElementById("playerFullScreen").style.visibility = 'visible';
	document.getElementById("infoBtnDIV").style.visibility = 'hidden';
	
	
}
function setResizehidden()
{	
	window.open('','_self','');
	window.resizeTo(1040,704);
		
	if (navigator.userAgent.indexOf("Firefox")!=-1)
	{	
		document.getElementById("doothaitvmovieplay").style.height = "396px";
		document.getElementById("doothaitvmovieplay").style.width = "640px";
		
	}else{
		
		
	    
		document.getElementById("doothaitvmovieplay").style.height = "396px";
		document.getElementById("doothaitvmovieplay").style.width = "640px";
		
	}
	try
	{
		document.getElementById("changeToMedium").style.visibility = 'hidden';
		document.getElementById("playerFullScreen").style.visibility = 'visible';
	}catch(e)
	{
		document.getElementById("changeToMedium").style.visibility = 'hidden';
	}
	
}
function setResizeVisible()
{
	try
	{
		document.getElementById("divChapterList").style.width = "275px";
	document.getElementById("changeToMedium").style.position = "absolute";
	document.getElementById("changeToMedium").style.left = "606px"
	document.getElementById("changeToMedium").style.bottom = "547px"

		document.getElementById("changeToMedium").style.visibility = 'visible';
		document.getElementById("playerFullScreen").style.visibility = 'hidden';
	
	}catch(e)
	{
		document.getElementById("changeToMedium").style.visibility = 'visible';
	}
}
function manageIncreaseDecrease()
{
		var playerLayout = document.documentElement.clientWidth;
	
	
	if((playerLayout > 1040 )&& playerLayout != 0)
	{	
		document.getElementById("changeToMedium").innerHTML = "<img src='images/decreasesize.png' alt='Decreasing screen size' name='playerDecreaeSize' border='0' id='playerDecrease' onclick='decreasingSize();'/>";
	
	document.getElementById("changeToMedium").style.position = "absolute";
	document.getElementById("changeToMedium").style.left = "916px";
	document.getElementById("changeToMedium").style.bottom = "725px"
	}else{
		document.getElementById("changeToMedium").innerHTML = " <img src='images/increasesize.png' alt='Increasing screen size' name='playerIncreaeSize' border='0' id='playerIncrease' onclick='increasingSize()'/>";
	document.getElementById("divChapterList").style.width = "275px";
	document.getElementById("changeToMedium").style.position = "absolute";
	document.getElementById("changeToMedium").style.left = "606px"
	document.getElementById("changeToMedium").style.bottom = "547px"
}
}
function decreasingSize()
{
	
	window.open('','_self','');
	window.resizeTo(1040,704);
	
	var browser = navigator.userAgent;
	//var playerLayout = document.getElementById("doothaitvmovieplay");
//	playerLayout.style.height = "396px";
//	playerLayout.style.width = "638px";
if(browser.indexOf('MSIE')>0)
{
	$("doothaitvmovieplay").resize({delay:50,to:{width:640,height:425}});
}else{
	$("doothaitvmovieplay").resize({delay:300,to:{width:640,height:425}});
}
//$("doothaitvmovieplay").resize({delay:300,to:{width:638,height:396}});
	document.getElementById("changeToMedium").innerHTML = " <img src='images/increasesize.png' alt='Increasing screen size' name='playerIncreaeSize' border='0' id='playerIncrease' onclick='increasingSize()'/>";
	document.getElementById("divChapterList").style.width = "275px";
	document.getElementById("changeToMedium").style.position = "absolute";
	document.getElementById("changeToMedium").style.left = "606px"
	document.getElementById("changeToMedium").style.bottom = "547px"
	
	document.getElementById("doothaitvmovieplay").style.width = "640px";
	document.getElementById("mirrorlist").style.width = "640px";
	document.getElementById("clipDescription").style.width = "640px";
	
	if(document.getElementById("fullScnBT")) //Check Element exists
	{
	document.getElementById("fullScnBT").style.position = "absolute";
	document.getElementById("fullScnBT").style.left = "664px";
	document.getElementById("fullScnBT").style.top = "351px";
	}
	
}

function manageResizeBT()
{
	
	var playerLayout = document.documentElement.clientWidth;
	
	
	if((playerLayout > 1040 )&& playerLayout != 0)
	{	
		document.getElementById("fullScnBT").style.left = "977px";
		document.getElementById("fullScnBT").style.top = "545px";
	}else{
		document.getElementById("fullScnBT").style.left = "665px";
		document.getElementById("fullScnBT").style.top = "351px";
	}
}




