var menuSlider1;
var siteMap = null;
var WIDTHSCREEN;
var HEIGHTSCREEEN;
window.onload=function(){
	MenuSlider.initialize({menuId : 'menu1', activeClass : 'activemenu1', subName : 'sub'});
	WIDTHSCREEN = document.body.clientWidth;
	HEIGHTSCREEEN = document.body.clientHeight;
}
function openWindow(href){
	var w = WIDTHSCREEN, h = HEIGHTSCREEEN;
	if (document.all) {
	}
	else if (document.layers) {
	   w = window.innerWidth;
	   h = window.innerHeight;
	}
	var popW = 640, popH = 600;
	var leftPos = (w-popW)/2;
	var topPos = (h-popH)/2;
  	siteMap = window.open(href,'Sitemap','width=640,height=600,scrollbars=yes,toolbar=no,location=yes,left='+leftPos+',top='+topPos);
	return false;
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}
function openPrintManager(url){
	window.open(url, '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=650,height=600');
}
function checkFormInput(id, len){
	var doc = document;
	if(document.getElementById(id).value.length > len){
		 document.getElementById(id).className = "text";
	}
}

function checkFormPassword(p1, p2){
	var doc = document;
	if(doc.getElementById(p1).value == doc.getElementById(p2).value){
		doc.getElementById(p1).className = "text";
		doc.getElementById(p2).className = "text";
	}
	else {
		doc.getElementById(p1).className = "error-text";
		doc.getElementById(p2).className = "error-text";
	}
}
function inArray(txt, arr){
	for(var index=0; index<arr.length; index++) {
		if(txt == arr[index]) return true;
	}
	return false;	
}
function submitForm(id){
	var doc = document;
	var excludes = new Array();
	excludes.push('username');
	excludes.push('password1');
	excludes.push('password2');
	var inputs = doc.getElementById(id).getElementsByTagName('input');
	var states = new Array();
	var doPost = true;
	for(var index=0; index<inputs.length; index++) {
		if(inputs[index].id.length > 0){
			switch(inputs[index].type){
				case 'text':
				case 'password':
					if(inputs[index].value.length == 0){
						states.push(false);
						doc.getElementById(inputs[index].id).className = "error-text";
					}
					else {
						if(! inArray(inputs[index].id, excludes)){
							doc.getElementById(inputs[index].id).className = "text";
						}
					}
					break;
			}
		}
	}
	for(var index=0; index<states.length; index++) {
		if(!states[index]) doPost = false;
	}
	if(doc.getElementById('username').className=='error-text'){
		doPost = false;	
	}
	if(doc.getElementById('password1').className=='error-text'){
		doPost = false;	
	}
	if(doc.getElementById('password2').className=='error-text'){
		doPost = false;	
	}
	if(doPost) doc.getElementById(id).submit();

}
