<!-- Hide
// Copyright 2009 by Pawan Mall
// Email me at pawanmall@in.com


/*/-------------------------------------//
Mode Selection.
//-------------------------------------/*/

helpstat = false;
stprompt = false;
basic = true;

function thelp(swtch){
        if (swtch == 1){
                basic = false;
                stprompt = false;
                helpstat = true;
        }
        else if (swtch == 0) {
                helpstat = false;
                stprompt = false;
                basic = true;
        }
        else if (swtch == 2) {
                helpstat = false;
                basic = false;
                stprompt = true;
        }
}
/*/-------------------------------------//
Reast Function.
//-------------------------------------/*/
function treset(){
        if (helpstat){
                alert("Clears the current editor.");
        }
        else {
        clear = prompt("Are you sure? (yes/no)",'');
        clear = clear.toLowerCase();
        if(clear == 'yes') {
                document.editor.reset();
                document.editor.value = "";
        }
        }
}    

/*/-------------------------------------//
Start html function in various mode.
//-------------------------------------/*/
function start(){
        if (helpstat){
                alert("Elements that appear at the beginning of the document, including TITLE.");
        }
        else if (basic) {
        document.editor.area.value = document.editor.area.value+"<html>\n<head>\n<title></title>\n</head>\n<body>\n";
        }
        else if (stprompt) {
                for(;;){
                        twrite = prompt("Title?",'');
                        if (twrite != "" && twrite != null){
                                break;
                        }
                        else {
                                prompt("You must enter a title.",'Ok, sorry.');
                        }
                }
                document.editor.area.value = document.editor.area.value + "<html>\n<head>\n<title>" + twrite + "</title>\n</head>\n<body ";
                
                twrite = prompt("Background color? (blank if none)",'');        
                if (twrite != "" && twrite != null){
                        twrite = '"' + twrite + '"';
                        document.editor.area.value = document.editor.area.value + "bgcolor=" + twrite + " ";
                }
                
                twrite = prompt("Background image? (blank if none)",'');                
                if (twrite != "" && twrite != null){
                        twrite = '"' + twrite + '"';
                        document.editor.area.value = document.editor.area.value + "background=" + twrite + " ";
                }
                
                twrite = prompt("Text color? (blank if none)",'');
                if (twrite != "" && twrite != null){
                        twrite = '"' + twrite + '"';
                        document.editor.area.value = document.editor.area.value + "text=" + twrite + " ";
                }
                
                twrite = prompt("Link color? (blank if none)",'');              
                if (twrite != "" && twrite != null){
                        twrite = '"' + twrite + '"';
                        document.editor.area.value = document.editor.area.value + "link=" + twrite + " ";
                }
                
                twrite = prompt("Visited link color? (blank if none)",'');              
                if (twrite != "" && twrite != null){
                        twrite = '"' + twrite + '"';            
                        document.editor.area.value = document.editor.area.value + "vlink=" + twrite + " ";
                }
                
                document.editor.area.value = document.editor.area.value + ">\n";
        }
}

function end(){
        if (helpstat){
                alert("Adds the the final elements to a document.");
        }
        else {
        document.editor.area.value = document.editor.area.value + "\n</body>\n</html>\n";  
        }
}
function doSaveAs(){
	if (document.execCommand){
		document.execCommand("SaveAs")
	}
	else {
		alert("Save-feature available only in Internet Exlorer.")
	}
}
function preview(){
        if (helpstat) {
                alert("Preview/save the document.");
        }
        else {
			var close= "<a href='javascript:window.close()' style='float:right; background-color:#000000; color:#FFFFFF; display:block; text-decoration:none; font-weight:bolder;' />Close Me</a>";
			var saveAs= "<a href='javscript:void' onClick='doSaveAs()'>Save As</a>"
                temp = document.editor.area.value+close;
                preWindow= open("", "preWindow","status=yes,toolbar=yes,menubar=yes,");
                preWindow.document.open();
                preWindow.document.write(temp);
                preWindow.document.close();
        }
}
/*/-------------------------------------//
Select all code form codebox.
//-------------------------------------/*/
function selectAll(theField){
        if (helpstat){
                alert("Select all text in below text box.");
        }
        else {
        var tempval=eval("document."+theField)
        tempval.focus()
        tempval.select()
       }
}
/*/-------------------------------------//
Define HTML <!DOCTYPE> Declaration.
//-------------------------------------/*/
function DOCTYPE() {
        if (helpstat) {
                alert("Define HTML <!DOCTYPE> Declaration.");
        }
        else if (basic) {
			var db='"';
			var doctype_exmp1="<!DOCTYPE html PUBLIC "+db+"-//W3C//DTD XHTML 1.0 Transitional//EN"+db;
			var doctype_exmp2=db+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"+db+">\n";
                document.editor.area.value = document.editor.area.value + doctype_exmp1 +doctype_exmp2;
        }
        else if (stprompt) {
                twrite = prompt("Define your own HTML <!DOCTYPE> declaration.",'');
                if (twrite != null && twrite != ""){
                document.editor.area.value = document.editor.area.value+ twrite;
                }
        }
}

function DOCTYPE_exmpl1() {
        if (helpstat) {
                alert("Define HTML <!DOCTYPE> Declaration. (HTML 4.01 Strict.)");
        }
        else if (basic) {
			var db='"';
			var html_strict41 = "<!DOCTYPE HTML PUBLIC "+db+"-//W3C//DTD HTML 4.01//EN"+db+" "+db+"http://www.w3.org/TR/html4/strict.dtd"+db+">\n";
                document.editor.area.value = document.editor.area.value + html_strict41;
                }
        else if (stprompt) {
			alert("This tag in not applying in Prompt mode..");
		}
        }

function DOCTYPE_exmpl2() {
        if (helpstat) {
                alert("Define HTML <!DOCTYPE> Declaration. (HTML 4.01 Transitional)");
        }
        else if (basic) {
			var db='"';
			var html_tradnl41 = "<!DOCTYPE HTML PUBLIC "+db+"-//W3C//DTD HTML 4.01 Transitional//EN"+db+" "+db+"http://www.w3.org/TR/html4/loose.dtd"+db+">\n";
                document.editor.area.value = document.editor.area.value + html_tradnl41;
                }
		else if (stprompt) {
			alert("This tag in not applying in Prompt mode..");
		}
	
        }

function DOCTYPE_exmpl3() {
        if (helpstat) {
                alert("Define HTML <!DOCTYPE> Declaration. (HTML 4.01 Frameset.)");
        }
        else if (basic) {
			var db='"';
			var html_frame = "<!DOCTYPE HTML PUBLIC "+db+"-//W3C//DTD HTML 4.01 Frameset//EN"+db+" "+db+"http://www.w3.org/TR/html4/frameset.dtd"+db+">\n";
                document.editor.area.value = document.editor.area.value + html_frame;
                }
		else if (stprompt) {
			alert("This tag in not applying in Prompt mode..");
		}
		
        }
		
function DOCTYPE_exmpl4() {
        if (helpstat) {
                alert("Define HTML <!DOCTYPE> Declaration. (XHTML 1.0 Strict.)");
        }
        else if (basic) {
			var db='"';
			var xhtml_strict10 = "<!DOCTYPE html PUBLIC "+db+"-//W3C//DTD XHTML 1.0 Strict//EN"+db+" "+db+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"+db+">\n";
                document.editor.area.value = document.editor.area.value + xhtml_strict10;
                }
		else if (stprompt) {
			alert("This tag in not applying in Prompt mode..");
		}
		
        }	
		
function DOCTYPE_exmpl5() {
        if (helpstat) {
                alert("Define HTML <!DOCTYPE> Declaration. (XHTML 1.0 Transitional.)");
        }
        else if (basic) {
			var db='"';
			var xhtml_tradnl41 = "<!DOCTYPE html PUBLIC "+db+"-//W3C//DTD XHTML 1.0 Transitional//EN"+db+" "+db+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"+db+">\n";
                document.editor.area.value = document.editor.area.value + xhtml_tradnl41;
                }
		else if (stprompt) {
			alert("This tag in not applying in Prompt mode..");
		}
		
        }
		
function DOCTYPE_exmpl6() {
        if (helpstat) {
                alert("Define HTML <!DOCTYPE> Declaration. (XHTML 1.0 Frameset.)");
        }
        else if (basic) {
			var db='"';
			var xhtml_frame = "<!DOCTYPE html PUBLIC "+db+"-//W3C//DTD XHTML 1.0 Frameset//EN"+db+" "+db+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"+db+">\n";
                document.editor.area.value = document.editor.area.value + xhtml_frame;
                }
		else if (stprompt) {
			alert("This tag in not applying in Prompt mode..");
		}
		
        }	
	
function DOCTYPE_exmpl7() {
        if (helpstat) {
                alert("Define HTML <!DOCTYPE> Declaration. (XHTML 1.1 .)");
        }
        else if (basic) {
			var db='"';
			var xhtml1 = "<!DOCTYPE html PUBLIC "+db+"-//W3C//DTD XHTML 1.1//EN"+db+" "+db+"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"+db+">\n";
                document.editor.area.value = document.editor.area.value + xhtml1;
                }
		else if (stprompt) {
			alert("This tag in not applying in Prompt mode..");
		}
		
        }
		
		
		
/*/-------------------------------------//
<HTML> html tag start function.
//-------------------------------------/*/		
		
function html_start() {
		var db="<html>\n";
        if (helpstat) {
                alert("Applying or starting with <HTML> tag.");
        }
        else if (basic) {
                document.editor.area.value = document.editor.area.value + db;
                }
		else if (stprompt) {
			alert(db+" tag in not applying in Prompt mode..");
		}
	
        }			
/*/-------------------------------------//
CSS Function (like class, id, etc....)
//-------------------------------------/*/

function css_class() {
        if (helpstat) {
                alert("Define CSS Classes.");
        }
        else if (basic) {
			var txt=prompt("Type Your Text Class","");
                document.editor.area.value = document.editor.area.value + " class='"+txt+"' \n";
        }
        else if (stprompt) {
                twrite = prompt("Text?",'');
                if (twrite != null && twrite != ""){
                document.editor.area.value = document.editor.area.value +" class='" + twrite + "'";
                }
        }
}

function accesskey() {
        if (helpstat) {
                alert("Define CSS Classes.");
        }
        else if (basic) {
			var txt=prompt("Type Your Text Class","");
                document.editor.area.value = document.editor.area.value + " accesskey='"+txt+"' ";
        }
        else if (stprompt) {
                twrite = prompt("Text?",'');
                if (twrite != null && twrite != ""){
                document.editor.area.value = document.editor.area.value +" accesskey='" + twrite + "'";
                }
        }
}