// JavaScript Document

<!--

function findChar(str,c){
//find index of  char c in string str

for(i = 0 ; i < str.length ; i++) 
     if(str.charAt(i) == c) return i;

     return -1 ; 
}

function findStringPortion(start,str,c){

// find a portion of a string , str ,and return it
//starting at index start , ending when char c is found. or end of the string is reached 

 			var scEnd = start ; 
		
			while(scEnd < str.length){
			   			
					if(str.charAt(scEnd) == c) break ;
						
						scEnd++; 
							
			}
 			
			return str.substring(start, scEnd) ;

}





function getSourceCode(){


//alert();

			var url = document.URL ; 			

			var s = findChar(url,'?') ; 
//alert(url);
			//no query string nothing to do 
			if(s  == -1){
//alert('no code');
				return ; 
			}
			
			
			//get the query portion of url
			var query = url.substring(findChar(url,'?') + 1,url.length)
			
			query = query.toLowerCase();
			
			
			//not a affiliate no affliate id defined so nothing to do 
			if(query.indexOf('sourcecode') ==  -1 ) return ; 
			
			var sourcecode  = "" ; 
			
			//find sourcecode
			afStart = query.indexOf('sourcecode');
			
			if(afStart != -1) sourcecode = findStringPortion(afStart,query,'&');
			
			//alert(sourcecode);

			sourcecode= sourcecode.substring(sourcecode.indexOf('=') + 1 , sourcecode.length);

			document.forms.trialForm.sourceCodeId.value = sourcecode ; 

}




//-->