﻿// w3Tamil99 Widget - Format 1.0
var w3TamilBaseURL = 'http://wk.w3tamil.com/code'; //'code';
var w3TamilFilesAdded='';//For the use of Dynamic insertion of Javascript & CSS files
loadW3TamilWidgetLibraries(); //Load dynamically necessary CSS files
var W3Tamil99ImgKeysCounter = 0; //To store the value that how many times the popup window has been opened

<!--
document.writeln('<'+'scr'+'ipt type="text/javascript" '+'src="'+w3TamilBaseURL+'/w3tamil_wk/w3tamil_wk_includes/js/w3tamil_wk_library.js"><'+'/'+'scr'+'ipt>');
document.writeln('<'+'scr'+'ipt type="text/javascript" '+'src="'+w3TamilBaseURL+'/w3tamil_wk/w3tamil_wk_includes/js/w3tamil_wk_mappings.js"><'+'/'+'scr'+'ipt>');
document.writeln('<'+'scr'+'ipt type="text/javascript" '+'src="'+w3TamilBaseURL+'/w3tamil_rp/w3tamil_rp_includes/js/w3tamil_rp_library.js"><'+'/'+'scr'+'ipt>');
//-->

function loadW3TamilJsCssFile(filename, filetype){
	//This function written based on the tutorial available at http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml
	if (w3TamilFilesAdded.indexOf("["+filename+"]")==-1){
		if (filetype=="js"){ //if filename is a external JavaScript file
			var fileref=document.createElement('script');
			fileref.setAttribute("type","text/javascript");
			fileref.setAttribute("src", filename);
		}
		else if (filetype=="css"){ //if filename is an external CSS file
			var fileref=document.createElement("link");
			fileref.setAttribute("rel", "stylesheet");
			fileref.setAttribute("type", "text/css");
			fileref.setAttribute("href", filename);
		}
		if (typeof fileref!="undefined")
			document.getElementsByTagName("head")[0].appendChild(fileref);
		w3TamilFilesAdded+="["+filename+"]"; //List of files added in the form "[filename1],[filename2],etc"
	}
	else{
	alert("already");//Already added; Nothing to do
	}
}
function loadW3TamilWidgetLibraries(){
	//loadW3TamilJsCssFile(w3TamilBaseURL+"/w3tamil_wk/w3tamil_wk_includes/js/w3tamil_wk_library.js", "js");
	//loadW3TamilJsCssFile(w3TamilBaseURL+"/w3tamil_wk/w3tamil_wk_includes/js/w3tamil_wk_mappings.js", "js");
	//loadW3TamilJsCssFile(w3TamilBaseURL+"/w3tamil_rp/w3tamil_rp_includes/js/w3tamil_rp_library.js", "js");
	loadW3TamilJsCssFile(w3TamilBaseURL+"/w3tamil_wk/w3tamil_wk_includes/css/w3tamil_wk_style.css", "css");
	loadW3TamilJsCssFile(w3TamilBaseURL+"/w3tamil_rp/w3tamil_rp_includes/css/w3tamil_rp_style.css", "css");
}

function GetAbsWindowBottom()
{
	// Compute the bottom of the popup window and the bottom of
	// the browser window, in absolute co-ordinates - different
	// on all browsers but the below should be accurate usually!
	//http://www.onlamp.com/pub/a/onlamp/2007/07/05/writing-advanced-javascript.html
	var abswindowbottom = 0;
	if (typeof(window.innerHeight) == 'number')
		abswindowbottom = window.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight)
		abswindowbottom = document.documentElement.clientHeight;
	else if (document.body && document.body.clientHeight)
		abswindowbottom = document.body.clientHeight;
	
	if (typeof(window.pageYOffset) == 'number')
		abswindowbottom = abswindowbottom + window.pageYOffset;
	else if (document.body && document.body.scrollTop)
		abswindowbottom = abswindowbottom + document.body.scrollTop;
	else if (document.documentElement && document.documentElement.scrollTop)
		abswindowbottom = abswindowbottom + document.documentElement.scrollTop;
	return abswindowbottom;
}
function GetAbsWindowTop()
{
	// Compute the top of the popup window and the top of
	// the browser window, in absolute co-ordinates - different
	// on all browsers but the below should be accurate usually!
	var abswindowtop = 0;
		if (typeof(window.pageYOffset) == 'number')
	abswindowtop = window.pageYOffset;
		else if (document.body && document.body.scrollTop)
	abswindowtop = document.body.scrollTop;
		else if (document.documentElement && document.documentElement.scrollTop)
	abswindowtop = document.documentElement.scrollTop;
		return abswindowtop;
}
function showW3Tamil99ImgKeysOutputText_widget_1(w3t){
	return w3t.showW3Tamil99ImgKeysOutputText();
}
function showW3Tamil99ImgKeysPopUp(w3t, fw){//fw - Resizing panel instance 
	W3Tamil99ImgKeysCounter++;
	if(W3Tamil99ImgKeysCounter==1)
	fw.createPanel(false,635,420,5,(GetAbsWindowTop()+5),'w3Tamil99 Keyboard',w3TamilBaseURL+'/w3tamil_widget/w3tamil_widget_includes/images/w3tamil_favicon_2009.gif',showW3Tamil99ImgKeysOutputText_widget_1(w3t));//window.screenLeft,window.screenTop+500);//document.body.scrollLeft,document.body.scrollTop);//window.pageXOffset, window.pageYOffset);//findPosX(window),findPosY(window));
	else alert('Already you opened a Web Tamil99 Keyboard Window');
	//alert('Web Tamil99 Keyboard has displayed top left corner of this page.\n~-~-~Powered by: w3Tamil.com~-~-~');
	//Give alert when avoid return false when calling thisfucntion
	return false;
}
function createW3Tamil99widget_1()
{	//w3TamilBaseURL = 'code'; 
	w3Tamil99 = new W3Tamil99("w3Tamil99", (w3TamilBaseURL+"/w3tamil_wk/") ,"w3Tamil_editor"); //"code/w3tamil_wk/"
	//w3Tamil99.setw3TamilBaseURL('code/w3tamil_wk/');
	w3tRp = new W3TamilResizablePanel('w3tRp', (w3TamilBaseURL+"/w3tamil_rp/")); //'code/w3tamil_rp/'
}
function showW3Tamil99widget_1()
{
	showW3Tamil99ImgKeysPopUp(w3Tamil99, w3tRp);
	//w3Tamil99.showW3Tamil99ImgKeys();
}
function showW3Tamil99widget_1_label_1()
{//w3TamilBaseURL = 'code'; 
	var tempt;
	tempt = '<div style="width:120px;border: 1px outset #efefef;text-align: center;font-family: Verdana, Latha, Arial, Helvetica, sans-serif;font-size: 10px;background-color: #fff;font-weight: bold;color:#000;">';
	tempt = tempt + '	<img src="'+w3TamilBaseURL+'/w3tamil_widget/w3tamil_widget_includes/images/w3TamilWK_banner_w120xh44.gif" width="120" height="44" alt="Web Tamil99 Keyboard" title="w3தமிழ்99 விசைப்பலகை " />';
	tempt = tempt + '	<a href="#" onclick="showW3Tamil99widget_1();return false" title="Open in a POPUP Window"><img src="'+w3TamilBaseURL+'/w3tamil_widget/w3tamil_widget_includes/images/w3tamilwkPopupWindow.gif" alt="Open in a POPUP Window" width="56" height="16" border="0"  /></a> ';
	tempt = tempt + '	<a href="'+w3TamilBaseURL+'/w3tamil_wk/index.html" target="_blank" title="Open in a NEW Window"><img src="'+w3TamilBaseURL+'/w3tamil_widget/w3tamil_widget_includes/images/w3tamilwkNewWindow.gif" alt="Open in a NEW Window" width="56" height="16" border="0"  /></a>';
	tempt = tempt + '	<span title="Tamil99 Keyboard">தமிழ்99<br />விசைப்பலகை</span>';
	tempt = tempt + '</div>';
	document.writeln(tempt);
}