
function Config()
{
	this.spacerPath = '../images/spacer.gif';
	// this.galleryPath = '../script_upload/gallery/';
}

config = new Config();


function action_check(str, rep)
{
	var b = confirm(str);
	if(rep == 'yes')
	{
		if(b)
		{
			location.href = this.href;
		}
	}
	return b;
}
/*
function transparent2(element)
{
	if(/MSIE (5\.5|6).+Win/.test(navigator.userAgent)) 
	{
		var src = element.src;
		element.src = config.spacerPath; 
		if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
	}
}
*/
function transparent(element)
{
	if(/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
	{
		var src = element.src;
		if(/\.png$/.test(element.src))
		{ 
			element.src = config.spacerPath;
			if (src)
			{
				element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
			}
		}   
	}
}

function ajaxSubmit(container, formname, submitOnFailure)
{
	showLoader();
	
	var ajax = new Ajax.Updater(container, "getReport.php", // shortReport.php
	{
		method: 'post',
		parameters: Form.serialize(formname),
		evalScripts: true,
		
		onException: function()
		{
			hideLoader();
			if(submitOnFailure)
			{
				document.forms[formname].submit();
			}
			else
			{
				alert('Failed to perform request. Check if ajax is supported');
			}
		},
		onSuccess: function()
		{
			hideLoader();
		}
	}
	);
}

function hideLoader()
{
	document.getElementById('short_loader').style.display = 'none';
	
	document.getElementById('submit_report').disabled = false;
	
	try
	{
		document.getElementById('carfax_loader').style.display = 'none';
		document.getElementById('submit_carfax').disabled = false;
	}
	catch(e){}
	
	try
	{
		document.getElementById('autocheck_loader').style.display = 'none';
		document.getElementById('submit_autocheck').disabled = false;
	}
	catch(e){}
}

function showLoader()
{
	// var cdiv = new centerdiv('loader');
	// cdiv.move();
	
	// document.getElementById('short_loader').style.display = 'block';
	
	document.getElementById('submit_report').disabled = true;
	
	try
	{
		// document.getElementById('carfax_loader').style.display = 'block';
		document.getElementById('submit_carfax').disabled = true;
	}
	catch(e){}
	
	try
	{
		// document.getElementById('autocheck_loader').style.display = 'block';
		document.getElementById('submit_autocheck').disabled = true;
	}
	catch(e){}
}

/*
function GetReport()
{
	ajaxSubmit("center_div", "short_report", true);
}
*/

function GetReport(form_name, loader_id)
{
	document.getElementById(loader_id).style.display = 'block';
	
	ajaxSubmit("center_div", form_name, true);
}

/*
	function showPic(pic, width, height)
	{ 
		sDesrc = "width=" + width + ", height=" + height + ", status=no, toolbar=no, menubar=no, scrollbars=no";
		win = window.open("galleryImage.php?pic=" + pic, "", sDesrc);
	}

	function showDetailPic(pic, type, width, height)
	{ 
		sDesrc = "width=" + width + ", height=" + height + ", status=no, toolbar=no, menubar=no, scrollbars=no";
		win = window.open("DetailImage.php?pic=" + pic + "&type=" + type, "", sDesrc);
	}

	function showVideo(video_id, width, height)
	{ 
		sDesrc = "width=" + width + ", height=" + height + ", status=no, toolbar=no, menubar=no, scrollbars=no";
		win = window.open("video.php?video_id=" + video_id + "&width=" + width + "&height=" + height, "", sDesrc);
	}

	var send = function(link, mData, catData) // typeData, catData, colorData
	{
		var dataToSend = document.getElementById('calendar_y').value + "." 
						 + document.getElementById('calendar_m').value;
		var typeData = document.getElementById('calendar_type').value;
		var ajax = new httpAjaxRequest(); 
		if(ajax)
		{  
			ajax.prepareHash({date:dataToSend, m:mData, calendar_type:typeData, cat_id:catData});
			// , calendar_type:typeData , cat_id:catData, color:colorData
			ajax.open("GET", "ajax.php");
			ajax.send();
			ajax.getData();
			ajax.onreadystatechange = function()
			{ 
				data = ajax.getResult();
				document.getElementById("calendar_div").innerHTML = data.calendar; 
			}  
		}
	 	else
	 	{
	 		window.location = link + document.getElementById('calendar_y').value + "." + document.getElementById('calendar_m').value;
	 	}
	}

	function writeCookie(cookieName, cookieContent, cookieExpireTime)
	{
		var cookiePath = '/';
		if(cookieExpireTime > 0)
		{
			var expDate = new Date()
			expDate.setTime(expDate.getTime()+cookieExpireTime*1000*60*60)
			var expires = expDate.toGMTString()
			document.cookie = cookieName + "=" + escape(cookieContent) + ";path=" + escape(cookiePath) + ";expires=" + expires + ";";
		}
	    else
	    {
			document.cookie = cookieName + "=" + escape(cookieContent) + ";path=" + escape(cookiePath) + ";";
		}
	}

	function readCookie(cookieName)
	{
		var ourCookie = document.cookie;
		if(!ourCookie || ourCookie == "")
		{
			return "";
		}
		ourCookie = ourCookie.split(";")
		var i = 0;
		var Cookie;
		while(i < ourCookie.length)
		{
			Cookie = ourCookie[i].split("=")[0];
			if(Cookie.charAt(0) == " ")
			{
				Cookie = Cookie.substring(1);
			}
			if(Cookie == cookieName)
			{
				return unescape(ourCookie[i].split("=")[1]);
			}
			i++;
		}
		return "";
	}

	function deleteCookie(cookieName)
	{
		var cookiePath = '/';
		document.cookie = cookieName + "=" + readCookie(cookieName) + ";path=" + escape(cookiePath) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT;";
	}

	function sendToFriend(id, year, width, height)
	{ 
		sDesrc = "width=" + width + ", height=" + height +
			", status=no, toolbar=no, menubar=no, scrollbars=no";
		win    = window.open("sendfriend.php?sendid=" + id + "&year=" + year, "", sDesrc);
	}

	function SaveGeo()
	{
		deleteCookie("geo");
		if(document.getElementById('geo').checked)
		{
			writeCookie('geo',"1", 77777);
		}
		else
		{
			writeCookie('geo',"0", 77777);
		}
	}
*/
