
// ONLINE REGISTER
	
	// ---- incearca sa completeze A6ProductID functie de URL
	/*function CompleteazaID ()
	{var am=document.location
	am=am.substring(am.indexOf("?"),am.lenght-am.indexOf("?"))
   ma=am.indexOf("?")
   alert("URL" + am)
	return false}
	*/

                        function Data ()
                        {convert_1()
	                 document.register.A0Subject_h.value='45% off for ' + document.register.A2ProductName.value}                


                        function checkData ()
                        {                                                     
                              									
                               // ---- verifica daca au fost completate cimpurile
                               if (document.register.A6ProductID_h.value == "") 
									{alert("Write here your Product ID!")
									document.register.A6ProductID_h.select();
                               document.register.A6ProductID_h.focus()
                               return false}

                               if (document.register.B0Name_h.value == "") 
									{alert("Write here your name!")
                               document.register.B0Name_h.select()
                               document.register.B0Name_h.focus()
                               return false}                                     

                               var string1=document.register.B2Email_h.value
                               if (string1.indexOf("@")==-1)
									{alert("Please input a valid B2Email_h address!")
									document.register.B2Email_h.select()
									document.register.B2Email_h.focus()
									return false}
                              
                              // ---- verifica daca primul caracter la A6ProductID_h este litera sau numar
								    var string = '' + document.register.A6ProductID_h.value;								
									if (string.charAt(0)!='1' && string.charAt(0)!='2' && string.charAt(0)!='3' && string.charAt(0)!='4' && string.charAt(0)!='5' && string.charAt(0)!='6' && string.charAt(0)!='7' && string.charAt(0)!='8' && string.charAt(0)!='9' && string.charAt(0)!='0')
									{ alert("This is not a valid Product ID! You will find your Product ID in the registration form provided with program.")
									document.register.A6ProductID_h.select();
									document.register.A6ProductID_h.focus();
									return false}
								
									Data()  
                         
                         		if (document.register.A2ProductName.value=="")
                         		{alert("This PRODUCT ID is not valid or you try to register a software witch doesn't support Online Registration!")
                               return false}
                        }


	//programul si versiunea
	function prog_id(IND) 
	{str_out = "";					
	str_in="" + IND;
							

	document.register.A4ProductVersion.value=str_in.substring(5,4) + "." + str_in.substring(6,5);																
	
	num_out =str_in.substring(4,0);  			
	
	for(i = 0; i < num_out.length; i += 2) 
	{num_in = parseInt(num_out.substr(i,[2]));
	num_in = unescape('%' + num_in.toString(16));
	str_out += num_in;}

							
	if (str_out=="TC") {document.register.A2ProductName.value="Total Control";}
	if (str_out=="QH") {document.register.A2ProductName.value="Quick Hide";}
	if (str_out=="SS") {document.register.A2ProductName.value="Software Submit Helper";}
	}



//------- afla limba folosita ---------------------------------------------------------
function language(IND) 
	{    var lng="";
		 var tmp=document.register.D2LNG_h.value;
	if (IND=="00") {lng="romanian";}
	if (IND=="02") {lng="english";}
	if (IND=="04") {lng="italian";}
	if (IND=="06") {lng="french";}
	if (IND=="08") {lng="german";}
	if (IND=="10") {lng="spanish";}
	if (IND=="12") {lng="portuguese";}
	if (IND=="14") {lng="norwegian";}
	if (IND=="16") {lng="dutch";}
	if (IND=="18") {lng="czech";}
	if (IND=="20") {lng="turkish";}
	if (IND=="22") {lng="russian";}
	if (IND=="24") {lng="chinese";}
	if (IND=="11") {lng="other";}

	document.register.D2LNG_h.value=tmp + "  " + lng;																
	}
//-------------------------------------------------------------------------------------



//------- algoritm criptare -----------------------------------------------------------
		function convert_1() 
		{input=(document.register.A6ProductID_h.value);

		len = input.length;
		if (len>9)
		{	
		//-----------------------------------------------------
		//alert('1' + input.substring(len-4,len-2))
		language(input.substring(len-4,len-2));
		//alert('2' + input.substring(len-2,len))
		language(input.substring(len-2,len));
		//-----------------------------------------------------
		input=input.substring(0,len-4);
		}

		origin=16;
		dest=10;
		base="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		c=0; Result="";

			for (t=1; t<=input.length; t++) 
			{b=base.indexOf(input.substring(t-1,t));
			n=b*(Math.pow (origin, input.length-t));
			c+=n;}

		a=100;
			while (c < Math.pow (dest, a)) { a--; }
			while (a>-1) 
			{e=Math.pow (dest, a);
			a--;
			d=((c-(c%e))/e)+1;
			c=c%e; Ciffer=base.substring(d-1, d); Result = Result + Ciffer;}

		NRT=parseInt(Result.substring(0,4))+parseInt(Result)
		document.register.A8RegistrationKEY_h.value=NRT

		prog_id(Result.substring(0,6))
		
		input=(document.register.A8RegistrationKEY_h.value);
		origin=10;
		dest=12;
		base="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		c=0; Result="";

			for (t=1; t<=input.length; t++) 
			{b=base.indexOf(input.substring(t-1,t));
			n=b*(Math.pow (origin, input.length-t));
			c+=n;}

		a=100;
			while (c < Math.pow (dest, a)) { a--; }
			while (a>-1) 
			{e=Math.pow (dest, a);
			a--;
			d=((c-(c%e))/e)+1;
			c=c%e; Ciffer=base.substring(d-1, d); Result = Result + Ciffer;}

		document.register.A8RegistrationKEY_h.value=Result;
		}
//-------------------------------------------------------------------------------------
