// JavaScript Document
function setPosisi(e,id){
	if(document.all){
		x = event.x;
		y = event.y;
	}
	else{
		x = e.layerX;
		y = e.layerY;
	}
	
	//x = e.screenX;
	//y = e.screenY;
	//
	document.getElementById(id).style.left = x+'px';
	document.getElementById(id).style.bottom = y+'px';
	//document.getElementById('divproductt').style.visibility = 'visible'
	
	hilang(id,false);
}

function hilang(id,kode){
	if(kode)
		document.getElementById(id).style.visibility = 'hidden';
	else
		document.getElementById(id).style.visibility = 'visible';
}
function open_win(url,width,height){
	window.open(url,'','menubar=0,toolbar=0,status=0,height='+height+'px,width='+width+'px');
}
function jam()
{
	tgl = new Date();
	bulan = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
	return 	dua(tgl.getDate())+" "+bulan[parseInt(tgl.getMonth())]+" "+tgl.getFullYear()+" "+
			dua(tgl.getHours())+":"+dua(tgl.getMinutes())+":"+dua(tgl.getSeconds());
}

function setJam(id)
{
	document.getElementById(id).innerHTML = jam();
	setTimeout("setJam('"+id+"')",1000);
}

function dua(no)
{
	//alert(no.toString().length);
	if(no.toString().length == 1)
		return '0'+no;
	else
		return no;
}
function check(){
   pan = arguments.length;
   s = true;
   for(i=1; i<pan; i+=2){
      isi = eval("document."+ arguments[0] +"."+ arguments[i] +".value");
	  if(isi == ""){
	     alert(arguments[i+1]);
		 eval("document."+ arguments[0] +"."+ arguments[i] +".focus()");
		 s = false;
		 break;
	  }
   }
   
   return s;
}

function validasi()
{
if(!cek((document.order.email.value)))
	{
	alert("Please check your email address");
	}
}
function cek(teks){
	if((teks=="")||(teks.indexOf('@')==-1)||(teks.indexOf('.')==-1))
	return false;
	else
	return true;
}

//form order
function validate_form_order ( )
{
    valid = true;

    if ( document.order_form.com_name.value == "" )
    {
        alert ( "Please fill in the 'Name Company' box." );
        valid = false;
    }
 	else if ( document.order_form.per_name.value == "" )
    {
        alert ( "Please fill in the 'Your Name' box." );
        valid = false;
    }
	else if ( document.order_form.email.value == "" )
    {
        alert ( "Please fill in the 'Your Email' box." );
        valid = false;
    }
	else if ( document.order_form.product.value == "" )
    {
        alert ( "Please fill in the 'Your Product' box." );
        valid = false;
    }
		else if ( document.order_form.qty.value == "" )
    {
        alert ( "Please fill in the 'Your Quantity (per MT)' box." );
        valid = false;
    }
    return valid;
}

//form contact
function validate_form_contact ( )
{
    valid = true;

    if ( document.contact.co_mc.value == "" )
    {
        alert ( "Please fill in the 'Name Company' box." );
        valid = false;
    }
 	else if ( document.contact.sender_mc.value == "" )
    {
        alert ( "This Contact Person  fields are required,please Fill it!" );
        valid = false;
    }
	else if ( document.contact.ph_mc.value == "" )
    {
        alert ( "Please fill in the 'Your Phone Number' box." );
        valid = false;
    }
	else if ( document.contact.mail.value == "" )
    {
        alert ( "Please fill in the 'Your Email Address' box." );
        valid = false;
		
    }
    return valid;
}

//form cek validasi

function cek (form)
{ 
	if (form.co_mc.value=="")
	{
	window.alert("Please fill in the 'Name Company' box!");
	form.co_mc.focus();
	return false;
	}
		if (form.sender_mc.value=="")
		{
		window.alert("This name fields are required,please Fill it!");
		form.sender_mc.focus();
		return false;
		}
				if (form.ph_mc.value=="")
				{
				window.alert("Please fill in the 'Your Phone Number' box.");
				form.ph_mc.focus();
				return false;
				}
					 if (form.mail.value=="")
					{
					window.alert("Please fill in the 'Your Email Address' box.");
					form.mail.focus();

					return false;
					}
						 if (form.qty.value=="")
						{
						window.alert("Please fill in the 'Your Quantity (per MT)' box.");
						form.qty.focus();
						return false;
						}
													else	
																		{
																		return true;
																		}
}

function order (form)
{ 
	if (form.com_name.value=="")
	{
	window.alert("Please fill in the 'Name Company' box!");
	form.com_name.focus();
	return false;
	}
		if (form.per_name.value=="")
		{
		window.alert("This name fields are required,please Fill it!");
		form.per_name.focus();
		return false;
		}
				if (form.email.value=="")
				{
				window.alert("Please fill in the 'Your Email Address' box.");
				form.email.focus();
				return false;
				}
					 if (form.product.value=="")
					{
					window.alert("Please fill in the 'Your Product' box.");
					form.product.focus();
					return false;
					}
						 if (form.qty.value=="")
						{
						window.alert("Please fill in the 'Your Quantity (per MT)' box.");
						form.qty.focus();
						return false;
						}
													else	
																		{
																		return true;
																		}
}
