// JavaScript Document
function startclock()
{
	var thetime=new Date();
	
	var nhours=thetime.getHours();
	var nmins=thetime.getMinutes();
	var nsecn=thetime.getSeconds();
	var nday=thetime.getDay();
	var nmonth=thetime.getMonth();
	var ntoday=thetime.getDate();
	var nyear=thetime.getYear()+543;
	var AorP=" ";
	
	//if (nhours>=12)
	//	AorP="P.M.";
	//else
	//	AorP="A.M.";
	
	//if (nhours>=13)
	//	nhours-=12;
	
	//if (nhours==0)
	//   nhours=12;
	
	if (nsecn<10)
	 nsecn="0"+nsecn;
	
	if (nmins<10)
	 nmins="0"+nmins;
	
	if (nday==0)
	  nday="Sunday";
	if (nday==1)
	  nday="Monday";
	if (nday==2)
	  nday="Tuesday";
	if (nday==3)
	  nday="Wednesday";
	if (nday==4)
	  nday="Thursday";
	if (nday==5)
	  nday="Friday";
	if (nday==6)
	  nday="Saturday";
	
	nmonth+=1;
	
	//if (nyear<=99)
	//  nyear= "19"+nyear;
	//if ((nyear>99) && (nyear<2000))
	// nyear+=1900;
	 document.getElementById("clock").value=ntoday+"/"+nmonth+"/"+nyear + " "+nhours+":"+nmins+":"+nsecn;
	setTimeout('startclock()',1000);
} 

function showdefaultnews()
{
	var itnews = document.getElementById("it");
	var newsbox = document.getElementById("newsbox");
	itnews.style.top = newsbox.offsetTop + 20 +"px";
	itnews.style.left = newsbox.offsetLeft+ 30 +"px";
	itnews.style.visibility = "visible";
}

function shownews(newstype)
{
	var anews = document.getElementById(newstype);
	var newsbox = document.getElementById("newsbox");
	
	document.getElementById("it").style.visibility = "hidden";
	document.getElementById("entertain").style.visibility = "hidden";
	document.getElementById("sport").style.visibility = "hidden";
	
	anews.style.top = newsbox.offsetTop + 20 +"px";
	anews.style.left = newsbox.offsetLeft+ 30 +"px";
	anews.style.visibility = "visible";
	anews.focus();
}

var domainname = window.location.hostname;
domainname = domainname.replace("www.","");
var cpaneluri = "cpanel."+domainname;
var mailuri = "mail."+domainname;
var ftphosturi = "ftp."+domainname;
var rootdir = "/htdocs/";
var statsuri = "www."+domainname+"/stats/";
var sqluri = "www."+domainname+"/sql/";

function MM_timelinePlay(tmLnName, myID) { //v1.2
  //Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Macromedia, Inc. All rights reserved.
  var i,j,tmLn,props,keyFrm,sprite,numKeyFr,firstKeyFr,propNum,theObj,firstTime=false;
  if (document.MM_Time == null) MM_initTimelines(); //if *very* 1st time
  tmLn = document.MM_Time[tmLnName];
  if (myID == null) { myID = ++tmLn.ID; firstTime=true;}//if new call, incr ID
  if (myID == tmLn.ID) { //if Im newest
    setTimeout('MM_timelinePlay("'+tmLnName+'",'+myID+')',tmLn.delay);
    fNew = ++tmLn.curFrame;
    for (i=0; i<tmLn.length; i++) {
      sprite = tmLn[i];
      if (sprite.charAt(0) == 's') {
        if (sprite.obj) {
          numKeyFr = sprite.keyFrames.length; firstKeyFr = sprite.keyFrames[0];
          if (fNew >= firstKeyFr && fNew <= sprite.keyFrames[numKeyFr-1]) {//in range
            keyFrm=1;
            for (j=0; j<sprite.values.length; j++) {
              props = sprite.values[j]; 
              if (numKeyFr != props.length) {
                if (props.prop2 == null) sprite.obj[props.prop] = props[fNew-firstKeyFr];
                else        sprite.obj[props.prop2][props.prop] = props[fNew-firstKeyFr];
              } else {
                while (keyFrm<numKeyFr && fNew>=sprite.keyFrames[keyFrm]) keyFrm++;
                if (firstTime || fNew==sprite.keyFrames[keyFrm-1]) {
                  if (props.prop2 == null) sprite.obj[props.prop] = props[keyFrm-1];
                  else        sprite.obj[props.prop2][props.prop] = props[keyFrm-1];
        } } } } }
      } else if (sprite.charAt(0)=='b' && fNew == sprite.frame) eval(sprite.value);
      if (fNew > tmLn.lastFrame) tmLn.ID = 0;
  } }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}



function MM_initTimelines() { //v4.0
    //MM_initTimelines() Copyright 1997 Macromedia, Inc. All rights reserved.
    var ns = navigator.appName == "Netscape";
    var ns4 = (ns && parseInt(navigator.appVersion) == 4);
    var ns5 = (ns && parseInt(navigator.appVersion) > 4);
    var macIE5 = (navigator.platform ? (navigator.platform == "MacPPC") : false) && (navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4);
    document.MM_Time = new Array(1);
    document.MM_Time[0] = new Array(0);
    document.MM_Time["Timeline1"] = document.MM_Time[0];
    document.MM_Time[0].MM_Name = "Timeline1";
    document.MM_Time[0].fps = 15;
    document.MM_Time[0].lastFrame = 0;
    for (i=0; i<document.MM_Time.length; i++) {
        document.MM_Time[i].ID = null;
        document.MM_Time[i].curFrame = 0;
        document.MM_Time[i].delay = 1000/document.MM_Time[i].fps;
    }
}
function Currencie()
{
           document.currencie.submit();
}

function Mysubmit()
{
           document.mycart.submit();
}
function MyCart()
{
           document.mycart.submit();
}
function CheckOut()
{
        window.location="pre_order.php?ems="+document.mycart.ems.value;
}
var MyAJaxhttp = false;
function MyAJax(url) {
  var today=new Date();
  var getdate=today.getTime();
  url=String(url)+String(String(url).indexOf('?')>0 ? "&" : "?")+'ranid='+ String(Math.ceil(Math.random()*getdate));
  var result;
  if (!MyAJaxhttp) {
    if (window.XMLHttpRequest) 
      MyAJaxhttp = new XMLHttpRequest();
    else if (window.ActiveXObject)
      MyAJaxhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  MyAJaxhttp.open("GET", url, false);
  MyAJaxhttp.send(null);
  result = MyAJaxhttp.responseText;
  return(result);
}

function ChangPrice(size,proid)
{
  var res= MyAJax('Aj_Changprice.php?size='+size+'&proid='+proid);
  document.getElementById("price").innerHTML=res;
}

function checkEmail(obj) {
var email = obj.value;
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(email)) {
	alert('Please provide a valid email address');
	obj.focus();
	return false;
	}
}
function ltrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1) {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
      s = s.substring(j, i);
   }
   return s;
   
}

//RTrim(string) : Returns a copy of a string without trailing spaces.
function rtrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1;       // Get length of string
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }
   return s;
}

// Trim(string) : Returns a copy of a string without leading or trailing spaces
function trim(str) {
   return rtrim(ltrim(str));
}
	function chk_number() {
		e_k=event.keyCode;
		if (((e_k < 48) || (e_k > 57)) && e_k != 46 && e_k != 45 && e_k != 44 && e_k !=13){
		//alert( "ตัวเลข 0 - 9 . และ , เท่านั้น");
		event.returnValue = false;
		return false;
		}
	}
	
	function ChkFormOrder()
{

	if(trim(document.customerdetail.name.value)=="")
	{
		alert("Please fill First Name");
		document.customerdetail.name.focus();
		return false;
	}
	if(trim(document.customerdetail.surname.value)=="")
	{
		alert("Please fill Last Name");
		document.customerdetail.surname.focus();
		return false;
	}
	if(trim(document.customerdetail.address.value)=="")
	{
		alert("Please fill Address");
		document.customerdetail.address.focus();
		return false;
	}

	if(trim(document.customerdetail.city.value)=="")
	{
		alert("Please fill City");
		document.customerdetail.city.focus();
		return false;
	}
	if(trim(document.customerdetail.province.value)=="")
	{
		alert("Please fill State/Province");
		document.customerdetail.province.focus();
		return false;
	}
	if(trim(document.customerdetail.zipcode.value)=="")
	{
		alert("Please fill Zip/Postal Code");
		document.customerdetail.zipcode.focus();
		return false;
	}

	if(trim(document.customerdetail.email.value)=="")
	{
		alert("Please fill E-mai");
		document.customerdetail.email.focus();
		return false;
	}
		if(document.customerdetail.code.value != document.customerdetail.code_hidden.value)
		{
		alert("Invalid Code");
		document.customerdetail.code.focus();
		return false;
	}
	return true;
}

