
document.write("<script language='javascript' src='ymPrompt/ymPrompt.js'></script>");


function $(element){
if(typeof element == "string")
	return document.getElementById(element);
else
	return element;
}


String.prototype.trim=function(){
		re = /^\|+|\|+$/g;
		return this.replace(re," ");
}

function checkUser(username){
	
	if(username.trim()==''){
		//$('msg').innerHTML = 'please enter username';
		return false;
	}
	/*
	if(username.length <6){
	   $('msg').innerHTML = '6-16 characters';
	   return false;
	}*/
	if(username.length >16){
	   //$('msg').innerHTML = '1-16 characters';
	   return false;
	}
	$('iframe').src = "checkuser.php?username="+escape(username);
}

function clearlog(){
	//clear logs and msg of error
	//$('username').value = '';
	$('msg').innerHTML = '';
}


function clearfirstnamelog(){
	//clear logs and msg of error
	//$('username').value = '';
	$('firstnameid').innerHTML = '';
}

function clearbox()
{
	$('termmsg').innerHTML = '' ;
}

function clearlastnamelog(){
	//clear logs and msg of error
	//$('username').value = '';
	$('lastnameid').innerHTML = '';
}

function clearzipid(){
	$('zipid').innerHTML = '';
}

function clearphoneid(){
	$('phoneid').innerHTML = '';
}

function clearcitylog(){
	//clear logs and msg of error
	//$('username').value = '';
	$('cityid').innerHTML = '';
}

function cleardpflog(){
	//clear logs and msg of error
	//$('dpfname').value = '';
	$('dpfmsg').innerHTML = '';
}

function clearpwdlog(){
	//clear logs and msg of error
	//$('passwd').value = '';
	$('pwdms').innerHTML = '';
}

function clearcpwdlog(){
	//clear logs and msg of error
	//$('cpasswd').value = '';
	$('cpwdmsg').innerHTML = '';
}

function clearemaillog(){
	//$('email').value = '';
	$('emailmsg').innerHTML = '';
}


function clearconlog(){
	//$('contact').value = '';
	$('contactmsg').innerHTML = '';
}


function onshowmaclog(){
	//$('dpfmacid').value = '';
	//$('macmsg').innerHTML = '';
	//$('example').style.display = 'block';
	//$('example').innerHTML = 'Example:';
	$('macmsg').style.display = 'block';
	//$('checkingmac').style.display = 'none';
	//$('macmsg').innerHTML = "Your 12 digit MACADDR Should Now appear on your frames screen  Like this MAC Addr:00:18:AB:01:4F:07";
	//$('macidcss').innerHTML = 'please enter 12 character MACID,you should check it out by your dpf product,e.g. 0019d8f28874,if your MACID is wrong,you cant get any services.Enter your MADID carefully and have fun!';
	
	/*
	$('macmsg').innerHTML = "Your frame's serial number can be found on the outside of the box or near the power and phone cord ports on your frame. The serial number is comprised of just numbers and in the form (xx:xx:xx:xx:xx:xx). Enter each set of 2 charaters or digits in the boxes below. When done enter on the Next input.";
	*/

	$('macmsg').innerHTML = "Quick Tip: Your Macid will be displayed on your frame once it is connected to your wireless router and you have selected 'Internet Content' from the main menu on the frame.";

}


function checkusermacid(){
	//$('dpfmacid').value = '';
	//$('macmsg').innerHTML = '';
	//$('example').style.display = 'block';
	//$('example').innerHTML = 'Example:';
	$('macmsg').style.display = 'none';
	//$('macmsg').innerHTML = "Your 12 digit MACADDR Should Now appear on your frames screen  Like this MAC Addr:00:18:AB:01:4F:07";
	//$('macidcss').innerHTML = 'please enter 12 character MACID,you should check it out by your dpf product,e.g. 0019d8f28874,if your MACID is wrong,you cant get any services.Enter your MADID carefully and have fun!';
	//$('macmsg').innerHTML = "Your frame's serial number can be found on the outside of the box or near the power and phone cord ports on your frame. The serial number is comprised of just numbers and in the form (xx:xx:xx:xx:xx:xx). Enter each set of 2 charaters or digits in the boxes below. When done enter on the Next input.";
	
	var macid1 = $('dpfmacid1').value;
	var macid2 = $('dpfmacid2').value;
	var macid3 = $('dpfmacid3').value;
	var macid4 = $('dpfmacid4').value;
	var macid5 = $('dpfmacid5').value;
	var macid6 = $('dpfmacid6').value;
	$('dpfmacid').value = macid1+macid2+macid3+macid4+macid5+macid6;

	//alert($('dpfmacid').value);
	var mymacidis = $('dpfmacid').value;
	if($('dpfmacid').value=='' || $('dpfmacid').value.length !=12){
	//alert('DPFMACID must be 12 characters');
	return false;
	}else{
		$('iframe').src = "checkusermacid.php?macid="+escape(mymacidis);
	}

}


function clearoldpwdlog(){
	//$('oldpasswd').value = '';
	$('oldpwdmsg').innerHTML = '';
}

//dpfname
function checkdpfname(dpfname){
	if(dpfname.trim()==''){
		//$('dpfmsg').innerHTML = 'please enter DPF name';
		return false;
	}
	if(dpfname.length <1){
	   //$('dpfmsg').innerHTML = '1-20 characters';
	   return false;
	}
	if(dpfname.length >20){
	   //$('dpfname').value = '';
	   //$('dpfmsg').innerHTML = '1-20 characters';

	   return false;
	}
	$('dpfmsg').innerHTML = '<font color=#00BFFF>OK!</font>';
}


//check dpfmacid
function checkmacid(macid){
	if(macid.trim()==''){
		$('macmsg').innerHTML = "Your 12 characters or digits MACADDR Should Now appear on your frames screen  Like this MAC Addr:00:18:AB:01:4F:07";
		return false;
	}
	
	if(macid.length !=12){
	   //$('dpfmacid').value = '';
	   $('macmsg').innerHTML = "Your 12 characters or digits MACADDR Should Now appear on your frames screen  Like this MAC Addr:00:18:AB:01:4F:07";
		
	   $('example').style.display = 'block';
	   $('example').innerHTML = 'Example:';

	   return false;
	}
	$('mymacmsg').innerHTML = '<font color=#00BFFF>OK!</font>';
	$('example').style.display = 'none';
	$('example').innerHTML = '';
	$('macmsg').style.display = 'none';

}

// passwd
function checkpwd(pwd){
	
	if(pwd.length <8){
	   //$('pwdmsg').innerHTML = '8-16 characters';
	   return false;
	}
	if(pwd.length >16){
	   //$('passwd').value = '';
	   //$('pwdmsg').innerHTML = '8-16 characters';

	   return false;
	}
	/*
	  var str=pwd;	
      var reg = /^[x00-x7f]+$/;
      if (! reg.test(str))
	  {
       return false;
      }
      if (str.length < 6 || str.length > 16){
       return false;
	   $('pwdmsg').innerHTML = '8-16 characters';
      }
	*/

}




function checkfirstname(firstname){
	
	if(firstname.trim()==''){
		/* $('firstnameid').innerHTML = '<font color=#00BFFF>please enter your first name</font>';*/
		return false;
	}

	if(firstname.length >20){

	  /* $('firstnameid').innerHTML = '<font color=#00BFFF>1-20 characters</font>'; */

	   return false;
	}
	
	$('firstnameid').innerHTML = '<font color=#00BFFF>OK!</font>';
}



function checklastname(lastname){
	if(lastname.trim()==''){
		/* $('lastnameid').innerHTML = '<font color=#00BFFF>please enter your last name</font>';*/
		return false;
	}

	if(lastname.length >20){

	  /*$('lastnameid').innerHTML = '<font color=#00BFFF>1-20 characters</font>';*/

	   return false;
	}
	$('lastnameid').innerHTML = '<font color=#00BFFF>OK!</font>';
}


function checkcity(city){
	if(city.trim()==''){
		/* $('cityid').innerHTML = '<font color=#00BFFF>please enter your city name</font>';*/
		return false;
	}

	if(city.length >20){

	   /* $('cityid').innerHTML = '<font color=#00BFFF>1-20 characters</font>';*/

	   return false;
	}
	$('cityid').innerHTML = '<font color=#00BFFF>OK!</font>';
}


// pwd
function checkcpwd(cpwd){
	if(cpwd.trim()==''){
		/* $('cpwdmsg').innerHTML = '<font color=#00BFFF>please confirm password</font>';*/
		return false;
	}
	/*
	if(cpwd.length <8){
	   $('cpwdmsg').innerHTML = '<font color=#00BFFF>8-16 characters</font>';
	   return false;
	}*/

	if(cpwd.length >16){
	  //$('cpasswd').value = '';
	  /* $('cpwdmsg').innerHTML = '<font color=#00BFFF>8-16 characters</font>'; */

	   return false;
	}
	if($('passwd').value != $('cpasswd').value){
	   $('cpasswd').value = '';
	   /* $('cpwdmsg').innerHTML = '<font color=#00BFFF>password must be match!</font>'; */

	   return false;
	}
	$('cpwdmsg').innerHTML = '<font color=#00BFFF>OK!</font>';
}

// check email
function   checkemailname(email)
  {   
	
		var s=email;  
		if(email.trim()=='') return false;
        if   (s.length>32)   
        {   
                $('emailmsg').innerHTML = "characters < 32!";   
                return   false;   
        }          var   regu   =   "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT)$"   
        var   re   =   new   RegExp(regu);   


		if   (s.search(re)   !=   -1)     
        {   
			   $('emailmsg').innerHTML ='<font color=#00BFFF>OK!</font>';
              return   true;   
        }   
        else     
        {   
                $('emailmsg').innerHTML = "<font color=#00BFFF>invalid email,e.g. john@yahoo.com</font>";
				//$('email').value = '';
                return   false;   
				$('email').focus();
        }   
		
 
/*
	    var myReg = /^[-_A-Za-z0-9]+@([_A-Za-z0-9]+\.)+[A-Za-z0-9]{2,3}$/; 
		if( myReg.test(s)){
			$('emailmsg').innerHTML ='<font color=#00BFFF>OK!</font>'+s;
			return true; 
		}
        else     
        {   
                $('emailmsg').innerHTML = "<font color=#00BFFF>invalid email,e.g. john@yahoo.com</font>";
				//$('email').value = '';
                return   false;   
				$('email').focus();
        }   
  */
  }

//contact
  function checkconname(conname){
	if(conname.trim()==''){
		return false;
	}
	if(conname.length >20){
	   //$('contact').value = '';
	   $('contactmsg').innerHTML = '<font color=#00BFFF>1-16 characters</font>';

	   return false;
	}
	$('contactmsg').innerHTML = '<font color=#00BFFF>OK!</font>';
}


//open windows

function wincenter(url, name, width, height, features)
{
	var str = "height=" + height + ",innerHeight=" + height;
	str += ",width=" + width + ",innerWidth=" + width;
	if (window.screen)
	{
		var xc = Math.floor( (screen.availWidth - 10 - width) / 2);
		var yc = Math.floor( (screen.availHeight - 30 - height) / 2);
		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;

		if (features == '')
		{
			features = "resizable=no,scrollbars=yes,status=no,"
							+ "toolbar=no,menubar=no,location=no";
		}
		str += ',' + features;
	}
	return window.open(url, name, str);
}


/* choose which item */

	String.prototype.trim=function()
	{
		re = /^\|+|\|+$/g;
		return this.replace(re," ");
	}
	function choosewhich()
	{
		getvalued_add();
		get();
	}
	

	function getvalued_add()
	{	
		var valuedadd='';
		//free rss info
		if($('news').checked==true) 
		valuedadd+="news"+'|';
		if($('weather').checked==true) 
		valuedadd+="weather forecast"+'|';
		if($('Gmail').checked==true) 
		valuedadd+="Gmail"+'|';
		if($('Picasa').checked==true) 
		valuedadd+="Picasa"+'|';

		//valued-add value rss info
		if($('iptv').checked==true) 
		valuedadd+="iptv"+'|';
		if($('ipradio').checked==true) 
		valuedadd+="ipradio"+'|';
		if($('ipphone').checked==true) 
		valuedadd+="ipphone"+'|';

		$('valueaddt').value=valuedadd;

		//alert($('valueaddt').value);this is for test
		get();	
	}
	function get()
	{
		var  adv=$('valueaddt').value;
		var he=adv.trim();

		$('valueaddt').value=he; 
		//if(he!="") $('acc').value=$('creditno').value;
	}




function clearoldpwdlog(){
	//$('oldpasswd').value = '';
	$('oldpwdmsg').innerHTML = '';
}



function checkoldpwd(oldpwd){
	if(oldpwd.trim()==''){
		$('oldpwdmsg').innerHTML = 'please enter your old password';
		return false;
	}
	
	if(oldpwd.length <8){
	   $('oldpwdmsg').innerHTML = '8-16 characters';
	   return false;
	}
	if(oldpwd.length >16){
	   //$('oldpasswd').value = '';
	   $('oldpwdmsg').innerHTML = '8-16 characters';

	   return false;
	}
	$('oldpwdmsg').innerHTML = '<font color=#00BFFF>OK!</font>';
}


function changepwd(username){

//alert(username);

$('iframe').src = "edituserpwd.php?username="+escape(username);
}


function checkmyself(){

$('usererrlog').innerHTML = '';

if($('username').value=='' || $('username').value.length > 16){
			//$('msg').innerHTML += '<font color="#00BFFF" style="font-size:12px;">USER NAME is Required(1-16 Charaters)</font>';
			var sta = false;
}else{
	
	var username = $('username').value;
	$('iframe').src = "checkuser.php?username="+escape(username);

		var isuseriddie = $('myusridlog').value;
		
		if(isuseriddie == "sorry"){
			$('usererrlog').style.display= 'block';
			$('usererrlog').innerHTML = '<li><font color="#00BFFF">Sorry!&nbsp;UserName Registered,Please Try Again!</font></li>'+"<br>";
			$('myusridlog').value = "";
			return false;
		}
}



/**
	function:checkmacid again

var macid1 = $('dpfmacid1').value;
var macid2 = $('dpfmacid2').value;
var macid3 = $('dpfmacid3').value;
var macid4 = $('dpfmacid4').value;
var macid5 = $('dpfmacid5').value;
var macid6 = $('dpfmacid6').value;
$('dpfmacid').value = macid1+macid2+macid3+macid4+macid5+macid6;
*/

//var op = reguserinfo.test.options[reguserinfo.test.selectedIndex].value ;

var questionname = reguserinfo.quesname.options[reguserinfo.quesname.selectedIndex].text ;
var quesmsg = document.getElementById('quesmsg');
//var submacchek = $('dpfmacid').value;
/*
if($('dpfmacid').value=='' || $('dpfmacid').value.length !=12){
	ymPrompt.errorInfo("DPFMACID must be 12 characters","300","120","Error");
	return false;
}else if(op == "select"){
	ymPrompt.errorInfo("Please select Frame Model","300","120","Error");
	return false;
}else

*/
if(questionname == ""){
	quesmsg.innerHTML = "<font color='#00BFFF' style='font-size:12px;'> Please select your passwrod question</font>";
}

/*
else{
		$('iframe').src = "checkusermacid.php?macid="+escape(submacchek);

		var ismaciddie = $('mymacidlog').value;
		//alert(ismaciddie);
		if(ismaciddie == "sorry"){
			$('usererrlog').style.display= 'block';
			$('usererrlog').innerHTML = '<table><tr><td><font color="#00BFFF">Sorry!&nbsp;MACID Registered,Please Try Again!</font></td></tr></table>'+"<br>";
			$('mymacidlog').value = "";
			return false;
		}
}
*/




		if($('term').checked==false){
			$('termmsg').innerHTML = "<font color='#00BFFF' style='font-size:12px;'> You should be agree: sunlogic Terms of Service</font>";
			var sta = false;
			//$('dpfmsg').innerHTML = "";
		}

		if(document.getElementById('answer').value == ''){
			var anmsg = document.getElementById('anmsg');
			anmsg.innerHTML = "<font color='#00BFFF' style='font-size:12px;'> You must fill out the password answer</font>";
		}
		
		if($('firstname').value=='' || $('firstname').value.length >20){
			$('firstnameid').innerHTML += "<font color='#00BFFF' style='font-size:12px;'>First name is Required(1-20 Charaters)</font>";
			var sta = false;
			//$('dpfmsg').innerHTML = "";
		}
		if($('lastname').value=='' || $('lastname').value.length >20){
			$('lastnameid').innerHTML += '<font color="#00BFFF" style="font-size:12px;">Last name is Required(1-20 Charaters)</font>';
			var sta = false;
			//$('dpfmsg').innerHTML = "";
		}
		
		if($('username').value=='' || $('username').value.length > 16){
			$('msg').innerHTML += '<font color="#00BFFF" style="font-size:12px;">USER NAME is Required(1-16 Charaters)</font>';
			var sta = false;
			//$('dpfmsg').innerHTML = "";
			
		}
		/*
		if($('dpfmacid').value=='' || $('dpfmacid').value.length != 12){
			$('macid').innerHTML += '<font color="#00BFFF" style="font-size:12px;">DPF MAC ID is Required(Must be 12 Characters)</font>';
			var sta = false;
			//$('dpfmsg').innerHTML = "";
		}*/
		if($('passwd').value=='' || $('passwd').value.length > 16 || $('passwd').value.length < 8){
			$('pwdms').innerHTML += '<font color="#00BFFF" style="font-size:12px;">Password is Required(8 Characters)</font>';
			var sta = false;
			document.getElementById('pwdmsg').innerHTML = "";
		}
		if($('cpasswd').value=='' ||  $('cpasswd').value.length > 16 || $('cpasswd').value.length < 8 ){
			$('cpwdmsg').innerHTML += '<font color="#00BFFF" style="font-size:12px;">Confirm Password is Required</font>';
			var sta = false;
			//$('dpfmsg').innerHTML = "";
		}
		if($('zipcode').value=='' ||  $('zipcode').value.length != 5 ){
			$('zipid').innerHTML += '<font color="#00BFFF" style="font-size:12px;">Postal/ZIP Code is Required(must be 5 Characters)</font>';
			var sta = false;
			//$('dpfmsg').innerHTML = "";
		}
		if($('city').value=='' ||  $('city').value.length > 30){
			$('cityid').innerHTML += '<font color="#00BFFF" style="font-size:12px;">City is Required</font>';
			var sta = false;
			//$('dpfmsg').innerHTML = "";
		}
		if($('phoneno').value=='' ||  $('phoneno').value.length > 20){
			$('phoneid').innerHTML += '<font color="#00BFFF" style="font-size:12px;">Primary phone is Required</font>';
			var sta = false;
			//$('dpfmsg').innerHTML = "";
		}
		if($('email').value=='' ||  $('email').value.length > 30){
			$('emailmsg').innerHTML += '<font color="#00BFFF" style="font-size:12px;">email is Required</font>';
			var sta = false;
			//$('dpfmsg').innerHTML = "";
		}
		
		/*
		if(checkoption() == false){
			var msg = document.getElementById("msg");
			msg.innerHTML += '<font color="#00BFFF" style="font-size:12px;">Please Select Item Model </font>';
			return false;
		}*/
		
		/*
		if($('contact').value=='' ||  $('contact').value.length > 50){
			$('usererrlog').innerHTML += '<li>contact is Required</li>'+"<br>";
			var sta = false;
		}
		*/
		if(sta ==false){
			$('usererrlog').style.display= 'block';
			return false;
		}else{
			//alert('submint....');
			return true;
		}
		
}


var accstatusme =null;
var freestatusme =null;
var valstatusme =null;

function showaccmodule(module){

	if(module == 'accmodule'){
		if(accstatusme == null){
			$('accmodule').style.display = 'block';
			$('accoumtmodule').src = '../../img/home/spe/hideme.gif';
			accstatusme = 1;
		}else{
			$('accmodule').style.display = 'none';
			$('accoumtmodule').src = '../../img/home/spe/showme.gif';
			accstatusme = null;
		}
	}
}

function showfreemodule(module){
	if(module == 'freemodule'){
		if(freestatusme == null){
			$('freemodule').style.display = 'block';
			$('fremodule').src = '../../img/home/spe/hideme.gif';
			freestatusme = 1;
		}else{
			$('freemodule').style.display = 'none';
			$('fremodule').src = '../../img/home/spe/showme.gif';
			freestatusme = null;
		}
	}
}

function showvaludmodule(module){
	if(module == 'valudmodule'){
		if(valstatusme == null){
			$('valudmodule').style.display = 'block';
			$('valmodule').src = '../../img/home/spe/hideme.gif';
			valstatusme = 1;
		}else{
			$('valudmodule').style.display = 'none';
			$('valmodule').src = '../../img/home/spe/showme.gif';
			valstatusme = null;
		}
	}

}



function chooseaddr(myclass){
		//alert(postal.selectedIndex);
		//alert(myclass);
		$('addr').value =myclass.options[myclass.selectedIndex].text;
		//alert($('addr').value);
}


function choosepritel(youclass){
		//alert(youclass);
		//alert(postal.selectedIndex);
		$('pritelphone').value =youclass.options[youclass.selectedIndex].text;
		//alert($('pritelphone').value);
}


function gotopaypal(){
//alert('test');
	$('gopaypal').click();
}


function  userchannel(chamacid){
	document.location = '../../module/chapter/mychannel.php';
	
}


function  usergallery(galmacid){
	document.location = '../../module/chapter/tboxcusmade.php?macid='+galmacid;
	
}


function channelpoit(){
 $('mychanel').style ="cursor:pointer";
}


function gettablister(){
	if(event.keyCode==13) event.keyCode=9;
}

/*
function gettablister_freemodule(){
	if(event.keyCode==13) event.keyCode=9;
	$('freemodule').display = 'block';
}
*/



function myCheckbox(obj,thisobj)
{
	var o = document.getElementById(obj);
	if(o.checked)
	{
		thisobj.style.backgroundImage="url(../../img/home/spe/checkOff.gif)";
		o.checked = false;
	}
	else
	{
		thisobj.style.backgroundImage="url(../../img/home/spe/checkOn.gif)";
		o.checked = true;
	}
}

function regsubmit(){
			
	if(checkmyself() == true){
		var opstal = reguserinfo.postal.options[reguserinfo.postal.selectedIndex].value ;
		var question = reguserinfo.quesname.options[reguserinfo.quesname.selectedIndex].text;
		document.getElementById("country").value = opstal ;
		document.getElementById("quesub").value = question ;

		window.document.reguserinfo.submit();
	}
}


function aaa(){
	alert("aaa");
}
function updatemac(){
	var update  = document.getElementById("checkingmac");
	update.innerHTML = "";
}