// JavaScript Document
function showDialogPartNumberSearch()
{
	// alert(document.getElementById("DialogPartNumberFrame").innerHTML);
	$.fancybox(
	{	
		'content'	: document.getElementById("DialogPartNumberFrame").innerHTML,
		'modal' 	: true,
		'titleShow'	: false,
		'padding'		 : 0,
		'overlayOpacity' : 0.6,
		'overlayColor'	 : '#000',
		'centerOnScroll' : true
	});
	
	//document.getElementById("DialogPartNumberFrame").click();
}

function openAvailabilityBox( strId, strHref )
{
	if( strId == "" )
	{
		return;
	}

	$( "#" + strId ).fancybox(
	{	
		'content': document.getElementById( strHref ).innerHTML,
		'modal' 	: true,
		'titleShow': false,
		'padding'		 : 0,
		'overlayOpacity' : 0.6,
		'overlayColor'	 : '#000',
		'centerOnScroll' : true
	});

	$( "#" + strId ).click();
}	

function showDialog( strTitle, strText )
{	
	document.getElementById("DialogBoxTitle").innerHTML = "<img src=\"images/layout/warning.png\" align=\"absmiddle\" />&nbsp;" + strTitle;
	document.getElementById("DialogBoxText").innerHTML = strText;

	$.fancybox(
	{	
		'content'	: document.getElementById("DialogBoxFrame").innerHTML,
		'modal' 	: true,
		'titleShow'	: false,
		'padding'		 : 0,
		'overlayOpacity' : 0.6,
		'overlayColor'	 : '#000',
		'centerOnScroll' : true
	});
}


function paypalurl(){
          document.getElementById("order_form").action = "https://www.paypal.com/cgi-bin/webscr";
                  }


function openHsnTsnWnd( strId )
{	
	if( strId == "" )
	{
		return;
	}
	
	$( "#" + strId ).fancybox(
	{	
		'content': document.getElementById("HsnTsnBoxFrame").innerHTML,
		'modal' 	: true,
		'titleShow': false,
		'padding'		 : 0,
		'overlayOpacity' : 0.6,
		'overlayColor'	 : '#000',
		'centerOnScroll' : true
	});

	$( "#" + strId ).click();	
}

var strHoverRPId = "";

function toggleHoverBoxPR( iId, iPosIndex )
{	
	objElement = document.getElementById( iId + "_product" );
	if( objElement == null )
	{
		return;
	}

	objHover = document.getElementById( iId + "_hover" );
	if( objHover == null )
	{	
		return;
	}
		
	if( objHover.style.display == "block" )
	{
		if( strHoverRPId == "" )
		{
			objHover.style.display = "none";
			strHoverPRId = "";
		} else {
			
		}
	} else {
		if( iId != "" )
		{
			if( strHoverRPId != iId )
			{						
				objElementTmp = document.getElementById( strHoverRPId + "_hover" );
				if( objElementTmp != null )
				{
					objElementTmp.style.display = "none";
				}
			}
		} else {
			objElementTmp = document.getElementById( strHoverRPId + "_hover" );
			if( objElementTmp != null )
			{
				objElementTmp.style.display = "none";				
			}
		}
				
		objHover.style.display = "block";
		objPoint = getPosition( iId + "_product" );
				
		if( iPosIndex == 0 )
		{	
			// objHover.style.left = ( objPoint.x - (objHover.offsetWidth) ) - 135 + "px";			
			objHover.style.top = 0; //(objElement.offsetTop + 31) + "px";
			// objHover.style.left = -(objHover.offsetWidth-5);// ( objPoint.x - (objHover.offsetWidth) ) - 135 + "px";						
			objHover.style.left = -(objHover.offsetWidth-5) + "px";
		} else {
			if( iPosIndex == 1 )
			{
				// set x
				// alert( objPoint.x +" - "+ leftPosition() );
				//objHover.style.left = (objPoint.x - (pageWidth()+leftPosition()) ) + "px";				
				// set y
				// objHover.style.top = (objPoint.y + (objHover.offsetHeight-10) ) + "px";
				//alert(objElement.offsetTop);
				//objHover.style.top = "500px";//(objElement.offsetTop) + "px";
			}			
		}
			
		strHoverRPId = iId;
	}
}


function scrollProductBox( iRelatedId, iWidth, bRight )
{
	if( iRelatedId == "" )
	{
		return;
	}
	
	if( iWidth == "" )
	{
		return;
	}	
	
	objRelatedProductTable = document.getElementById( "related_products_table_" + iRelatedId );
	if( objRelatedProductTable != null )
	{
		iRelatedProductTablePos = objRelatedProductTable.style.left;
		iRelatedProductTablePos = iRelatedProductTablePos.replace(/px/g, "");
		if( bRight == true )
		{	
			if( iRelatedProductTablePos != "" )
			{
				iRelatedProductTablePos = parseInt(iRelatedProductTablePos) + 160;
			} else {
				iRelatedProductTablePos = 160;
			}
			
			if( iRelatedProductTablePos > 0 )
			{
				return;
			}																
		} else {
			if( iRelatedProductTablePos != "" )
			{
				iRelatedProductTablePos = parseInt(iRelatedProductTablePos) - 160;
			} else {
				iRelatedProductTablePos = -160;
			}
			

			if( Math.abs(iRelatedProductTablePos) > (iWidth-640) )
			{
				return;
			}

		}
		$("#" + "related_products_table_" + iRelatedId ).animate({"left": iRelatedProductTablePos + "px"}, "slow");
	}
}
													
function focusPartNumber()
{
	objPartNumberSearch = document.getElementById("part_number_search");					
	objPartNumberSearch.value = ''; 
	objPartNumberSearch.style.border = "1px solid #000"; 
	objPartNumberSearch.style.color = "#008337";
}

function focusHsnTsnSearch( strCurrentSel )
{
	objElement = null;
	if( strCurrentSel == "HSN" )
	{
		objElement = document.getElementById("HSN");						
	} else {
		objElement = document.getElementById("TSN");
	}
	
	if( objElement != null )
	{
		objElement.value = ""; 
		objElement.style.border = "1px solid #008337";
		objElement.style.color = "#000";					
	}
}

var strHoverId = "";

function toggleHoverBox( iId, iPosIndex )
{	
	objElement = document.getElementById( iId + "_product" );
	if( objElement == null )
	{
		return;
	}
	
	objHover = document.getElementById( iId + "_hover" );
	if( objHover == null )
	{	
		return;
	}
	
	if( objHover.style.display == "block" )
	{
		if( strHoverId == "" )
		{
			objHover.style.display = "none";
			strHoverId = "";			
		} else {
			
		}
	} else {
		if( iId != "" )
		{
			if( strHoverId != iId )
			{
				objElementTmp = document.getElementById( strHoverId + "_hover" );
				if( objElementTmp != null )
				{	
					objElementTmp.style.display = "none";
				}
			}
		} else {
			objElementTmp = document.getElementById( strHoverId + "_hover" );
			if( objElementTmp != null )
			{
				objElementTmp.style.display = "none";
			}
		}
						
		objPoint = getPosition( iId + "_product" );	
		// alert(objPoint.x + " - " + objPoint.y);
		objHover.style.display = "block";			
		
		//alert(objHover.offsetWidth + " " + objHover.offsetHeight);		
		
		if( iPosIndex == 0 || 
			iPosIndex == 1 || 
			iPosIndex == 4 ||										
			iPosIndex == 5 ||
			iPosIndex == 8 ||										
			iPosIndex == 9 )
		{
			// set x 	
			objHover.style.left = (objPoint.x+(182/2)+60) + "px";
			
			// set y				
			if( iPosIndex == 8 || 
				iPosIndex == 9 )
			{
				objHover.style.top = (objPoint.y - (objHover.offsetHeight-40) ) + "px";
			} else {
				objHover.style.top = (objPoint.y+20) + "px";							
			}
		} else {
			if( iPosIndex == 2 || 
				iPosIndex == 3 || 
				iPosIndex == 6 || 
				iPosIndex == 7 ||
				iPosIndex == 10 ||										
				iPosIndex == 11 )
			{
				// set x
				objHover.style.left = ( objPoint.x - (182*2) ) + 20 + "px";				
				
				// set y 				
				if( iPosIndex == 10 || 
				    iPosIndex == 11 )
				{
					objHover.style.top = (objPoint.y - objHover.offsetHeight ) + 40 + "px";					
				} else {
					objHover.style.top = (objPoint.y+20) + "px";															
				}
			}			
		}
			
		strHoverId = iId;
	}
}

function getPosition( strElementId )
{	
	/*
	var objElement = document.getElementById( strElementId );
	var strTagName = "";
	var iY = 0;
	var iX = 0;
	
	while( objElement != null )
	{
		iY += objElement.offsetTop;
		iX += objElement.offsetLeft;
		strTagName = objElement.tagName.toUpperCase();
	
		if( strTagName == "BODY" )
		{
			strTagName = 0;
		}
	
		if( typeof( objElement ) == "object" )
		{
			if( typeof( objElement.offsetParent ) == "object" )
			{
				//alert( strTagName + " - " + objElement.offsetParent );
				objElement = objElement.offsetParent;
			}
		}
	}
	*/
	// alert(iX + " - " + iY);
	objPosition = new Object();
	/*
	objPosition.x = iX;
	objPosition.y = iY;
	*/
	objPosition.x = document.getElementById( strElementId ).offsetLeft;
	objPosition.y = document.getElementById( strElementId ).offsetTop;	
	
	//alert( objPosition.x + " - " + document.getElementById( strElementId ).offsetLeft );
	
	return objPosition;
}

var objImgDeSel = new Image();
objImgDeSel.src = "images/layout/icons/0-0.png";

var objImgSel = new Image();
objImgSel.src = "images/layout/icons/1-0.png";

function selMark( iMark )
{
	var iValue = 6;
	if( document.getElementById( "Mark" + iMark ).childNodes[0].src == objImgSel.src )
	{	
		iValue = iMark;	
		if( iMark == 5 )
		{
			if( document.getElementById( "Mark4").childNodes[0].src == objImgDeSel.src )
			{
				document.getElementById("Mark5").childNodes[0].src = objImgDeSel.src;
				iValue = 6;
			}
		} else {		
			if( document.getElementById( "Mark" + (iMark - 1) ) != null )
			{
				if( document.getElementById( "Mark" + (iMark - 1) ).childNodes[0].src == objImgDeSel.src )
				{
					document.getElementById("Mark" + iMark ).childNodes[0].src = objImgDeSel.src;
					if( iMark != 6 )
					{
						iValue = iMark + 1;
					} else {
						iValue = 6;
					}
				}			
			} else {
				if( iMark == 1 )
				{
					document.getElementById("Mark" + iMark ).childNodes[0].src = objImgDeSel.src;
					iValue = 2;
				}
			}		
		}
		
		for( iIndex = iMark-1; iIndex > 0; iIndex-- )
		{
			document.getElementById("Mark" + iIndex ).childNodes[0].src = objImgDeSel.src;
		}			
	} else {
		document.getElementById("Mark1").childNodes[0].src = objImgDeSel.src;
		document.getElementById("Mark2").childNodes[0].src = objImgDeSel.src;
		document.getElementById("Mark3").childNodes[0].src = objImgDeSel.src;
		document.getElementById("Mark4").childNodes[0].src = objImgDeSel.src;
		document.getElementById("Mark5").childNodes[0].src = objImgDeSel.src;
		
		iSteps = 6 - iMark;
		for( iIndex = 5; iIndex >= iMark; iIndex-- )
		{
			document.getElementById("Mark" + iIndex ).childNodes[0].src = objImgSel.src;
		}
		
		iValue = iMark;
	}

	document.getElementById("vote_hidden").value = iValue;
}

function goToOrderStep( iStep )
{
	objOrderForm = document.getElementById("order_form");
	if( objOrderForm == null )
	{
		return;
	}

	switch( iStep )
	{
		case 0:
			objOrderForm.action = "index.php?page_id=show_cart&step=0";
			objOrderForm.submit();			
		break;
		
		case 1:
			objOrderForm.action = "index.php?page_id=show_cart&step=1";				
			objOrderForm.submit();			
		break;
		
		case 2:
			objOrderForm.action = "index.php?page_id=show_cart&step=2";
			objOrderForm.submit();			
		break;
	
		case 3:
			objOrderForm.action = "index.php?page_id=show_cart&step=3";			
			objOrderForm.submit();
		break;		
	}
}

function popupFadeOut()
{
	$('#NewProductAddToCart').hide();												
}

function openProductCompare( strUrl )
{
	var iWndYCenter = ( pageHeight() / 2 ) + topPosition();
	var iWndXCenter = ( pageWidth() / 2 ) + leftPosition();							
	var iWidth = ( iWndXCenter-(800/2) );
	var iHeight = ( iWndYCenter-(600/2) );
	objNewWnd = window.open( strUrl, "ProductCompare", "width=800, height=600, left=" + iWidth + ", top=" + iHeight + ", status=no, toolbar=no, menubar=no, location=no, dependent=yes, scrollbars=yes, resizable=yes");
	objNewWnd.focus();
}

function toggleFilterBox()
{
	$("#filter_box").slideToggle("fast");
}


var objCheck = new Image();
objCheck.src = "images/layout/check.png";

var objCheckSel = new Image();
objCheckSel.src = "images/layout/check_sel.png";

function toggleInputFieldCheck( strValueId )
{
	objClickedElement = document.getElementById( "filter_field__1_" + strValueId );
	if( objClickedElement == null )
	{
		return false;
	}

	if( objClickedElement.value == "1" )
	{
		objClickedElement.value = "0";
		objElementCheckImg = document.getElementById( "filter_field__1_" + strValueId + "_check" );
		if( objElementCheckImg != null )
		{				
			// uncheck radio ctrl (image)
			objElementCheckImg.src = objCheck.src;
		}		
	} else {
		objClickedElement.value = "1";		
		objElementCheckImg = document.getElementById( "filter_field__1_" + strValueId + "_check" );
		if( objElementCheckImg != null )
		{				
			// check radio ctrl (image)
			objElementCheckImg.src = objCheckSel.src;
		}		
	}

	document.getElementById("FilterForm").submit();
}

var objRadio = new Image();
objRadio.src = "images/layout/radio.png";

var objRadioSel = new Image();
objRadioSel.src = "images/layout/radio_sel.png";

function toggleInputField( strFilterId, strValueId )
{
	objClickedElement = document.getElementById( "filter_field_" + strFilterId + "_" + strValueId );
	if( objClickedElement == null )
	{
		return false;
	}
	
	var arrFilterItems;
	eval( "arrFilterItems = arrFilterElement" + strFilterId + ";" );
	if( arrFilterItems != null )
	{
		iArrSize = arrFilterItems.length;
		for( iIndex = 0; iIndex < iArrSize; iIndex++ )
		{
			if( objClickedElement.id != "filter_field_" + arrFilterItems[iIndex] )
			{
				objElementHiddenBool = document.getElementById("filter_field_" + arrFilterItems[iIndex]);
				if( objElementHiddenBool != null )
				{
					// set hidden filter bool to 0, filter not set
					objElementHiddenBool.value = "0";
					
					objElementRadioImg = document.getElementById( arrFilterItems[iIndex] + "_radio" );
					if( objElementRadioImg != null )
					{	
						// uncheck radio ctrl (image)
						objElementRadioImg.src = objRadio.src;
					}
				}
			}
		}
	}

	if( objClickedElement.value == "1" )
	{
		objClickedElement.value = "0";
		objElementRadioImg = document.getElementById( strFilterId + "_" + strValueId + "_radio" );
		if( objElementRadioImg != null )
		{				
			// uncheck radio ctrl (image)
			objElementRadioImg.src = objRadio.src;
		}		
	} else {
		objClickedElement.value = "1";		
		objElementRadioImg = document.getElementById( strFilterId + "_" + strValueId + "_radio" );
		if( objElementRadioImg != null )
		{				
			// check radio ctrl (image)
			objElementRadioImg.src = objRadioSel.src;
		}		
	}

	document.getElementById("FilterForm").submit();
}

function toggleInputFieldPSG( strValueId )
{
	objClickedElement = document.getElementById( "filter_field__1_" + strValueId );
	if( objClickedElement == null )
	{
		return false;
	}
	
	var arrFilterItems;
	eval( "arrFilterItems = arrFilterElement_1;" );
	if( arrFilterItems != null )
	{
		iArrSize = arrFilterItems.length;
		for( iIndex = 0; iIndex < iArrSize; iIndex++ )
		{
			if( objClickedElement.id != "filter_field__" + arrFilterItems[iIndex] )
			{
				objElementHiddenBool = document.getElementById("filter_field__" + arrFilterItems[iIndex]);
				if( objElementHiddenBool != null )
				{
					// set hidden filter bool to 0, filter not set
					objElementHiddenBool.value = "0";

					objElementRadioImg = document.getElementById( "filter_field__" + arrFilterItems[iIndex] + "_radio" );
					if( objElementRadioImg != null )
					{	
						// uncheck radio ctrl (image)
						objElementRadioImg.src = objRadio.src;
					}
				}
			}
		}
	}

	if( objClickedElement.value == "1" )
	{
		objClickedElement.value = "0";
		objElementRadioImg = document.getElementById( "filter_field__1_" + strValueId + "_radio" );
		if( objElementRadioImg != null )
		{				
			// uncheck radio ctrl (image)
			objElementRadioImg.src = objRadio.src;
		}		
	} else {
		objClickedElement.value = "1";		
		objElementRadioImg = document.getElementById( "filter_field__1_" + strValueId + "_radio" );
		if( objElementRadioImg != null )
		{			
			// check radio ctrl (image)
			objElementRadioImg.src = objRadioSel.src;
		}		
	}

	document.getElementById("FilterForm").submit();
}

function toggleBox( iId )
{
	objBox = document.getElementById( "box_" + iId );
	objBoxSub = document.getElementById( "box_sub_" + iId );					
	if( objBox != null )
	{
		if( objBoxSub != null )
		{
			$("#box_sub_" + iId ).slideToggle("fast");
		}
	}
}
				
function resetCar()
{
	/*
	document.getElementById("car_maker").selectedIndex = 0;
	document.getElementById("car_type").selectedIndex = 0;
	document.getElementById("car_variant").selectedIndex = 0;
	document.getElementById("car_id").selectedIndex = 0;
	document.getElementById("CarSelecterForm").submit();
	*/
	window.location.href = "index.php?car_maker=";
}


var g_iPopUpStatus = 0;

function closeRelatedCarsWnd()
{
	if( g_iPopUpStatus == 1 )
	{
		$("#RelatedCarBox").fadeOut("slow"); 		
		g_iPopUpStatus = 0;
	}
}

var g_iPopUpStatusHsnTsn = 0;

function closeHsnTsnWnd()
{
	if( g_iPopUpStatusHsnTsn == 1 )
	{
		$("#HsnTsnBox").fadeOut("slow");
		g_iPopUpStatusHsnTsn = 0;
	}
}


function closeWnd( iId )
{
	$("#dlg_" + iId ).fadeOut("slow");
}

function openDlg( iId )
{	
	iWndYCenter = (pageHeight()/2) + topPosition();
	iWndXCenter = (pageWidth()/2) + leftPosition();		
	
	iPopUpYCenter = 525/2;
	iPopUpXCenter = 800/2;
	
	document.getElementById("dlg_" + iId ).style.top = (iWndYCenter-iPopUpYCenter) + "px";
	document.getElementById("dlg_" + iId ).style.left = (iWndXCenter-iPopUpXCenter) + "px";						
	
	$("#dlg_" + iId ).fadeIn("slow"); 
}

function openRelatedCarsWnd( iProductId )
{	
	if( iProductId == "" )
	{
		return;
	}

	document.getElementById("RelatedCarFrame").src = "related_cars_by_product_id.php?product_id=" + iProductId;	
	
	$("#open_car_fit_box").fancybox(
	{	
		'content': document.getElementById("RelatedCarBoxFrame").innerHTML,		
		'modal' 	: true,
		'titleShow': false,
		'padding'		 : 0,
		'overlayOpacity' : 0.6,
		'overlayColor'	 : '#000',
		'centerOnScroll' : true
	});		
	
	$("#open_car_fit_box").click();
}

function closeNoteWnd()
{
	document.getElementById("NoteBox").style.display = "none";
}

function openNoteWnd( iProductId, iNoteTableId )
{
	if( iProductId == "" )
	{
		return;
	}
						
	if( document.getElementById("NoteBox").style.display == "inline" )
	{
		document.getElementById("NoteBox").style.display = "none";
	} else {
		iWndYCenter = pageHeight()/2;
		iWndXCenter = pageWidth()/2;		
		
		iPopUpYCenter = 600/2;
		iPopUpXCenter = 800/2;
		
		document.getElementById("NoteBox").style.top = (iWndYCenter-iPopUpYCenter) + "px";
		document.getElementById("NoteBox").style.left = (iWndXCenter-iPopUpXCenter) + "px";						
		
		document.getElementById("NoteFrame").src = "notes_by_product_id.php?product_id=" + iProductId + "&note_table_id=" + iNoteTableId;

		document.getElementById("NoteBox").style.display = "inline";	
	}
}				

// calculate the current window width //
function pageWidth() 
{
	return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}

// calculate the current window height //
function pageHeight() 
{
	return window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
}

// calculate the current window vertical offset //
function topPosition() 
{
	return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}

// calculate the position starting at the left of the window //
function leftPosition() 
{
	return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
}	

function changedGroup()
{
	objForm = document.getElementById("GroupSwitcher");
	if( objForm != null )
	{
		objForm.submit();
	}
}

function checkNumber( objInput )
{
	var strValue = objInput.value.replace(/[^\^\d]/g, '');
	if( parseInt(strValue) <= 0 )
	{
		strValue = 1;
	}
	objInput.value = strValue;
}


function refreshCartChange()
{
	objOrderForm = document.getElementById("order_form");
	if( objOrderForm == null )
	{
		return;
	}

	objOrderForm.action = "index.php?page_id=show_cart&refresh=1";	
	objOrderForm.submit();
}

function resetCssClass( objElement )
{
	if( objElement == null )
	{
		return false;
	}
	
	objElement.className = "input_field";
	return true;			
}

function highlightElement( objElement )
{
	if( objElement == null )
	{
		return false;
	}

	objElement.className = "input_field_sel";			
	objElement.focus();
}

function checkElement( objElement )
{
	if( objElement == null )
	{
		return false;
	}
	
	if( objElement.value == "" )
	{				
		highlightElement(objElement);
		return false;
	}
	return true;
}

function resetOrderForm()
{
	resetCssClass(document.getElementById("firstname"));
	resetCssClass(document.getElementById("surname"));
	resetCssClass(document.getElementById("street"));
	resetCssClass(document.getElementById("city"));
	resetCssClass(document.getElementById("zipcode"));
	resetCssClass(document.getElementById("phone"));
	resetCssClass(document.getElementById("email"));
	return true;
}

function goToCart()
{
	objFormStep1 = document.getElementById("step_1");
	if( objFormStep1 != null )
	{
		objFormStep1.action = "index.php?page_id=show_cart";
		objFormStep1.submit();
	}
}

function goBackToStep1()
{
	objFormStep2 = document.getElementById("step_2");
	if( objFormStep2 != null )
	{
		objFormStep2.action = "index.php?page_id=order_step_1";
		objFormStep2.submit();
	}
}

function goToStep3()
{
	objFormStep2 = document.getElementById("step_2");
	if( objFormStep2 != null )
	{	
		objNextButton = document.getElementById("next_button");
		objRightOfWithdrawalCheck = document.getElementById("right_of_withdrawal_check");
		if( objRightOfWithdrawalCheck.checked == true )
		{
			objFormStep2.action = "index.php?page_id=order_step_3";
			objFormStep2.submit();					
		}
	}			
}



var objStep3TxtButtonRed = new Image();
objStep3TxtButtonRed.src = "images/layout/bg-wr-cart-nonaccept.jpg";

var objStep3TxtButtonGreen = new Image();
objStep3TxtButtonGreen.src = "images/layout/bg-wr-cart-naccepted.jpg";

function toggleNext()
{
	objNextButton = document.getElementById("GoToStep3Link");
	
	objCheckButton = document.getElementById("check_button_img");
	objTxtButton = document.getElementById("txt_button_img");		
	
	if( objCheckButton.src == objCheck.src )
	{			
		objCheckButton.src = objCheckSel.src;
		objTxtButton.src = objStep3TxtButtonGreen.src;
		objNextButton.style.display = "block";
	} else {
		objCheckButton.src = objCheck.src;
		objTxtButton.src = objStep3TxtButtonRed.src;		
		objNextButton.style.display = "none";		
	}
}

function goBackToStep2()
{
	objFormStep3 = document.getElementById("step_3");
	if( objFormStep3 != null )
	{	
		objFormStep3.action = "index.php?page_id=order_step_2";
		objFormStep3.submit();					
	}			
}

function sendOrder()
{
	objSendOrder = document.getElementById("SendOrder");
	if( objSendOrder != null )
	{
		objSendOrder.value = "1";
		
		objFormStep = document.getElementById("order_form");
		if( objFormStep != null )
		{
			objFormStep.submit();
		}
	}
}

function checkCookie()
{
	strCookie = document.cookie;
	while( strCookie != "" )
	{
		strCookieName = strCookie.substring( 0, strCookie.search('=') );
		strCookieValue = strCookie.substring( strCookie.search('=')+1, strCookie.search(';') );
		
		if( strCookieValue == "" )
		{
			strCookieValue = strCookie.substring( strCookie.search('=')+1, strCookie.length);
		}
		
		strCookieName = strCookieName.replace(/ /g, "");
		if( strCookieName == "weitecshop" )
		{
			return true;
		}
	
		iPos = strCookie.search(';')+1;
		if( iPos == 0 )
		{
			iPos = strCookie.length
		}
		strCookie = strCookie.substring( iPos, strCookie.length );
	}
	return false;
}
