var Ajax = false;

var testObj;
_pos_a = 286; _pos_b = 504; _pos_c = 720;
_posY = 210;
var _pos = 0;
var _opacity = 100;


version=0;
if (navigator.appVersion.indexOf("MSIE")!=-1)
{
	temp=navigator.appVersion.split("MSIE");
	version=parseFloat(temp[1])	;
}

if (version>=5.5) //NON IE browser will return 0
	{
		_pos_a = 286; _pos_b = 504; _pos_c = 720;
		_posY = 210;
		_opacity = 110;
		//alert("You're using IE5.5+");
	}

if (navigator.userAgent.indexOf("Firefox")!=-1)
{
	//alert("FIREFOX");
	var versionindex=navigator.userAgent.indexOf("Firefox")+8;
	//alert(navigator.userAgent.charAt(versionindex));
		if ((parseInt(navigator.userAgent.charAt(versionindex))>=1) && (parseInt(navigator.userAgent.charAt(versionindex))<=2))
			{
				_pos_a = 286; _pos_b = 504; _pos_c = 720;
				_posY = 205;
				_opacity = 100;
				//alert("You are using Firefox 1.x or 2.x");
			}
		else
			{
				_pos_a = 286; _pos_b = 504; _pos_c = 720;
				_posY = 205;
				_opacity = 100;
				//alert("You are using other than Firefox 1.x or 2.x");
			}
}

function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}	
	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

		
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function initForm(ObjID,ObjValue,IntPos){
	var usertype = document.getElementById('Strusertype').value;
	//alert(usertype);
	//if ((usertype == 'Admin') && (parseInt(navigator.userAgent.charAt(versionindex)) == 3))
	//{
		//alert((parseInt(navigator.userAgent.charAt(versionindex))));
		//_pos_a = 855;
		//_pos_b = 425;
		//_pos_c = -5;
	//}

	//Insert ObjValue Into ObjID
	if(IntPos == 1)
	{
		_pos = _pos_a;
	}

	if(IntPos == 2)
	{
		_pos = _pos_b;
	}
	
	if(IntPos == 3)
	{
		_pos = _pos_c;
	}


	if(ObjID != '')
	{
		document.getElementById(ObjID).value = ObjValue;
	}
	
	var pagesize = getPageSize();
	var pagescroll = getPageScroll();	
	var a = document.createElement('a');
//	var thanks = document.getElementById('formsended');
	var div = document.getElementById('contform');
//	var right = document.getElementById('rightform');
//	var left = document.getElementById('leftform');
//	right.style.display = "block";
//	left.style.display = "block";
//	thanks.style.display = "none";
	div.style.opacity = "0";
	div.style.filter = 'alpha(opacity=' + 0 + ')';
	div.style.display = "block";	
	fadeIn('contform')	
	//div.style.opacity = "1";
	//div.style.filter = 'alpha(opacity=' + 100 + ')';
	//div.style.top = (pagescroll[1] + ((pagesize[3] - 242 - parseInt(div.style.height)) / 2 +(128)) + 'px');	
	//div.style.left = (((pagesize[0] - _pos - parseInt(div.style.width)) / 2) + 'px');
	div.style.top = (_posY + 'px');	
	div.style.left = ( _pos + 'px');
	//alert(_pos);
	//alert("div.style.top= " + div.style.top);
	//alert("div.style.left= " + div.style.left);
}

function Close(){	
	fadeOut('contform');
}

var fadein=0, fadeout=_opacity, opac;
var callFunc, Value;
var callFadeout

function fadeIn(fadeObj) {
	//alert(fadeObj);	
	testObj = document.getElementById(fadeObj);
	Value=0;
	fadeout=_opacity;					
	callFunc = setInterval('setOpacity()', 50);	
}

function fadeOut(fadeObj){
	testObj = document.getElementById(fadeObj);
	Value=_opacity;					
	callFadeout = setInterval('setOpacity()', 50);
}

function setOpacity()
{		
	//alert(Value);	
	/*
	-moz-opacity:.50; Moz
	filter:alpha(opacity=50); IE
	opacity:.50;
	*/
	if(Value==0 && fadein<_opacity){		
		fadein+=10;		
		opac = fadein*0.01;
		//alert("opac= "+opac);
		//alert("fadein= "+fadein);
		if(fadein<_opacity){
			//alert("1= "+opac);
			testObj.style.opacity = opac;
			testObj.style.filter = 'alpha(opacity=' + (fadein-10) + ')';
			testObj.style.MozOpacity = opac;
		}
		else{
			clearInterval(callFunc);
			fadein=0;
		}							
	}
	else if(Value==_opacity && fadeout>0){		
			fadeout-=15;		
			opac = fadeout*0.01;
			//alert("opac= "+opac);
			//alert("fadeout= "+fadeout);
			if(fadeout>0){
				//alert("2= "+opac);
				testObj.style.opacity = opac;
				testObj.style.filter = 'alpha(opacity=' + (fadeout-10) + ')';
				testObj.style.MozOpacity = opac;
			}
			else{
				//alert(fadeout);
				clearInterval(callFadeout);
				//fadeout=100;
				testObj.style.display = "none";
			}				
		}	
	
}