var ajaxRequestUrl = 'http://www.snowstars.net/index/ajax_request.php?S=';


function ZoomPicture(PictureID, Language, Width, Height) {

	if ((Width/Height > 4/3 && Width > window.screen.availWidth - 35) || (Width/Height < 4/3 && Height > window.screen.availHeight - 150)) {

		NewWindowWidth = window.screen.availWidth - 20;

		NewWindowHeight = window.screen.availHeight - 150;

	} else {

		NewWindowWidth = Width + 50;

		NewWindowHeight = Height + 80;

	}

	NewWindowFeatures = "top=20,left=10,width="+NewWindowWidth+",height="+NewWindowHeight+",location=0,directories=0,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1";

	var PictureZoom = window.open("http://www.snowstars.net/generalpurpose/zoompicture.php?PictureID=" + PictureID + "&Language=" + Language, "PictureZoom", NewWindowFeatures);

	PictureZoom.focus();
}

function SwapImage(ImageName, ImageFileName) {

	document.images[ImageName].src = ImageFileName;

}

function OpenURLInNewWindow(URL) {

	if (URL) {

		NewWindowWidth = (window.screen.availWidth - 20);
		NewWindowHeight = (window.screen.availHeight - 150);

		NewWindowFeatures = "top=20,left=10,width="+NewWindowWidth+",height="+NewWindowHeight+",location=1,directories=0,menubar=1,toolbar=1,status=1,scrollbars=1,resizable=1";

		var NewWindow = window.open("http://www.snowstars.net/index/referer.php?URL="+URL+"&S=", "PreviewWindow", NewWindowFeatures);

		NewWindow.focus();
	}
}

function OpenURLInNewWindowSized(URL, NewWindowWidth, NewWindowHeight) {

	if (URL) {

		//NewWindowWidth = (window.screen.availWidth - 20);
		//NewWindowHeight = (window.screen.availHeight - 150);

		NewWindowFeatures = "top=20,left=10,width="+NewWindowWidth+",height="+NewWindowHeight+",location=1,directories=0,menubar=1,toolbar=1,status=1,scrollbars=1,resizable=1";

		var NewWindow = window.open("http://www.snowstars.net/index/referer.php?URL="+URL+"&S=", "PreviewWindow", NewWindowFeatures);

		NewWindow.focus();
	}
}

function RoundToDecimal(ValueToRound, NoOfDecimal) {

	ValueToRound = Math.round(ValueToRound*Math.pow(10,2))/Math.pow(10,2);
	ValueToRoundString = "" + ValueToRound;
	CommaPos = ValueToRoundString.length - ValueToRoundString.indexOf(".");
	if (CommaPos == 2) {
		ValueToRoundString += "0";
	} else {
		if (CommaPos == ValueToRoundString.length + 1) {
			ValueToRoundString += ".00";
		}
	}
	return ValueToRoundString;
}

function changeBox(box) { 
//	eval(box + '.checked = true');
//	return false;
	if(box.checked) {
		box.checked = false;
	} else {
		box.checked = true;
	}
}

var marked_row = new Array;

function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;

    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 5. Sets the new color...
	newColor = thePointerColor;
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
                theCells[c].style.backgroundColor = newColor;
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function

// resizes Iframe according to content
function resizeMe(obj){ 
   docHeight = iframe.document.body.scrollHeight;
   obj.style.height = docHeight + 'px'
} 

