<!--

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 ltrim ( s )
{
	return s.replace( /^\s*/, "" )
}

function rtrim ( s )
{
	return s.replace( /\s*$/, "" );
}


function trim ( s )
{
	return rtrim(ltrim(s));
}

function isNumeric(str)
{
  var len= str.length;
  if (len==0)
    return false;
  //else
  var p=0;
  var ok= true;
  var ch= "";
  while (ok && p<len)
  {
    ch= str.charAt(p);
    if ('0'<=ch && ch<='9')
      p++;
    else
      ok= false;
  }
  return ok;
}

function emailCheck (emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	alert("Please input a proper email")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]
if (user.match(userPat)==null) {
    // user is not valid
    alert("Please input a proper email")
    return false
}
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("Please input a proper email")
		return false
	    }
    }
    return true
}
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("Please input a proper email")
    return false
}
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   alert("Please input a proper email")
   return false
}
if (len<2) {
   var errStr="Please input a proper email"
   alert(errStr)
   return false
}
return true;
}

function isEmpty(str)
{
	temp=trim(str)
	if (temp.length==0)
	{
		return true
	}else
	{
		return false
	}
}

//CHECK WHETHER THE TEXT LENGTH IN 'FIELD' EXCEEDED THE 'MAXLIMIT', N DISPLAY CHARACTER LEFT AT 'COUNTFIELD' 
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else 
countfield.value = maxlimit - field.value.length;
}

function confirmdelete()
{
var agree=confirm("Do you want to delete these data?");
if (agree)
	return true ;
else
	return false ;
}

//CHECK WHETHER THE 'STR' IS EMPTY OR NOT,IF IT IS EMPTY THEN THE 'STRNAME' WILL BE ADDED TO THE  ERROR 'MESSAGE'
function validateString(message, str, strname){
	if (isEmpty(str))
	{
 		message=message+strname+", ";
	}
	return message
}

//DISPLAY ERROR 'MESSAGE' IF ERROR EXIST ('MESSAGE'<>' ') N CANCEL SUBMIT IF ERROR EXIST ('MESSAGE'<>' ' OR 'VALID'=FALSE)
function validationMessage(message,valid)
{
if ((message==" ") && (valid))
{
 return true; 
}
else
{
	if (message!=" ")
	{
		message=message.substring(0,message.length-2)
 		message="Please input your " + message;
 		alert(message);
 	}
 	return false;
 }
}

function checknum(isi)
{
	temp=isi.value
	if ((!(isNumeric(isi.value)))&&(trim(isi.value)!=''))
	{
		alert("Qty must be numeric!")
	}
	for(i=0;i<isi.value.length;i++)
	{
		betul="no"
		for(j=0;j<=9;j++)
		{
			if(isi.value.charAt(i)==j+'')
			{
				betul="yes"
			}
		}
		if(betul=="no")
		{
			temp=temp.replace(isi.value.charAt(i),'')
		}
	}
	isi.value=temp
	if ((isi.value<=0)&&(trim(isi.value)!=''))
	{
		alert("Qty must be bigger than 0")
		isi.value="1"
	}
}

function checkQtyEmpty(isi)
{
	if(trim(isi.value)=='')
	{
			alert('You must fill the Qty');
			isi.value='1';
			isi.focus();
	}
}

function milisvalidation()
{
	valid=true
	pesan=" "
	emailStr=(trim(document.milisForm.milisemail.value))
	pesan=validateString(pesan,emailStr,"Email")
	if (!(isEmpty(emailStr)))
	{
 	if (!(emailCheck(emailStr))) 
 	{
 		valid=false;
	}
	}
	return validationMessage(pesan,valid)
}
         
function ValidateSearch()
{
	valid=true
	pesan=" "
	temp=document.formSearch.SearchStr.value.toUpperCase()
	temp=rtrim(ltrim(temp))
	pesan=validateString(pesan,temp,"Search String")
	var rep1=/\bAND\b/
	var rep2=/\bOR\b/
	temp2=temp
	while (temp2.match(rep1)!=null)
	{
		temp2=temp2.replace(rep1,"")	
	}
	while (temp2.match(rep2)!=null)
	{
		temp2=temp2.replace(rep2,"")	
	}
	if ((!(isEmpty(temp))) && (isEmpty(temp2)))
	{
 		alert("Please input more words beside condition words ('AND'/'OR')")
 		valid=false;
	}
	return validationMessage(pesan,valid)
}

//POP UP WINDOW 
function popUpAdminWindow(link) 
{ 
	var realHeight=320; 
	var realWidth=320; 
	var halfHeight=(realHeight/2); 
	var halfWidth=(realWidth/2); 
	var iMyWidth; 
	var iMyHeight; 
	//gets top and left positions based on user's resolution so hint window is centered. 
	iMyWidth = (window.screen.width/2) - (halfWidth+ 10); //half the screen width minus half the new window width (plus 10 pixel borders). 
	iMyHeight = (window.screen.height/2) - (halfHeight + 27); //half the screen height minus half the new window height (plus title and status bars). 
	var win2 = window.open(link,"Title","status=no,height=" + realHeight + ",width=" + realWidth + ",resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=no");  win2.focus(); 
}

//POP UP WINDOW 
function popUpRegisterWindow(link) 
{ 
	var realHeight=225; 
	var realWidth=250; 
	var halfHeight=(realHeight/2); 
	var halfWidth=(realWidth/2); 
	var iMyWidth; 
	var iMyHeight; 
	//gets top and left positions based on user's resolution so hint window is centered. 
	iMyWidth = (window.screen.width/2) - (halfWidth+ 10); //half the screen width minus half the new window width (plus 10 pixel borders). 
	iMyHeight = (window.screen.height/2) - (halfHeight + 27); //half the screen height minus half the new window height (plus title and status bars). 
	var win2=window.open(link,"Title","status=no,height=" + realHeight + ",width=" + realWidth + ",resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=no");  win2.focus(); 
}

//LOCKING
function updateLock(objectName,ID,filename) 
{
	if (objectName.checked)
	{
		lockStatus = "y";
	} 
	else 
	{
		lockStatus = "n";
	}
	linkName = (filename + ID + "&lockStatus=" + lockStatus);
	var submitOK = confirm("Do you want to change the status of this data?")
	if (submitOK == true)
	{
		doSave = open(linkName,"_top");
	}
	else 
	{
		if (objectName.checked)
		{
			objectName.checked = false;
		}
		else
		{
			objectName.checked = true;
		}
	}
}

//CHANGE DEFAULT TYPE FOR EACH PRODUCT
function updateType(objectName,ID,filename) 
{
	if (objectName.defaultChecked!=true)
	{
		linkName = (filename + ID);
		var submitOK = confirm("Do you want to make this size as the default size for the current product?")
		if (submitOK == true)
		{
			doSave = open(linkName,"_top");
		}
		else 
		{
		//check for all radio button n check the default ones
			objectName.checked=false
			for (i=0; i<document.myForm.length;i++)
			{
  			obj = document.myForm.elements[i];
   			if (obj.type == "radio")
   			{
	    		if (obj.defaultChecked)
  	  		{
    				obj.checked=true
    			}
	    	}
  		}
  	}
	}
}

function changeBrand()
{
	if (document.formBrand.brand.selectedIndex!=0)
	{
		window.location.href=document.formBrand.brand.value
	}
}

function cOn(td){
if(document.getElementById||(document.all && !(document.getElementById))){
td.style.backgroundColor="#EAE19F";
}
}
function cOut(td){
if(document.getElementById||(document.all && !(document.getElementById))){
td.style.backgroundColor="#6FD2E4";
}
}
-->

