var site="";
function buildit(the_choice){
var the_code = "";
var the_url = document.window_form.url.value;
var the_x = document.window_form.width.value;
var the_y = document.window_form.height.value;
the_x -= 0;
the_y -= 0;

the_code = '<script language="JavaScript" type="text/javascript">\n';
the_code += '<!-- \n';
the_code += 'function open_win(what_link){ \n';
the_code += 'var the_url = "'+the_url+'"\n';
the_code += 'var the_x = '+the_x+';\n';
the_code += 'var the_y = '+the_y+';\n';
the_code += 'the_x -= 0;\n';
the_code += 'the_y -= 0;\n';
the_code += 'var how_wide = screen.availWidth;\n';
the_code += 'var how_high = screen.availHeight;\n';

the_code += 'if(what_link != ""){the_url=what_link;}\n';


var the_toolbar = document.window_form.toolbar.options[document.window_form.toolbar.selectedIndex].value;
var the_addressbar = document.window_form.address_bar.options[document.window_form.address_bar.selectedIndex].value;
var the_directories = document.window_form.directories.options[document.window_form.directories.selectedIndex].value;
var the_statusbar = document.window_form.statusbar.options[document.window_form.statusbar.selectedIndex].value;
var the_menubar = document.window_form.menubar.options[document.window_form.menubar.selectedIndex].value;
var the_scrollbars = document.window_form.scrollbars.options[document.window_form.scrollbars.selectedIndex].value;
var the_do_resize = document.window_form.do_resize.options[document.window_form.do_resize.selectedIndex].value;
var the_copy_history = document.window_form.copy_history.options[document.window_form.copy_history.selectedIndex].value;


the_code += 'var the_toolbar = "'+the_toolbar+'";\n';
the_code += 'var the_addressbar = "'+the_addressbar+'";\n';
the_code += 'var the_directories = "'+the_directories+'";\n';
the_code += 'var the_statusbar = "'+the_statusbar+'";\n';
the_code += 'var the_menubar = "'+the_menubar+'";\n';
the_code += 'var the_scrollbars = "'+the_scrollbars+'";\n';
the_code += 'var the_do_resize =  "'+the_do_resize+'";\n';
the_code += 'var the_copy_history = "'+the_copy_history+'";\n';
	radcount = document.window_form.screen_pos.length ;
		for (var a = 0; a < radcount; a++){
			if (document.window_form.screen_pos[a].checked){
			var the_position = document.window_form.screen_pos[a].value;
			var is_pos_choice = a+1;
			}
		}
		
var how_wide = screen.availWidth;
var how_high = screen.availHeight;

	
if (is_pos_choice == 1){
top_pos = 0;
left_pos = 0;
the_code += 'top_pos = 0;\n';
the_code += 'left_pos = 0;\n';
}

if (is_pos_choice == 2){
top_pos = 0;
left_pos = (how_wide/2) -  (the_x/2);
the_code += 'top_pos = 0;\n';
the_code += 'left_pos = (how_wide/2) -  (the_x/2);\n';
}

if (is_pos_choice == 3){
left_pos = how_wide - the_x;
top_pos = 0;
the_code += 'left_pos = how_wide - the_x;\n';
the_code += 'top_pos = 0;\n';
}	
		
if (is_pos_choice == 4){
top_pos = (how_high/2) -  (the_y/2);
left_pos = 0;
the_code += 'top_pos = (how_high/2) -  (the_y/2);\n';
the_code += 'left_pos = 0;\n';
}	
		
if (is_pos_choice == 5){
top_pos = (how_high/2) -  (the_y/2);;
left_pos = (how_wide/2) -  (the_x/2);
the_code += 'top_pos = (how_high/2) -  (the_y/2);\n';
the_code += 'left_pos = (how_wide/2) -  (the_x/2);\n';
}	

if (is_pos_choice == 6){
top_pos = (how_high/2) -  (the_y/2);
left_pos = how_wide - the_x;
the_code += 'top_pos = (how_high/2) -  (the_y/2);\n';
the_code += 'left_pos = how_wide - the_x;\n';
}	

if (is_pos_choice == 7){
top_pos = how_high - the_y;
left_pos = 0;
the_code += 'top_pos = how_high - the_y;\n';
the_code += 'left_pos = 0;\n';
}

if (is_pos_choice == 8){
top_pos = how_high - the_y;
left_pos = (how_wide/2) -  (the_x/2);
the_code += 'top_pos = how_high - the_y;\n';
the_code += 'left_pos = (how_wide/2) -  (the_x/2);\n';
}


if (is_pos_choice == 9){
top_pos = how_high - the_y;
left_pos = how_wide - the_x;
the_code += 'top_pos = how_high - the_y;\n';
the_code += 'left_pos = how_wide - the_x;\n';
}






if(the_choice == 'demo' || the_choice == 'demo1'){
if (window.outerWidth ){
	var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories=" +the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",outerWidth="+the_x+",outerHeight="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
site=open(the_url, "DisplayWindow", option);
var Opera = (navigator.userAgent.indexOf('Opera') != -1);
if(Opera){
site.resizeTo(the_x,the_y);
site.moveTo(0,0);
}

}
else
{

	var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories=" +the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",Width="+the_x+",Height="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
if(!site.closed && site.location){
site.location=the_url;
site.focus();
return false;}
site=open('', "DisplayWindow", option);
site.location=the_url;

if(the_choice=='demo'){
site.resizeTo(the_x,the_y);
}
}
}




the_code += 'if (window.outerWidth ){\n';
the_code += 'var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",outerWidth="+the_x+",outerHeight="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;\n';
the_code += 'site=open(the_url, "DisplayWindow", option);\n';
the_code += 'var Opera = (navigator.userAgent.indexOf(\'Opera\') != -1);\n';
the_code += 'if(Opera){\n';
the_code += 'site.resizeTo(the_x,the_y);\n';
the_code += 'site.moveTo(0,0);\n';
the_code += '}\n';
the_code += '}\n';
the_code += 'else\n';
the_code += '{\n';
the_code += 'var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",Width="+the_x+",Height="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;\n';
the_code += 'site=open(\'\', "DisplayWindow", option);\n';
the_code += 'site.location=the_url;\n';
the_code += 'if(site.open){site.focus();return false;}\n';
the_code += 'site.resizeTo(the_x,the_y);\n';
the_code += '}\n';
the_code += '} \n';
the_code += '// --> \n';
the_code += '</script> \n';






if(the_choice == 'code'){
var finaltext="<!-- start open window code -->\n\n"+the_code+"\n\n<!-- http://www.webdevtips.com/webdevtips/codegen/openwin.shtml -->\n<!-- end open window code -->\n";
document.dothecode.codearea.value=finaltext;
return false;
}


}
function alloff(form){
form.toolbar.options.selectedIndex=1;
form.address_bar.options.selectedIndex=1;
form.directories.options.selectedIndex=1;
form.statusbar.options.selectedIndex=1;
form.menubar.options.selectedIndex=1;
form.scrollbars.options.selectedIndex=1;
form.do_resize.options.selectedIndex=1;
form.copy_history.options.selectedIndex=1;
}
function allon(form){
form.toolbar.options.selectedIndex=0;
form.address_bar.options.selectedIndex=0;
form.directories.options.selectedIndex=0;
form.statusbar.options.selectedIndex=0;
form.menubar.options.selectedIndex=0;
form.scrollbars.options.selectedIndex=0;
form.do_resize.options.selectedIndex=0;
form.copy_history.options.selectedIndex=0;
}
