var blank_country_option='';
var s_type;

function SetBlankCountryOption(type)
{   
	if ( type=='search')
    {
        blank_country_option='<select size="1" class="fieldShort" style="width:220px"><option value="0"> Any </option></select>';
    }
    else
    {
        blank_country_option='<select size="1" class="fieldShort" style="width:220px"><option value=""> Not Available </option></select>';
    }
}


function country_select(selected_c,type)
{      

	s_type = type;  
    c=j_country.length;

    var country_select='<select name="country" size="1" class="fieldShort" OnChange="region_select(this.value,\'\');">\r\n';
    var sel="";  

    if ( type=='search')
    {
        country_select+='<option value=""> Any </option>\r\n';
    }
    else
    {
        country_select+='<option value=""> please choose </option>\r\n';
    }
    
    for (i=0;i<c;i++)
    {
        if (j_country[i][4]==0)
        {
            if (selected_c!="" && j_country[i][0]==selected_c)
            {
                sel="SELECTED";
            }
            else
            {
                sel="";
            }
            
            country_select+='<option value="' +j_country[i][0] + '" ' +sel+ '>' + j_country[i][3] +' </option>\r\n';   
        }
    }
    
    country_select+='</select>';
    document.getElementById('fm_countries').innerHTML=country_select;
}


function region_select(current_country,selected_r)
{

    c=j_country.length;
    document.getElementById('fm_region').innerHTML="";   
        
    var region_select = '<select name="region" size="1" style="width:220px" class="fieldShort">\r\n';
    bFoundRegion = false;
    
    var sel="";
    
    if ( s_type=='search' )
    {
        region_select +='<option value=""> Any </option>\r\n'; 
    }
    else
    {
        region_select +='<option value=""> please choose </option>\r\n'; 
    }
    
    for (i=0;i<c;i++)
    {
        if ( j_country[i][0]==current_country && j_country[i][4]==1 )
        {       
             if (selected_r!="" && selected_r==j_country[i][1])
             {
                sel="SELECTED";
             }
             else
             {
                sel="";
             }
             
             bFoundRegion=true;
             region_select+= '<option value="' + j_country[i][1] + '" '+ sel + '>' + j_country[i][3] + '</option>\r\n';        
        }
    }
        
    region_select+='</select>';    
    
    if (bFoundRegion)
    {
        document.getElementById('fm_region').innerHTML=region_select;        
    }
    else
    {
        document.getElementById('fm_region').innerHTML=blank_country_option;       
    }       
}


function show_member_info_text( page )
{


}


function privacy_policy()
{
    window.open("./index.php?action=cv_privacy&popup=true","privacy","width=760,height=560,scrollbars=yes, resizable=yes");
    
} 


function tandc()
{
    window.open("./index.php?action=t-and-c&popup=true","privacy","width=760,height=560,scrollbars=yes, resizable=yes");       
} 

function gen_popup(action)
{
    window.open("./index.php?action=" + action + "&popup=true","privacy","width=760,height=560,scrollbars=yes, resizable=yes");   
}

function show_screenskin(url)
{
     //  alert (url);
	var normal = "";
    normal	= window.open (url,"normal","status=1,toolbar=0,width=564,height=532"); 
	if ( window.focus ) { normal.focus(); }
}


function show_pro_screenskin(url)
{
    var pro = "";
	pro		= window.open (url,"prowindow","status=1,toolbar=0,width=770,height=600"); 
	if ( window.focus) { pro.focus(); }
}


function multi_popup ( url, name,width, height )
{
	var mpopup 	= "";
	mpopup		= window.open (url,name,"status=1,toolbar=0,width=" + width + ",height=" + height); 
	if ( window.focus) { mpopup.focus(); }
}

function email_popup(url)
{

     if ( mywindow=window.open ( url ,"booking_email","status=1,toolbar=0,width=1px,height=1px"))
     { 
        setTimeout('mywindow.close()',8000);
     }
}

function send_password()
{
    if (document.form1.login.value=='')
    {
        document.getElementById('form_msg').innerHTML = 'Please Enter An Email Address';
    }
    else
    {
        email           = document.form1.login.value;
        location.href   = './index.php?action=login&forgot_password=1&email=' + email; 
    }

}


function wmv_player ( url , width , height , span_id )
{
	url = 'http://www.chaletvideo.com/' + url;		
	wmv = '<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" '
		 +'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"' 
		 +'  width="' + width +'" height="' + height + '" id="player" align="" border="">'
		 +'<param name="url" value="' +url+ '" />'
		 +'<embed width="' + width +'" height="' + height + '" name="player" align="" type="application/x-mplayer2"' 
		 +'	pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" src="' +url+ '"></embed>'
		 +'</object>';
		 
    document.getElementById( span_id ).innerHTML = wmv; 
}


function flash_pro_player ( flv, title, duration, span_id)
{
	var flashvars = "video_duration=" + duration + "&t=" + title + "&flv=" + flv; 
	var swf		  = "player_VV_design_3x4.swf";
	flash_play_initialise( swf, flashvars, span_id, 320, 245  );
}

function flash_chalet_nopro_player ( flv, title, duration, span_id )
{
	var flashvars = "video_duration=" + duration + "&t=" + title + "&flv=" + flv; 
	var swf		  = "player_VV_design.swf";
	flash_play_initialise( swf, flashvars, span_id, 240, 245 );
}

function flash_chalet_pro_player ( flv, buffer_seconds, duration, span_id)
{	
	var flashvars = "video_duration=" + duration + "&flv=" + flv + "&bufferSecs=" + buffer_seconds + "&linkTo=http://www.chaletvideo.com/viewingroom";
	var swf		  = "widescreen480v3.swf";
	flash_play_initialise( swf, flashvars, span_id, 480, 310 );
}

function flash_play_initialise( swf, flashvars, span_id, width, height )
{

	var flash= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ' 
		   +'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + width + '" height="' + height + '""> '
           +'<param name="movie" value="../core_images/swfs/' + swf + '"> '
           +'<param name="quality" value="high"> '
           +'<param name="flashvars" value="' + flashvars + '"> '
           +'<embed src="../core_images/swfs/' + swf + '" flashvars="' + flashvars + '" '
		   +'quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>'
           +'</object>';

	document.getElementById( span_id ).innerHTML = flash; 

}

function skin_media ( media_type, mode, duration, buffer_seconds, media_file, chosen )
{		
	fplayerpro 		= "flash_chalet_pro_player ( 'http://www.chaletvideo.com/chalet_videos/' + media_file, buffer_seconds , duration, 'movie_play');";
	fplayernopro	= "flash_chalet_nopro_player ( 'http://www.chaletvideo.com/chalet_videos/' + media_file, '' , duration, 'movie_play');";
	
	movie_wmv1 = "chalet_videos/" + movie_wmv;
	
	mplayerpro 		= "wmv_player ( movie_wmv1 , 480 , 336 , 'movie_play' );";
	mplayernopro	= "wmv_player ( movie_wmv1 , 240 , 245 , 'movie_play' );";
	
	fplayerlnk		= "skin_media( 'flash' , package_type , flash_duration, buffer_seconds, flash_flv);"; 
	mplayerlnk		= "skin_media( 'wmv' , package_type , '','', movie_wmv);"; 

	if ( media_type == 'flash' )
	{
		if ( mode == 'pro')
		{
			eval ( fplayerpro ) ;
		}
		else
		{
			eval ( fplayernopro ) ;
		}
	}
	else if ( media_type == 'wmv' )
	{
		if ( mode == 'pro')
		{	
			eval ( mplayerpro );
		}
		else
		{
			eval ( mplayernopro );
		}		
	}
	
	view_lnk = '';
	
	if ( wmv_status == 'enabled' && media_type == 'flash' )
	{
		view_lnk = 'To view in Windows Media Player click <a href="javascript:' + mplayerlnk + '">HERE<a/>...';
	}
	else if ( flash_status == 'enabled' && media_type == 'wmv' )
	{
		view_lnk = 'To view in Flash Player click <a href="javascript:' + fplayerlnk + '">HERE<a/>...';
	}

	document.getElementById( 'switch_movie' ).innerHTML = view_lnk;	
}

function call_chalet_video_intro(parameters)
{	 	
    parameter = parameters.split(",");	
	chalet_video_intro(parameter[0], parameter[1], parameter[2], parameter[3]); 
}

function chalet_video_intro(mode, video, length, player)
{	
	video1 = video;				
 	 var intro_lnk = new Array();
	 flash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="480" height="310">'
	          +'<param name="movie" value="./core_images/swfs/' + player + '">'
	          +'<param name="quality" value="high">'
	          +'<param name="flashvars" value="flv=http://www.chaletvideo.com/chalet_videos/' + video1 + '.flv&video_duration=' + length + '&bufferSecs=6&linkTo=http://www.chaletvideo.com/viewingroom">'
	          +'<embed src="./core_images/swfs/' + player + '" flashvars="flv=http://www.chaletvideo.com/chalet_videos/' + video1 + '.flv&video_duration=' + length + '&bufferSecs=6&linkTo=http://www.chaletvideo.com/viewingroom" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="480" height="310"></embed>'
	        +'</object>';	
	 	document.getElementById('intro_play').innerHTML = flash;	
}
