//news window functions
function open_print_window(thesite)
{
	window.open(thesite,"_blank","toolbar=no, location=yes, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=550, height=600");
}

function printcurrent() {
	window.print();
}

function closecurrent()
{
	window.close();
}

function emailcurrent(urlLink)
{
	window.open("emailcurrent.php?link=" + urlLink,"_blank","toolbar=no, location=yes, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=550, height=450");
}

function rfqcurrent(urlLink)
{
	window.open("rfqcurrent.php?link=" + urlLink,"_blank","toolbar=no, location=yes, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=550, height=450");
}


//Code to send AJAX requests via POST
function loadAjaxDoc(dataSent, elementToDraw, phpScriptToRun)
{
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById(elementToDraw).innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("POST", phpScriptToRun, true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.send(dataSent);
}

//Load content for products
function loadProdContent(urlLink, imageHead)
{
	$(function(){
		$("div#top img").attr({ src: imageHead });
		$(document).ajaxStart(function() 
		{
			//$.blockUI({ message: '<br /><img src="images/ajax-loader-box.gif" /> <h3>Processing...</h3>' });
			$("div#allcontent").block({ message: '<img src="images/newdownloader.gif" />', css: { border:'none',width:'40px'} });
		}).ajaxStop(function() 
		{
			//$.unblockUI();
			$("div#allcontent").unblock();
		}).ajaxError(function(a, b, e) 
		{
			throw e;
		});
		$("div#allcontent").load(urlLink);
	});
}

function ajaxload(urlLink)
{
	$(function(){
		$(document).ajaxStart(function() 
		{
			//$.blockUI({ message: '<br /><img src="images/ajax-loader-box.gif" /> <h3>Processing...</h3>' });
			$("div#allcontent").block({ message: '<img src="images/newdownloader.gif" />', css: { border:'none',width:'40px'} });
		}).ajaxStop(function() 
		{
			//$.unblockUI();
			$("div#allcontent").unblock();
		}).ajaxError(function(a, b, e) 
		{
			throw e;
		});
		$("div#allcontent").load(urlLink);
	});
}

function autoclick(wheretoclick)
{
	$(function(){
		if (!$('div#leftnav').find('a[href*="' + wheretoclick + '"]').parent().prev().hasClass("downyellowarrow"))
		{
			if (!$('div#leftnav').find('a[href*="' + wheretoclick + '"]').parent().prev().hasClass("downgreenarrow"))
			{
				$('div#leftnav').find('a[href*="' + wheretoclick + '"]').parent().prev().click();
			}
		}
		$('div#leftnav').find('a[href*="' + wheretoclick + '"]').click();		
	});
}
