﻿// JScript File

function GetLove(spanResultLove ,ctrlYourName,ctrlLoveName)
{

    
        spanResultLove = document.getElementById(spanResultLove);
       
        var intRand = randomReal(50,100)
       
       /*
        var thecode1
        try{
            thecode1 = document.getElementById(ctrlYourName).value;
            
        }
        catch(err1)
        {
            thecode1 = ctrlYourName.value;
        }
        
        
        var thecode2
        try{
            thecode2 = document.getElementById(ctrlLoveName).value;
            
        }
        catch(err2)
        {
            thecode1 = ctrlLoveName.value;
        }
       
        
        var sum1 = 0;
        var sum2 = 0;
        var i = 0;        
        var Output = 0;

      
        for(i=0 ; i < thecode1.length ; i++)
        {
            try{
           sum1 = sum1 + String.charCodeAt(thecode1.charCodeAt(i)); 
           }catch(err3)
           {
            sum1 = 0.5 * ((thecode1.length + 100)/2);
           }
        }
        
        for(i=0 ; i < thecode2.length ; i++)
        {
          try{
           sum2 = sum2 + String.charCodeAt(thecode2.charCodeAt(i));  
           }catch(err4)
           {
            sum2 += 0.25 * ((thecode2.length+ 100)/2);
           }
        }
        
         
        var result ="";
        
        if (sum1 > sum2) 
            {result = sum1 / sum2;}
        else if (sum1 < sum2) 
            {result = sum2 / sum1;}
        else if (sum1 == sum2) 
            {
               spanResultLove.innerHTML = "100%";
             var resultDiv = document.getElementById("spanResultDiv");
		resultDiv.style.display="block";
		
             return false;     
            }
            
        
        if( (eval(result) % 1) == 0 )
        {    
             spanResultLove.innerHTML = "100%";
             var resultDiv = document.getElementById("spanResultDiv");
		resultDiv.style.display="block";
		
             return false;   
        }
        
        result = result + "00.000";
        
        
        Output = eval(result.substring(result.indexOf(".") + 1, result.indexOf(".") + 2));

        while(Output < 60)
        {
            Output = Output + 20;
        }
        
        */
        
        var strRand = "" + intRand;
        strRand =strRand.substring(0,strRand.indexOf("."))
        
                
        spanResultLove.innerHTML = strRand +"%";
        var resultDiv = document.getElementById("spanResultDiv");
		resultDiv.style.display="block";	
        return true;  
}




function randomReal(low, high)
// Given  : low <= high
// Given  : a random real number in the range [low, high)
{
    return Math.random()*(high-low) + low;
}

function randomInt(low, high)
// Given  : low <= high
// Given  : a random real integer in the range [low, high]
{
    return Math.floor(Math.random()*(high-low+1)) + low;
}

function randomChar(str)
// Given  : str is a nonempty string
// Returns: a random character from the string
{
        return str.charAt(randomInt(0, str.length-1));
}

function randomItem(list)
// Given  : list is a nonempty list (array)
// Returns: a random item from the list
{
        return list[randomInt(0, list.length-1)];
}
