var info = new Array(), jm_marquee = new Array();

function sCode(text, width, height, direction, speed, ID) {
	direction = direction.toLowerCase(); if (ID != null) text = document.getElementById(ID).innerHTML;
	if (direction != 'left' && direction != 'up' && direction != 'right' && direction != 'down') direction = 'left';
	if (speed == null) speed = 50;
	var txt = '<div id="demo' + info.length + '0" style="overflow: hidden; width: ' + width + 'px; height: ' + height + 'px;">\r';
	txt += '  <table width="' + ((direction == 'left' || direction == 'right') ? width * 2 : width) + '" border="0" cellspacing="0" cellpadding="0" onmouseover="javascript: clearInterval(jm_marquee[' + jm_marquee.length + ']);" onmouseout="javascript: jm_marquee[' + jm_marquee.length + '] = setInterval(\'marquee(\\\'' + direction + '\\\', ' + info.length + ');\', ' + speed + ');">\r';
	if (direction == 'left' || direction == 'right') {
		txt += '    <tr>\r';
		txt += '      <td width="' + width + '" id="demo' + info.length + '1">' + text + '</td>\r';
		txt += '      <td width="' + width + '" id="demo' + info.length + '2">' + text + '</td>\r';
		txt += '    </tr>\r';
	}
	else {
		txt += '    <tr height="' + height + '">\r';
		txt += '      <td width="' + width + '" id="demo' + info.length + '1">' + text + '</td>\r    </tr>\r';
		txt += '    <tr height="' + height + '">\r';
		txt += '      <td width="' + width + '" id="demo' + info.length + '2">' + text + '</td>\r    </tr>\r';
	}
	txt += '  </table>\r</div>'; txt = txt.replace('\r', "\r\n"); info[info.length] = txt;
	if (ID == null) document.write(txt);
	else document.getElementById(ID).innerHTML = txt;
	jm_marquee[jm_marquee.length] = setInterval('marquee(\'' + direction + '\', ' + (info.length - 1) + ');', speed);
}

function marquee(direction, obj) {
	var Obj = new Array(), i = 0;
	for (; i < 3; i++) Obj[i] = document.getElementById('demo' + String(obj) + String(i));
	if (direction == 'left') {
		if (Obj[2].offsetWidth - Obj[0].scrollLeft < 2) Obj[0].scrollLeft -= Obj[1].offsetWidth;
		else Obj[0].scrollLeft++;
	}
	if (direction == 'up') {
		if (Obj[2].offsetTop - Obj[0].scrollTop < 2) Obj[0].scrollTop -= Obj[1].offsetHeight;
		else Obj[0].scrollTop++;
	}
	if (direction == 'right') {
		if (Obj[0].scrollLeft < 2) Obj[0].scrollLeft = Obj[1].offsetWidth * 2;
		else Obj[0].scrollLeft--;
	}
	if (direction == 'down') {
		if (Obj[0].scrollTop < 2) Obj[0].scrollTop = Obj[1].offsetHeight * 2;
		else Obj[0].scrollTop--;
	}
}



function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}

function checkfk()
{
 if(checkstr(fkinfo.fksubject.value)==1)
 { alert("Sorry,please input the subject!");
 return false;
 }
 if(checkstr(fkinfo.fksubject.value)==2)
 { alert("Sorry,your subject inlude non-English characters");
 return false;
 }
 if(checkstr(fkinfo.fkusername.value)==1)
 { alert("Sorry,please input the name!");
 return false;
 }
 if(checkstr(fkinfo.fkusername.value)==2)
 { alert("Sorry,the name inlude non-English characters");
 return false;i
 }
 
 if(checkstr(fkinfo.job.value)==2)
 { alert("Sorry,the position inlude non-English characters");
 return false;
 }
 if(checkstr(fkinfo.id.value)==2)
 { alert("Sorry,the user ID inlude non-English characters");
 return false;
 }
 if(checkstr(fkinfo.fkemail.value)==1)
 { alert("Sorry,please input the email!");
 return false;
 }
 if(checkstr(fkinfo.fkemail.value)==2)
 { alert("Sorry,your email inlude non-English characters");
 return false;
 }

 
    if (fkinfo.fkemail.value.charAt(0)=="." ||        
         fkinfo.fkemail.value.charAt(0)=="@"||       
         fkinfo.fkemail.value.indexOf('@', 0) == -1 || 
         fkinfo.fkemail.value.indexOf('.', 0) == -1 || 
         fkinfo.fkemail.value.lastIndexOf("@")==fkinfo.fkemail.value.length-1 || 
         fkinfo.fkemail.value.lastIndexOf(".")==fkinfo.fkemail.value.length-1)
     {
      alert("Sorry!Email pattern is incorrect!");
      fkinfo.fkemail.focus();
      return false;
      }
 
 if(checkstr(fkinfo.country.value)==2)
 { alert("Sorry,the country inlude non-English characters");
 return false;
 }

 if(checkstr(fkinfo.fklaizi.value)==2)
 { alert("Sorry,the address inlude non-English characters");
 return false;
 } 
 if(checkstr(fkinfo.postcode.value)==2)
 { alert("Sorry,your postal code inlude non-English characters");
 return false;
 }
  if(checkstr(fkinfo.fktel.value)==1)
 { alert("Sorry,please input the tel!");
 return false;
 }
 if(checkstr(fkinfo.fktel.value)==2)
 { alert("Sorry,your tel inlude non-English characters");
 return false;
 }
  if(checkstr(fkinfo.fax.value)==1)
 { alert("Sorry,please input the fax!");
 return false;
 }
 if(checkstr(fkinfo.fax.value)==2)
 { alert("Sorry,your fax inlude non-English characters");
 return false;
 }
  if(checkstr(fkinfo.fkcontent.value)==1)
 { alert("Sorry,please input the information!");
 return false;
 } 
}
function checkstr(str){ 
 if(str=="")
{
  return 1;
}
else
{  
for(var i=0;i<str.length;i++)
if(str.charCodeAt(i) > 128 && !isOkChar(str.charCodeAt(i))) {       
return 2;
}
}
}

var total_num = 0;
var checkOk = new Array();

checkOk[0] = "12288";
checkOk[1] = "8364";

var specialChars = ["?","¡À","¡Á","8216","?","8212","8804","8805","¡ì","969","945","946","947","948","951","952","955","956","957","958","960","963","964","966","967","931","934","937","8712","8240","¡Â","8800","961","8744","8743","8721","8734","8801","8730","¡¤","916","?","?","?","?","?","?","?","?","C?","F¡ã","?","?","8364","?","8482",""];
var win = null;
function check(object,input_value) {
	if (!(checkChinese(input_value))) {
		alert('Sorry, the information you filled is not in English. Please input in English instead                                            ');
		object.focus();
	}
}
	
	
function checkChinese(myint) {
	var str = myint;
	var isChinese = true;
	for (i = 0;  i < str.length;  i++)
	{
	c = str.charCodeAt(i);
	if (c > 128 && !isOkChar(c))
	{
	isChinese = false;
	break;
	}
	}
	if ( !isChinese )
	{
	return (false);
	}
	return (true);
}
function checkSpecialChinese(myint) {
	var str = myint;
	var isChinese = true;
	for (i = 0;  i < str.length;  i++)
	{
	c = str.charCodeAt(i);
	if (c==25||(c > 128 && !isOkSpecialChar(c)))
	{
	isChinese = false;
	break;
	}
	}
	if ( !isChinese )
	{
	return (false);
	}
	return (true);
}	
	
function isOkSpecialChar(ch)
{
	for (j = 0;  j < specialChars.length;  j++)
	if (ch == specialChars[j])
	{	
	return true;
	}
	return false;
}
function isOkChar(ch)
{
	for (j = 0;  j < specialChars.length;  j++)
	if (ch == checkOk[j])
	{
	return true;
	}
	return false;
}
function transHTML(str)
{
	//ÈçÊÇ/n/r ×ª»»³É<br>
	//<,>Ìæ»».
	var regexp1 = /\r\n/gi;
	var regexp2 = /\n/gi;
	var regexp3 = /</gi;
	var regexp4 = />/gi;
	//var regexp5 = /\"/gi;
	//var regexp6 = /&/gi;
	str = str.replace(regexp3, "&lt;");
	str = str.replace(regexp4, "&gt;");
	//str = str.replace(regexp5, "&quot;");
	//str = str.replace(regexp6, "&amp;");
	str = str.replace(regexp1, "<br>");
	str = str.replace(regexp2, "<br>");	
	return str;
}
function open_window_specialChar(str)
{
	str =transHTML(str);	  
var new_head =  '<title>www.1001PP.com</title>'+
			  '<link href="../../style/mainfont.css" rel="stylesheet" type="text/css" />'+
              '<link href="../../style/style.css" rel="stylesheet" type="text/css" />'+
			  
			'<br><table width="439" border="0" align="center" cellpadding="0" cellspacing="0" >'+
         '<tr>'+
           '<td height="29" background="/images/check/top.jpg">&nbsp;</td>'+
         '</tr>'+
         '<tr>'+
'<td background="/images/check/center.jpg"><table width="95%" border="0" align="center" cellpadding="4" cellspacing="0">'+
             '<tr>'+
 '<td><span class="DH">Sorry, you input non-English characters (Marked in red below). Please modify them into English.</span>'+
 '</td>'+
'</tr>'+
'<tr>'+
'<td>';
var new_end = '</td>'+
             ' </tr>'+
            '  <tr>'+
 '<td align="center"><img src="/images/check/logo.gif" width="9" height="9">&nbsp;&nbsp;'+
  '<a href="javascript:window.close()" class="DH33">Close the window</a></td>'+
              '</tr>'+
              '<tr>'+
 '<td align="center"><span class="font1016black2"><span class="font1016black2e"><font face="Arial, Helvetica, sans-serif">'+'Copyright(c)</font></span> <font face="Arial, Helvetica, sans-serif">'+
  '<span class="font1016black2e">200</span><span class="STYLE2">3-2009</span>'+
                     ' <Hanker International>'+
                     ' <span class="font1016black2e">1001PP.Com</span>'+ 
 '<span class="font1016black2e"> All Rights Reserved.</span></font></span></td>'+
             ' </tr>'+
            '</table></td>'+
          '</tr>'+
          '<tr>'+
           ' <td height="19" background="/images/check/foot.jpg">&nbsp;</td>'+
         ' </tr>'+
      '  </table> ';		  
			  
	var new_body = '';											
	if(win==null||win.closed)
	{
		win = window.open("about:blank","","width=470,height=200,scrollbars=yes,resizable=yes");
	}
	else
	{
		win.document.close();
	}
	for (i = 0;  i < str.length;  i++)
	{
		ch = str.charCodeAt(i);
		errChar = str.charAt(i);		
		if (ch==25||(ch > 128 && !isOkSpecialChar(ch))) {
			
			if(ch==12288){
				new_body += '<font color="#CC0000"><b>&amp;nbsp;</b></font>';
			}else{
new_body += '<font color=red style="BORDER-bottom: #999999 1px dotted;line-height:200%;"><b>' + errChar + '</b></font>';
			}
			
		}else {
			new_body += errChar;
		}
	}
	win.document.write(new_head+new_body+new_end);
	win.focus();
}


