var max_allowed_link_index=0;
var lastdev='';	
 
function redirect_to_license_page(){
	document.forms['config_form'].predef_url.selectedIndex=0;
	document.forms['config_form'].runurl.value='';
	document.location.href='./?mode=LICENSE';
};

  
function check_onsubmit(){
   if(document.forms['config_form'].runurl.value != document.forms['config_form'].predef_url.value){
        redirect_to_license_page();
	return false;
    };
}

  
function show_in_frame(dev) {
    last_dev = dev;
    //alert(document.forms['config_form'].predef_url.value);
    if(document.forms['config_form'].predef_url.value=='http://www.google.com/gmm/tour.html'){
    	window.open(document.forms['config_form'].predef_url.value);
    	document.forms['config_form'].predef_url.selectedIndex=0;
    	return;
    	//window.open(document.forms['config_form'].pred_urls.value='';
    }
    if(document.forms['config_form'].predef_url.value=='hummer_jnr_s60'){
    	document.getElementById('jme_device').src='http://mobilerunner.wap3.net:8080/emulator/midlets/demo3d/hummer_jnr_s60.jad/index.html?skin='+last_dev+'&rand='+Math.random();
    	return;
    }
	if(document.forms['config_form'].runurl.value.length == 0) {
      document.forms['config_form'].runurl.value = document.forms['config_form'].predef_url.value;
	};
    document.forms['config_form'].rundevice.value = dev;  

    if(document.forms['config_form'].runurl.value != document.forms['config_form'].predef_url.value){
    	redirect_to_license_page();
    	return
    };
    if(document.forms['config_form'].predef_url.selectedIndex > max_allowed_link_index){
    	if(document.forms['config_form'].predef_url.options.length - document.forms['config_form'].predef_url.selectedIndex > 4){ 	
    	   	redirect_to_license_page();
    	return;
    	}
    };
    
    document.forms['config_form'].submit();
    if(document.getElementById('run_url_id').type=='text'){
    	document.getElementById('run_url_id').focus();
    }
    
};
  
function do_mail(to, subj) {
    if(to==1) t = "contact";
    if(to==2) t = "contact";
    if(to==3) t = "contact";
    if(to==4) t = "contact";
    if(to==5) t = "contact";
    document.location.href = "mailto:"+t+"@"+"mobilerunner.net"+"?subject="+escape(subj);
};

function ch_ua() {
    ind = document.forms['config_form'].predef_uagent.value;
    document.forms['config_form'].uagent.value = ua_ua[ind];
};


var preloadFlag = false;

function preloadPage() {
  	return;
};

function qt_popup() {
   if (navigator.appVersion.indexOf("Win") < 0 ) return 1;
   if (navigator.appName.substring(0,9) != "Microsoft") return 1;
   var haveqt=true;
   if(document.getElementById){
   		try{
   			var qtobj= new ActiveXObject("QuickTimeCheckObject.QuickTimeCheck.1");
		} 
   		catch(err){
 	    	window.open('qt.php', "qt_popup", "toolbar=0,location=0,directories=0,status=0,screenX=700,screenY=600,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=300,height=120");
 	    	return 1;
   		};
   };
	if(qtobj!=null){
		haveqt=qtobj.IsQuickTimeAvailable(0);
	}
 	if(haveqt==false){
 		window.open('qt.php', "", "toolbar=0,location=0,directories=0,status=0,screenX=700,screenY=600,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=300,height=120");
 	}
};
