var newCountries;
var country_dd_id   = 'search_country';
var subregion_dd_id = 'search_subregion';
var subregion_src_id = 'SimAjaxFrame';
var subregion_dd_area = 'subregion_area';
var min_country_form_name = 'min_country_search';
var min2_country_form_name = 'min2_country_search';

var browser=navigator.appName;
var version= navigator.appVersion;
var paren = version.indexOf('(');
var whole_version = navigator.appVersion.substring(0,paren-1);
version = parseFloat(whole_version);
var doIt='no';


function handle_subregion_dropdown(newCountry){
	var newCountry = newCountry; 
	document.getElementById(subregion_dd_id).disabled= true;
	//document.getElementById(subregion_src_id).src= "/cgi-bin/compare/request_dropdown.cgi?country_id=" + newCountry;
	document.getElementById(subregion_src_id).src= "/cgi/turbo1/request_dropdown.cgi?country_id=" + newCountry;
	doIt = 'yes';
}

function dw_display_iframe(ifrmId, divId) {
    if(doIt=='yes'){
        ifrmId = ifrmId; divId = divId; 
        var lyr = document.getElementById? document.getElementById(divId): null;
   
        if ( window.frames[ifrmId] && lyr ) {
            lyr.innerHTML = window.frames[ifrmId].document.body.innerHTML;
            lyr.style.display = 'block'; 
            window.frames[ifrmId].document.body.innerHTML ='';
            if ( typeof window.frames[ifrmId].doOnIframedLoad == 'function' ) {
                window.frames[ifrmId].doOnIframedLoad();
            }
            //Change subregion dropdown size For mini form search
            if( document.getElementById(min_country_form_name) ){
                var subregion_area = document.getElementById( subregion_dd_area );
                subregion_area.firstChild.style.width = '146px';
                subregion_area.firstChild.style.height = '18px';
            }
            
            if( document.getElementById(min2_country_form_name) ){
                var subregion_area = document.getElementById( subregion_dd_area );
                subregion_area.firstChild.style.width = '150px';
                subregion_area.firstChild.style.height = '18px';
            } 
        }
    }
} 	

function handle_subregion_dropdown_1(newCountry){

	var browser=navigator.appName;
    
    //Only Opera version more than 9.25
	if( (browser == 'Opera') && (version > 9.25) ){
	    document.getElementById(subregion_dd_id).innerHTML = ''; 
	}else{
	    document.getElementById(subregion_dd_id).disabled= true;
	}
	document.getElementById(subregion_src_id).src= "/cgi/turbo1/request_dropdown.cgi?country_id=" + newCountry;
}

function dw_display_iframe_1(ifrmId, divId) {

    //Only Opera Version 9.25
    if( (browser == 'Opera') && (version == 9.25) ){

        var frame_body = window.frames[ifrmId].document.body.innerHTML;
        var subregion_str = frame_body.indexOf('<SELECT');

        if( window.frames[ifrmId].document.body.innerHTML != '' && subregion_str > -1 ){
            var lyr = document.getElementById(divId);
            
            if ( window.frames[ifrmId] && lyr ) {
                lyr.innerHTML = window.frames[ifrmId].document.body.innerHTML;
                lyr.style.display = 'block'; 
       	        window.frames[ifrmId].document.body.innerHTML = '';
       	        
       	        if ( typeof window.frames[ifrmId].doOnIframedLoad == 'function' ) {
                    window.frames[ifrmId].doOnIframedLoad();
                }

            }
            newCountries = document.getElementById(country_dd_id).value;
        }
        
    }else{
        //Other Browser
        if(window.frames[ifrmId].document.body.innerHTML != '' ){ 
            
            //if exist divId Reture this node divId
            //not exist divId Reture NULL
            //var lyr = document.getElementById ? document.getElementById(divId) : null; 
            
            var lyr = document.getElementById(divId);
            
            if ( window.frames[ifrmId] && lyr ) {
                lyr.innerHTML = window.frames[ifrmId].document.body.innerHTML;
                lyr.style.display = 'block'; 
       	        window.frames[ifrmId].document.body.innerHTML = '';
            }
            newCountries = document.getElementById(country_dd_id).value;
        }
    }
     
}
