//function GetURL(strURL) {
//	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
//	xmlhttp.open("GET", strURL, false);
//	xmlhttp.send("");
//	return xmlhttp.responseText;
//} 

function GetURL(strURL) {
	var browser_name = navigator.appName;
	var xmlhttp;
	
	if (browser_name == "Microsoft Internet Explorer")
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	else
		xmlhttp = new XMLHttpRequest();
	
	xmlhttp.open("GET", strURL, false);
	xmlhttp.send("");
	
	return xmlhttp.responseText;
}

function openModalDialog(url, width, height) {
	return showModalDialog(url, "", "dialogWidth:"+width+"px;dialogHeight:"+height+"px;help:no;status:no;scroll:no;");
}

function buildSelect(oSelect, oRecords)
{
	var oItem, oItem
	var aRemove = Array() // Array of item-indexes to be removed
	var iSelectID = oSelect.value
	var iLength = oSelect.length
	
	oSelect.style.display = "none"
	for (i=0; i < iLength; i++)
	{
		oSelect.remove(0)
	}
	for (i=0; i < oRecords.length; i++)
	{
		oItem = document.createElement("OPTION")
		oItem.text = oRecords[i].name
		oItem.value = oRecords[i].id
		oItem.selected = (oRecords[i].id == iSelectID)

		oSelect.add(oItem)
	}
	
	oSelect.style.display = ""
}

function GetCheckboxCSV(objCheckbox) {
	var strOut = "";
	
	for (i=0; i < objCheckbox.length; i++)
	{
		if (objCheckbox(i).checked) {
			if (strOut != "") strOut += ","
			strOut += objCheckbox(i).value;
		}
	}
	return strOut;
}

function CopyOptions(objSource, objTarget) {
	var objItem
	
	for (i=0; i < objSource.length; i++)
	{
		objItem = document.createElement("OPTION")
		objItem.text = objSource.item(i).text
		objItem.value = objSource.item(i).value

		//objTarget.options.add(objItem)
		objTarget.options[objTarget.options.length] = objItem //Safari
	}
}

function dbRecord(iID, sName, bIsCompany)
{
	this.id = iID
	this.name = sName
	this.isCompany = bIsCompany
}

function addItem(iID, sName, bIsCompany)
{
	var newItem = new dbRecord(iID,sName,bIsCompany)
	this.length += 1;
	this[(this.length-1)] = newItem;
}

function recordList()
{
	this.length = 0
	this.addItem = addItem
}

function OptionCSV(objSelect) {
	var strTemp = "";
	
	for (i=0; i < objSelect.length; i++) {
		if (!(strTemp == "")) strTemp += ",";
		strTemp += objSelect.item(i).value
	}
	return strTemp;
}

function moveOptions(oSource, oTarget) {
//	alert(navigator.userAgent.indexOf('Safari'));

	if (navigator.userAgent.indexOf('Safari') == -1) {
		var oSourceItem, oTargetItem;
		var aRemove = Array(); // Array of item-indexes to be removed
		var iCount = 0; // Item-count
		var iNewIndex;
		for (i=0; i < oSource.length; i++) {
			if (oSource.item(i).selected) {
				iCount++;
				aRemove[iCount] = i;
				oSourceItem = oSource.item(i);
				oTargetItem = document.createElement("OPTION");
				oTargetItem.text = oSourceItem.text;
				oTargetItem.value = oSourceItem.value;
				iNewIndex = oTarget.length;
			
				// Find correct target position (sort)
				for (j=0; j < oTarget.length; j++) {
					if (oSource.item(i).text < oTarget.item(j).text) {
						iNewIndex = j;
						break;
					}
				}
				oTarget.options.add(oTargetItem, iNewIndex);
			}
		}
	
		// Remove selected items
		for (i=1; i <= iCount; i++) {
			oSource.remove(aRemove[i]-(i-1));
		}
	}
	else {
		//MacOS - Safari
		moveOptionsMac(oSource, oTarget);
	}

}

function moveOptionsMac(oSource, oTarget) {
	var oSourceItem, oTargetItem;
	var aRemove = Array(); // Array of item-indexes to be removed
	var iCount = 0; // Item-count
	var iNewIndex;

	for (i=0; i < oSource.length; i++) {
		if (oSource.options(i).selected == true) {
			iCount++;
			aRemove[iCount] = i;
			oSourceItem = oSource.options(i);
			oTargetItem = document.createElement("OPTION");
			oTargetItem.text = oSourceItem.text;
			oTargetItem.value = oSourceItem.value;
			iNewIndex = oTarget.length;

			// Find correct target position (sort)
			for (j=0; j < oTarget.length; j++) {
				if (oSource.options(i).text < oTarget.options(j).text) {
					iNewIndex = j;
					break;
				}
			}

			//Safari does not support .add(oTargetItem, iNewIndex) ;(..
			if (oTarget.options.length == 0 || oTarget.options.length == iNewIndex) {
				oTarget.options[oTarget.options.length] = oTargetItem;
			}
			else { 
				var aNew = Array();
		
				for (k=0; k<iNewIndex; k++) {
					oNewItem = document.createElement("OPTION");
					oNewItem.text = oTarget.options[k].text;
					oNewItem.value = oTarget.options[k].value;
					aNew[k] = oNewItem;
				}

				aNew[iNewIndex] = oTargetItem;

				for (k=iNewIndex; k<oTarget.options.length; k++) {
					oNewItem = document.createElement("OPTION");
					oNewItem.text = oTarget.options[k].text;
					oNewItem.value = oTarget.options[k].value;
				
					aNew[k+1] = oNewItem;
				}
		
					oTarget.options.remote;
					for (k=0; k < aNew.length; k++) {
					oTarget.options[k] = aNew[k];
				}
			}
		}
	}


	// Remove selected items

	for (i=1; i <= iCount; i++) {
		oSource.remove(aRemove[i]-(i-1));
	}

}

function selectAllOptions(oSelect) {
	for (i=0; i < oSelect.length; i++) {
		oSelect.item(i).selected = true
	}
}

function SelectFromValue(objSelect, varValue) {
	for (i=0; i < objSelect.length; i++) {
		if (objSelect.item(i).value == varValue) {
			objSelect.item(i).selected = true;
			break;
		}
	}
}

function over(obj) {
	obj.style.background='#eeeeee';
}

function out(obj) {
	obj.style.background='#ffffff';
}

function sure() {
	return confirm('Are you sure?');
}

// Open dialog and return value when closed - OLD!!!
//function openDialog(url, width, height) {
//	return showModalDialog("/modaldialog.asp?"+url, "", "dialogWidth:"+width+"px;dialogHeight:"+height+"px;help:no;status:no;scroll:yes;");
//}

// Open dialog and return value when closed
function openDialog(url, width, height) {
	var browser_name = navigator.appName;
	if (browser_name == "Microsoft Internet Explorer" )
	{
		return showModalDialog("/modaldialog.asp?"+url, "", "dialogWidth:"+width+"px;dialogHeight:"+height+"px;help:no;status:no;scroll:yes;");
		return showModalDialog("/modaldialog.asp?"+url, "", "dialogWidth:"+width+"px;dialogHeight:"+height+"px;help:no;status:no;scroll:yes;");
	}
	else
	{
		//FireFox etc.
		var left = parseInt((screen.availWidth/2) - (width/2));
		var top = parseInt((screen.availHeight/2) - (height/2));

		return window.open("/modaldialog.asp?"+url, "", "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + ",screenX=" + left + ",screenY=" + top + "modal=yes");
	}
}


// Return value and close window
function setReturnValue(returnValue) {
	parent.window.returnValue=returnValue
}

// Return value and close window
function doReturn(returnValue) {
	parent.window.returnValue=returnValue
	parent.window.close()
}


// Cancel and close window
function doCancel() {
	parent.window.close()
}

function setHomePage() {
  var url="http://www.languagewire.com/";
  // Internet Explorer 5
  if (document.all && document.getElementById) {
    oHomePage.setHomePage(url);
//    this.setHomePage(url);
  }
  // Netscape Navigator
  else if(document.layers&&navigator.javaEnabled()) {
    netscape.security.PrivilegeManager.enablePrivilege('UniversalPreferencesWrite');
    navigator.preference('browser.startup.homepage',url);
  }
}

function over(obj) {
	obj.style.background='#eeeeee';
}

function out(obj) {
	obj.style.background='#ffffff';
}

/********************************************************************************
Copyright (C) 1999 Thomas Brattli
This script is made by and copyrighted to Thomas Brattli at www.bratta.com
Visit for more great scripts. This may be used freely as long as this msg is intact!
I will also appriciate any links you could give me.
********************************************************************************/
//Default browsercheck, added to all scripts!
function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}
bw=new checkBrowser()
/********************************************************************************
Remeber to set the look of the divBottom layer in the stylesheet (if you wan't
another font or something)
********************************************************************************/

/*Set these values, gright for how much from the right you wan't the layer to go
and gbottom for how much from the bottom you want it*/
var gright=220
var gbottom=110


/********************************************************************************
Constructing the ChangeText object
********************************************************************************/
function makeObj(obj,nest){
	nest=(!nest) ? '':'document.'+nest+'.'										
   	this.css=bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+"document.layers." +obj):0;			
	this.moveIt=b_moveIt;
}
function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x; this.css.top=this.y}

/********************************************************************************
Initilizing the page, getting height and width to moveto and calls the 
object constructor
********************************************************************************/
function geoInit(){
	oGeo=new makeObj('divBottom')
	pageWidth=(bw.ie4 || bw.ie5)?document.body.offsetWidth-4:innerWidth;
	pageHeight=(bw.ie4 || bw.ie5)?document.body.offsetHeight-2:innerHeight;
	checkIt()
	//sets the resize handler.
	onresize=resized
	if(bw.ie4 || bw.ie5) window.onscroll=checkIt;
	//shows the div
	oGeo.css.visibility='visible'
}
/********************************************************************************
This function executes onscroll in ie and every 30 millisecond in ns
and checks if the user have scrolled, and if it has it moves the layer.
********************************************************************************/
function checkIt(){
	if(bw.ie4 || bw.ie5) oGeo.moveIt(document.body.scrollLeft +pageWidth-gright,document.body.scrollTop+pageHeight-gbottom)
	else if(bw.ns4){
		oGeo.moveIt(window.pageXOffset+pageWidth-gright, window.pageYOffset+pageHeight-gbottom)
		setTimeout('checkIt()',30)
	}
}
//Adds a onresize event handler to handle the resizing of the window.
function resized(){
	pageWidth=(bw.ie4 || bw.ie5)?document.body.offsetWidth-4:innerWidth;
	pageHeight=(bw.ie4 || bw.ie5)?document.body.offsetHeight-2:innerHeight;
	if(bw.ie4 || bw.ie5) checkIt()
}






function showdiv(divid){
	document.getElementById(divid).style.display='block';
	//document.all[divid].style.display='';
	//document.all[divid].style.overflow='visible';
}

function hidediv(divid){
	document.getElementById(divid).style.display='none';
	//document.all[divid].style.display='none';
	//document.all[divid].style.overflow='hidden';
}


function getstate(divid){
	if (GetCookie(divid) == 'visible'){
		SetCookie(divid, 'visible');
		document.all[divid].style.visibility='visible';
		document.all[divid].style.overflow='visible'}
	else{
		SetCookie(divid, 'hidden');
		document.all[divid].style.visibility='hidden';
		document.all[divid].style.overflow='hidden'}
}

function showhide(divid){
	//alert(document.all[divid].style.overflow);
	if (document.all[divid].style.visibility=='hidden'){
		SetCookie(divid, 'visible')
		document.all[divid].style.visibility='visible';
		document.all[divid].style.overflow='visible'}
	else{
		SetCookie(divid, 'hidden')
		document.all[divid].style.visibility='hidden';
		document.all[divid].style.overflow='hidden'}
}

var expDays = 30;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function getCookieVal (offset) {  
var endstr = document.cookie.indexOf (";", offset);  
if (endstr == -1)    
endstr = document.cookie.length;  
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {  
var arg = name + "=";  
var alen = arg.length;  
var clen = document.cookie.length;  
var i = 0;  
while (i < clen) {    
var j = i + alen;    
if (document.cookie.substring(i, j) == arg)      
return getCookieVal (j);    
i = document.cookie.indexOf(" ", i) + 1;    
if (i == 0) break;   
}  
return null;
}
function SetCookie (name, value) {  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (argc > 2) ? argv[2] : null;  
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure = (argc > 5) ? argv[5] : false;  
document.cookie = name + "=" + escape (value) + 
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
((path == null) ? "" : ("; path=" + path)) +  
((domain == null) ? "" : ("; domain=" + domain)) +    
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {  
var exp = new Date();  
exp.setTime (exp.getTime() - 1);  
var cval = GetCookie (name);  
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function checknumber(input) {
	var str = input.value;
	if (str == '') return false;
	for (var i = 0; i < str.length; i++) {
		var ch = str.substring(i, i + 1)
		if ((ch < "0" || "9" < ch) && ch != '.') {
			return false;
		}
	}
	return true;
}

function help(keyword) {
	popup('/help.asp?mode='+keyword, 'help', 400, 300, 'yes');
}

function popImage(imageId) {
	popup("/popupimage.asp?id="+imageId, "popup", 50, 50, 0)
}

function popup(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

