 var checkOk = new Array();

checkOk[0] = "12288";
checkOk[1] = "8364";
var win = null;
function check(object,input_value) {
	if (!(checkchi(input_value))) {
		alert('Sorry, the information you filled is not in English. Please input in English instead                                            ');
		object.focus();
	}
}
function checkchi(myint) {

  var checkStr = myint;
  var allValid = true;

  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charCodeAt(i);
     if (ch > 256 && !isOkChar(ch))
    {      
      allValid = false;
      break;
    }
  }
  if ( !allValid )
  {
    return (false);
  }

  return (true);

}
function isOkChar(ch)
{
	for (j = 0;  j < checkOk.length;  j++)
      	if (ch == checkOk[j])
      	{
        	return true;
        }
    return false;
	
}

function checkDetail(input_value) {
   if (!(checkchi(input_value))) {
        show_choose(input_value);
        return false;
   }
   return true;
}



function show_choose(checkStr)
{
    var new_head = '<HTML><HEAD><TITLE>Check - CraftSources</TITLE><META content="text/html; charset=iso-8859-2" http-equiv=Content-Type>'+
                    '<style type=text/css>\<!--BODY,TD{color:#000;font-size:12px;font-family:Verdana,sans-serif;MARGIN-TOP:0px}A:LINK{color:#039;text-decoration:underline;}A:VISITED{color:#039;text-decoration:underline;}A:HOVER{color:#700054;text-decoration:underline;}.X{font:bold 24px Verdana,sans-serif;}.L{font:bold 18px Verdana,sans-serif;}.LM{font:bold 14.8px Verdana,sans-serif;}.M{font-size:12px;font-weight:bold}.C{font-size:12px}.S{font-size:10px}.S1{font-size:11px}.S9{font-size:9px}.MORE{font:bold 10px Verdana,sans-serif;text-decoration:underline;}.ST{font:bold 11px Verdana,sans-serif;}select{font-size:12px;}input{font-size:12px}.textarea{font-size:12px}--\></style>' +
                    '<BODY bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">'+
                    '<center>'+
                    '<table border=0 cellspacing="0" cellpadding="4" width="100%" bgcolor="#339900">'+
                    '<tr>'+
                        '<td class="heading5" ><font color="#FFFFFF">Sorry, part of the information you filled in is not in English (Marked in red below). Please change into English.<class=s></font></td>'+
                    '</tr>'+
                    '</table>'+
                    '<table border=0 cellspacing="0" cellpadding="4" width="100%">'+
                    '<tr>'+
                        '<td>';
    var new_end = '</td></tr></table><br><table border=0 cellspacing="0" cellpadding="4" width="100%" bgcolor="#339900"><tr><td class="heading5" align="center"><b><a href="javascript:opener.focus();window.close()"><img src="images/button_closewindow.gif" width="106" height="20" border="0"></a></b></td></tr></table></center></BODY></HTML>';
    var new_body = '';
    
    if(win==null||win.closed){
        win = window.open("about:blank","","width=420,height=200,scrollbars=yes,resizable=yes");
    }
    else{
        win.document.close();                       
    }   

    for (i = 0;  i < checkStr.length;  i++){

        ch = checkStr.charCodeAt(i);
        errChar = checkStr.charAt(i);
        if (ch > 128 && !isOkChar(ch)) {
            new_body += '<font color="#CC0000"><b>' + errChar + '</b></font>';
            
        }
        else {
            new_body += errChar;
        }
    }
    win.document.write(new_head+new_body+new_end);  
    win.focus();
}

function checkContainComma( value ){
    if(value==null)
        return false;
    for(i=0;i<value.length;i++){
        ch=value.charCodeAt(i);
        if(ch==44)
            return true;
    }    	 
    return false;
}


  


function trim1(inputString) {
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function