// JavaScript Document
if (is_admin != 1) {
	hs.graphicsDir = SITE_ROOT + 'highslide/graphics/';
	hs.align = 'center';
	hs.transitions = ['expand', 'crossfade'];
	hs.outlineType = 'rounded-white';
	hs.fadeInOut = true;
	//hs.numberPosition = 'caption';
	hs.dimmingOpacity = 0.5;
}
// Add the controlbar
/*
hs.addSlideshow
(
	{
		//slideshowGroup: 'group1',
		interval: 5000,
		repeat: false,
		useControls: true,
		fixedControls: 'fit',
		overlayOptions: 
		{
			opacity: .75,
			position: 'bottom center',
			hideOnMouseOut: true
		}
	}
);
*/

if (is_admin != 1) {
	$(document).ready(function() {
		$('#ddlLanguage').sSelect();

		var sky = null; // object
		var sky_pos = 0;
		sky = document.getElementById('top');
		setInterval(
	function() {
		sky.style.backgroundPosition = sky_pos++ + 'px 0px';

	},
	45);
	});
}

function pageLoad()
{
	showShoppingCart();
}

function trim(str)
{ 
	return str.replace(/^\s+|\s+$/g, '');
}

function SelectTab(n, tabs)
{
	// Tabs
	for ( i=1; i<=tabs; i++ )
	{
		if ( n == i )
		{
			document.getElementById('tab_' + i).className = 'tab selected';
			document.getElementById('content_tab_' + i).style.display = 'block';
		}
		else
		{
			document.getElementById('tab_' + i).className = 'tab';
			document.getElementById('content_tab_' + i).style.display = 'none';
		}
	}
}

function pagesMenuOver(obj)
{
	obj.oldClass = obj.className;
	obj.className = 'selected';
}

function pagesMenuOut(obj)
{
	if (obj.oldClass && obj.oldClass != '')
	{
		obj.className = obj.oldClass;
	}
	else
	{
		obj.className = '';
	}
}

function contactSubmit()
{
	var is_submit = true;
	
	// Name
	if ( trim(document.frmContact.txtName.value).length == 0 )
	{
		document.frmContact.txtName.className = 'input-error';
		document.frmContact.txtName.focus();
		document.frmContact.txtName.select();
		is_submit = false;
	}
	else
	{
		document.frmContact.txtName.className = 'input';
	}
	
	// Phone
	if ( trim(document.frmContact.txtPhone.value).length == 0 )
	{
		document.frmContact.txtPhone.className = 'input-error';
		document.frmContact.txtPhone.focus();
		document.frmContact.txtPhone.select();
		is_submit = false;
	}
	else
	{
		document.frmContact.txtPhone.className = 'input';
	}

	// Email
	if ( !emailCheck(document.frmContact.txtEmail.value) )
	{
		document.frmContact.txtEmail.className = 'input-error';
		document.frmContact.txtEmail.focus();
		document.frmContact.txtEmail.select();
		is_submit = false;
	}
	else
	{
		document.frmContact.txtEmail.className = 'input';
	}
	
	// Subject
	if ( trim(document.frmContact.txtSubject.value).length == 0 )
	{
		document.frmContact.txtSubject.className = 'input-error';
		document.frmContact.txtSubject.focus();
		document.frmContact.txtSubject.select();
		is_submit = false;
	}
	else
	{
		document.frmContact.txtSubject.className = 'input';
	}
	
	// security_code
	if ( trim(document.frmContact.security_code.value).length == 0 )
	{
		document.frmContact.security_code.className = 'input-error';
		document.frmContact.security_code.focus();
		document.frmContact.security_code.select();
		is_submit = false;
	}
	else
	{
		document.frmContact.security_code.className = 'input';
	}
	
	//
	if (is_submit)
	{
		document.frmContact.submit();
	}
}

function supportSubmit()
{
	var is_submit = true;
	
	if ( !emailCheck(document.frmSupport.txtEmail.value) )
	{
		document.frmSupport.txtEmail.className = 'input-error';
		document.frmSupport.txtEmail.focus();
		document.frmSupport.txtEmail.select();
		is_submit = false;
	}
	else
	{
		document.frmSupport.txtEmail.className = 'input';
	}
	
	if (is_submit)
	{
		document.frmSupport.submit();
	}
}

/* Products */
function getProducts()
{
	var area_url 		= 0;
	var group_url		= 0;
	var subgroup_url	= 0;
	var assortment_url	= 0;
	var firm_url		= 0;
	var type_url		= 0;
	var model_url		= 0;
	var color_url		= 0;
	
	if (document.getElementById('area_url'))
	{
		area_url = document.getElementById('area_url').value;
	}
	if (document.getElementById('group_url'))
	{
		group_url = document.getElementById('group_url').value;
	}
	if (document.getElementById('subgroup_url'))
	{
		subgroup_url = document.getElementById('subgroup_url').value;
	}
	if (document.getElementById('assortment_url'))
	{
		assortment_url = document.getElementById('assortment_url').value;
	}
	if (document.getElementById('firm_url'))
	{
		firm_url = document.getElementById('firm_url').value;
	}
	if (document.getElementById('type_url'))
	{
		type_url = document.getElementById('type_url').value;
	}
	if (document.getElementById('model_url'))
	{
		model_url = document.getElementById('model_url').value;
	}
	if (document.getElementById('color_url'))
	{
		color_url = document.getElementById('color_url').value;
	}
	document.location = SITE_ROOT + LANG + '/gproducts/' + area_url + '/' + group_url + '/' + subgroup_url + '/' + assortment_url + '/' + firm_url + '/' + type_url + '/' + model_url + '/' + color_url + '/';
}

function UserNameCheck(UserName)
{
	var UserNamePat = /^([a-zA-Z0-9._-]+)/;	
	var matchArray = UserName.match(UserNamePat);
	
	if ( matchArray == null )
	{
		return false;	
	}
	else if ( matchArray[0] != UserName )
	{
		return false;
	}
	else
	{
		return true;	
	}
}

function emailCheck(emailStr)
{
	/* The following pattern is used to check if the entered e-mail address
	fits the user@domain format. It also is used to separate the username
	from the domain. */

	//var emailPat=/^(.+)@(.+)$/
	var emailPat=/^([a-zA-Z0-9._-]+)@(.+)$/;
	/* The following string represents the pattern for matching all special
	characters. We don't want to allow special characters in the address. 
	These characters include ( ) < > @ , ; : \ " . [ ] */
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
	/* The following string represents the range of characters allowed in a 
	username or domainname. It really states which chars aren't allowed. */
	var validChars="\[^\\s" + specialChars + "\]";
	/* The following pattern applies if the "user" is a quoted string (in
	which case, there are no rules about which characters are allowed
	and which aren't; anything goes). E.g. "jiminy cricket"@disney.com
	is a legal e-mail address. */
	var quotedUser="(\"[^\"]*\")";
	/* The following pattern applies for domains that are IP addresses,
	rather than symbolic names. E.g. joe@[123.124.233.4] is a legal
	e-mail address. NOTE: The square brackets are required. */
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	/* The following string represents an atom (basically a series of
	non-special characters.) */
	var atom=validChars + '+';
	/* The following string represents one word in the typical username.
	For example, in john.doe@somewhere.com, john and doe are words.
	Basically, a word is either an atom or quoted string. */
	var word="(" + atom + "|" + quotedUser + ")";
	// The following pattern describes the structure of the user
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	/* The following pattern describes the structure of a normal symbolic
	domain, as opposed to ipDomainPat, shown above. */
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	
	
	/* Finally, let's start trying to figure out if the supplied address is
	valid. */
	
	/* Begin with the coarse pattern to simply break up user@domain into
	different pieces that are easy to analyze. */
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null)
	{
		/* Too many/few @'s or something; basically, this address doesn't
		even fit the general mould of a valid e-mail address. */
		//alert("Wrong Email!");
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	
	// See if "user" is valid 
	if (user.match(userPat)==null)
	{
		// user is not valid
		//alert("Wrong Email!");
		return false;
	}

	/* if the e-mail address is at an IP address (as opposed to a symbolic
	host name) make sure the IP address is valid. */
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null)
	{
		// this is an IP address
		for (var i=1;i<=4;i++)
		{
			if (IPArray[i]>255)
			{
				//alert("Wrong Email!");
				return false;
			}
		}
		return true;
	}

	// Domain is symbolic name
	var domainArray=domain.match(domainPat);
	if (domainArray==null)
	{
		//alert("Wrong Email!");
		return false;
	}
	
	/* domain name seems valid, but now make sure that it ends in a
	three-letter word (like com, edu, gov) or a two-letter word,
	representing country (uk, nl), and that there's a hostname preceding 
	the domain or country. */
	
	/* Now we need to break up the domain to get a count of how many atoms
	it consists of. */
	var atomPat=new RegExp(atom,"g");
	var domArr=domain.match(atomPat);
	var len=domArr.length;
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3)
	{
		// the address must end in a two letter or three letter word.
		//alert("Wrong Email!");
		return false;
	}
	
	// Make sure there's a host name preceding the domain.
	if (len<2)
	{
		//alert("Wrong Email!");
		return false;
	}

	// If we've gotten this far, everything's valid!
	return true;
}

function showGalleryImage(img)
{
	obj = document.getElementById('image_big');
	
	if (obj)
	{
		obj.src = SITE_ROOT + 'showimage.php?type=gallery&id=' + img + '&w=550&h=412&wm=0';
	}
}

function loginFocus(obj)
{
	if ( !obj.init )
	{
		obj.initValue = obj.value;
		obj.value = '';
		obj.init  = true;
	}
	else if ( obj.value == obj.initValue )
	{
		obj.value = '';
	}
}

function loginBlur(obj)
{
	if ( obj.value == '' )
	{
		obj.value = obj.initValue;
	}
}

function loginPasswordFocus(obj)
{
	obj.style.display = 'none';
	
	if (obj.type && obj.type == 'text')
	{
		obj_1 = document.getElementById('login_password');
	}
	else
	{
		obj_1 = document.getElementById('login_password_text');
	}
	obj_1.style.display = 'block';
	obj_1.focus();
}

function loginPasswordBlur(obj)
{
	if (obj.type && obj.type == 'text')
	{
		obj.style.display = 'none';
		obj_1 = document.getElementById('login_password');
		obj_1.style.display = 'block';
	}
	else
	{
		if (obj.value == '')
		{
			obj.style.display = 'none';
			obj_1 = document.getElementById('login_password_text');
			obj_1.style.display = 'block';
		}
	}
}

function signupStep1()
{
	var is_submit = true;
	
	// txtFirstName
	if ( trim(document.frmSignUp.txtFirstName.value).length == 0 )
	{
		document.frmSignUp.txtFirstName.className = 'input-error';
		document.frmSignUp.txtFirstName.focus();
		document.frmSignUp.txtFirstName.select();
		is_submit = false;
	}
	else
	{
		document.frmSignUp.txtFirstName.className = 'input';
	}
	
	// txtLastName
	if ( trim(document.frmSignUp.txtLastName.value).length == 0 )
	{
		document.frmSignUp.txtLastName.className = 'input-error';
		document.frmSignUp.txtLastName.focus();
		document.frmSignUp.txtLastName.select();
		is_submit = false;
	}
	else
	{
		document.frmSignUp.txtLastName.className = 'input';
	}
	
	// txtEmail
	if ( !emailCheck(document.frmSignUp.txtEmail.value) )
	{
		document.frmSignUp.txtEmail.className = 'input-error';
		document.frmSignUp.txtEmail.focus();
		document.frmSignUp.txtEmail.select();
		is_submit = false;
	}
	else
	{
		document.frmSignUp.txtEmail.className = 'input';
	}
	
	// ddlOperator
	if ( document.frmSignUp.ddlOperator.value == 0 )
	{
		document.frmSignUp.ddlOperator.focus();
		is_submit = false;
	}

	//
	if (is_submit)
	{
		document.frmSignUp.submit();
	}
}

function signupStep3()
{
	var is_submit = true;
	
	verifyFormField(document.frmSignUp.txtFirstName) == false ? is_submit = false : is_submit = is_submit;
	verifyFormField(document.frmSignUp.txtLastName) == false ? is_submit = false : is_submit = is_submit;
	verifyFormEmailField(document.frmSignUp.txtEmail) == false ? is_submit = false : is_submit = is_submit;
	
	// ddlOperator
	if ( document.frmSignUp.ddlOperator.value == 0 )
	{
		document.frmSignUp.ddlOperator.focus();
		is_submit = false;
	}
	
	verifyFormConfirmField(document.frmSignUp.txtEmail, document.frmSignUp.txtConfirmEmail) == false ? is_submit = false : is_submit = is_submit;
	verifyFormUsernameField(document.frmSignUp.txtUserName) == false ? is_submit = false : is_submit = is_submit;
	verifyFormField(document.frmSignUp.txtPassword) == false ? is_submit = false : is_submit = is_submit;
	verifyFormConfirmField(document.frmSignUp.txtPassword, document.frmSignUp.txtConfirmPassword) == false ? is_submit = false : is_submit = is_submit;
	
	//
	if (is_submit)
	{
		document.frmSignUp.submit();
	}
}

function signupStep4()
{
	var is_submit = true;
	
	verifyFormField(document.frmPayment.txtCreditCardName) == false ? is_submit = false : is_submit = is_submit;
	
	// ddlCreditCard
	if ( document.frmPayment.ddlCreditCard.value == 0 )
	{
		document.frmPayment.ddlCreditCard.focus();
		is_submit = false;
	}
	
	// ddlCreditCardExpireMonth
	if ( document.frmPayment.ddlCreditCardExpireMonth.value == 0 )
	{
		document.frmPayment.ddlCreditCardExpireMonth.focus();
		is_submit = false;
	}
	
	// ddlCreditCardExpireYear
	if ( document.frmPayment.ddlCreditCardExpireYear.value == 0 )
	{
		document.frmPayment.ddlCreditCardExpireYear.focus();
		is_submit = false;
	}
	
	verifyFormField(document.frmPayment.txtCreditCardNumber) == false ? is_submit = false : is_submit = is_submit;
	verifyFormField(document.frmPayment.txtCreditCardCode) == false ? is_submit = false : is_submit = is_submit;
	
	verifyFormField(document.frmPayment.txtBillingFirstName) == false ? is_submit = false : is_submit = is_submit;
	verifyFormField(document.frmPayment.txtBillingLastName) == false ? is_submit = false : is_submit = is_submit;
	
	// ddlBillingCountry
	if ( document.frmPayment.ddlBillingCountry.value == 0 )
	{
		document.frmPayment.ddlBillingCountry.focus();
		is_submit = false;
	}
	
	verifyFormField(document.frmPayment.txtBillingCity) == false ? is_submit = false : is_submit = is_submit;
	verifyFormField(document.frmPayment.txtBillingStreet) == false ? is_submit = false : is_submit = is_submit;
	verifyFormField(document.frmPayment.txtBillingZIP) == false ? is_submit = false : is_submit = is_submit;
	verifyFormField(document.frmPayment.txtBillingPhone) == false ? is_submit = false : is_submit = is_submit;
	
	if ( !document.frmPayment.chkPolicy.checked )
	{
		document.frmPayment.chkPolicy.focus();
		is_submit = false;
	}
	
	if ( !document.frmPayment.chkTerms.checked )
	{
		document.frmPayment.chkTerms.focus();
		is_submit = false;
	}
	
	// 
	if (is_submit)
	{
		document.frmPayment.submit();
	}
}

// Проверка поля в форме
function verifyFormField(field)
{
	if (field)
	{
		if ( trim(field.value).length == 0 )
		{
			field.className = 'input-error';
			field.focus();
			field.select();
			return false;
		}
		else
		{
			field.className = 'input';
			return true;
		}
	}
	return false;
}

// Проверка поля Email в форме
function verifyFormEmailField(field)
{
	if (field)
	{
		if ( !emailCheck(field.value) )
		{
			field.className = 'input-error';
			field.focus();
			field.select();
			return false;
		}
		else
		{
			field.className = 'input';
			return true;
		}
	}
	return false;
}

// Проверка поля Username в форме
function verifyFormUsernameField(field)
{
	if (field)
	{
		if ( !UserNameCheck(field.value) )
		{
			field.className = 'input-error';
			field.focus();
			field.select();
			return false;
		}
		else
		{
			field.className = 'input';
			return true;
		}
	}
	return false;
}

// Проверка совпадения 2-х полей в форме
function verifyFormConfirmField(field, confirm_field)
{
	if (field && confirm_field)
	{
		if ( trim(field.value) != trim(confirm_field.value) )
		{
			confirm_field.className = 'input-error';
			confirm_field.focus();
			confirm_field.select();
			return false;
		}
		else
		{
			confirm_field.className = 'input';
			return true;
		}
	}
	return false;
}

function signupSelectOperator()
{
	var operator_id = document.getElementById('ddlOperator').value;
	if (operator_id != '0')
	{
		destination.push('skuku_operetor_status');
		script_name = SITE_ROOT + "ajax.php?lang=" + LANG;
		ajax_req = 'switch=skuku_operetor_status&operator_id=' + operator_id;
		cache.push(ajax_req);
		getAjaxRequest();
	}
	else
	{
		document.getElementById('skuku_operetor_status').innerHTML = 'Choose your network operator / country';
	}
}

function setProductsQuantity(id, action)
{
	var obj = document.getElementById(id);
	if (obj)
	{
		if (isNaN(obj.value))
		{
			obj.value = 1;
		}
		
		if (action == '-' && parseInt(obj.value) > 1)
		{
			obj.value = parseInt(obj.value) - 1;
		}
		else if (action == '+')
		{
			obj.value = parseInt(obj.value) + 1;
		}
	}
}

// Refresh DIV to show Shopping Cart
function showShoppingCart()
{
	var obj = document.getElementById('shopping_cart');
	if (obj)
	{
		destination.push('shopping_cart');
		script_name = SITE_ROOT + "ajax.php?lang=" + LANG;
		ajax_req = 'switch=b2b_shopping_cart';
		cache.push(ajax_req);
		getAjaxRequest();
	}
}

// Add selected product to Shopping Cart
function addToShoppingCart(product_id)
{
	//if ( confirm('Add to Shopping Cart ?') )
	//{
		var quantity = 1;
		
		if ( document.getElementById('product_qty_' + product_id) )
		{
			quantity = parseInt(document.getElementById('product_qty_' + product_id).value);
		}
		
		destination.push('shopping_cart');
		script_name = SITE_ROOT + "ajax.php?lang=" + LANG;
		ajax_req = 'product_id=' + product_id + '&quantity=' + quantity + '&switch=b2b_addToShoppingCart';
		cache.push(ajax_req);
		getAjaxRequest();
		
		// Refresh Shopping Cart
		showShoppingCart();
	//}
}

// Remove product from shopping cart
function removeFromShoppingCart(cart_id)
{
	//if ( confirm('Remove from Shopping Cart ?') )
	//{
		destination.push('shopping_cart');
		script_name = SITE_ROOT + "ajax.php?lang=" + LANG;
		ajax_req = 'cart_id=' + cart_id + '&switch=b2b_removeFromShoppingCart';
		cache.push(ajax_req);
		getAjaxRequest();
		
		// Refresh Shopping Cart
		showShoppingCart();
	//}
}

//
function getCountryZones(obj, div, sw)
{
	var country_id = parseInt(obj.value);
	
	destination.push(div);
	script_name = SITE_ROOT + "ajax.php?lang=" + LANG;
	ajax_req = 'country_id=' + country_id + '&switch=' + sw;
	cache.push(ajax_req);
	getAjaxRequest();
}

//
function copyBillingAddress(obj)
{
	if (obj.checked)
	{
		document.frmPayment.txtShippingFirstName.value = document.frmPayment.txtBillingFirstName.value;
		document.frmPayment.txtShippingLastName.value = document.frmPayment.txtBillingLastName.value;
		document.frmPayment.txtShippingCity.value = document.frmPayment.txtBillingCity.value;
		document.frmPayment.txtShippingStreet.value = document.frmPayment.txtBillingStreet.value;
		document.frmPayment.txtShippingZIP.value = document.frmPayment.txtBillingZIP.value;
		document.frmPayment.txtShippingPhone.value = document.frmPayment.txtBillingPhone.value;
		
		document.frmPayment.ddlShippingCountry.selectedIndex = document.frmPayment.ddlBillingCountry.selectedIndex;
		
		var country_id = document.frmPayment.ddlBillingCountry.value;
		var sw = 'b2b_payment_shipping_state';
		
		destination.push('div_shipping_state');
		script_name = SITE_ROOT + "ajax.php?lang=" + LANG;
		ajax_req = 'country_id=' + country_id + '&switch=' + sw;
		cache.push(ajax_req);
		getAjaxRequest();
		
		//document.frmPayment.ddlShippingState.selectedIndex = document.frmPayment.ddlBillingState.selectedIndex;
		
	}
}

function introOver(id)
{
	//var objLine = document.getElementById('intro-box-line');
	//var x = 320 + 149 * (id-1);
	//objLine.style.marginLeft = x;
	
	var obj = document.getElementById('intro_text');
	if (obj)
	{
		obj.style.display = 'none';
	}
	
	for(i=1; i<=5; i++)
	{
		objText = document.getElementById('intro_text_'+i);
		if (objText)
		{
			if (i == id)
			{
				objText.style.display = 'block';
			}
			else
			{
				objText.style.display = 'none';
			}
		}
	}
}

function introOut()
{
	var obj = document.getElementById('intro_text');
	if (obj)
	{
		obj.style.display = 'block';
	}
	
	for(i=1; i<=5; i++)
	{
		objText = document.getElementById('intro_text_'+i);
		if (objText)
		{
			objText.style.display = 'none';
		}
	}
}

// Open menu Item
function menuClick(id, cId, cName)
{
	var obj = document.getElementById(cId+id);
	
	if (obj)
	{
		if (obj.className == cName + 'close')
		{
			obj.className = cName + 'open';
		}
		else
		{
			obj.className = cName + 'close';
		}
	}
}

function loginSubmit()
{
	var is_submit = true;
	
	verifyFormField(document.frmLogin.login_username) == false ? is_submit = false : is_submit = is_submit;
	verifyFormField(document.frmLogin.login_password) == false ? is_submit = false : is_submit = is_submit;
	
	return is_submit;
}

function createAccountSubmit()
{
	var is_submit = true;
	
	verifyFormField(document.frmRegistration.txtFirstName) == false ? is_submit = false : is_submit = is_submit;
	verifyFormField(document.frmRegistration.txtLastName) == false ? is_submit = false : is_submit = is_submit;
	verifyFormEmailField(document.frmRegistration.txtEmail) == false ? is_submit = false : is_submit = is_submit;
	
	if ( document.frmRegistration.txtUserName )
	{
		verifyFormUsernameField(document.frmRegistration.txtUserName) == false ? is_submit = false : is_submit = is_submit;
		verifyFormField(document.frmRegistration.txtPassword) == false ? is_submit = false : is_submit = is_submit;
		verifyFormConfirmField(document.frmRegistration.txtPassword, document.frmRegistration.txtConfirmPassword) == false ? is_submit = false : is_submit = is_submit;
	}	
	
	return is_submit;
}

function registrationSubmit()
{
	var is_submit = true;
	
	verifyFormField(document.frmRegistration.txtFirstName) == false ? is_submit = false : is_submit = is_submit;
	verifyFormField(document.frmRegistration.txtLastName) == false ? is_submit = false : is_submit = is_submit;
	verifyFormEmailField(document.frmRegistration.txtEmail) == false ? is_submit = false : is_submit = is_submit;
	verifyFormField(document.frmRegistration.txtPhoneCell) == false ? is_submit = false : is_submit = is_submit;
	verifyFormField(document.frmRegistration.txtCity) == false ? is_submit = false : is_submit = is_submit;
	verifyFormField(document.frmRegistration.txtAddress) == false ? is_submit = false : is_submit = is_submit;
	
	if ( document.frmRegistration.txtUserName )
	{
		verifyFormUsernameField(document.frmRegistration.txtUserName) == false ? is_submit = false : is_submit = is_submit;
		verifyFormField(document.frmRegistration.txtPassword) == false ? is_submit = false : is_submit = is_submit;
		verifyFormConfirmField(document.frmRegistration.txtPassword, document.frmRegistration.txtConfirmPassword) == false ? is_submit = false : is_submit = is_submit;
	}	
	
	return is_submit;
}

function showGalleryCaruselImage(id, url)
{
	var big_image = document.getElementById('gallery_carusel_image');
	var big_image_url = document.getElementById('gallery_carusel_image_url');
	
	if (big_image && big_image_url)
	{
		big_image.src = SITE_ROOT + 'showimage.php?type=gallery&id=' + id + '&w=300&h=225&wm=0';
		big_image_url.href = url;
	}
	
}

function OpenMenu(id)
{
	if ( document.getElementById('menu_' + id) )
	{
		if ( document.getElementById('menu_' + id).open )
		{
			document.getElementById('menu_' + id).style.display = 'none';
			document.getElementById('menu_icon_' + id).src = TPL_PATH +'images/icon_help_close.gif';
			document.getElementById('menu_bullet_' + id).src = TPL_PATH + 'images/icon_tree_close.gif';
		}
		else
		{
			document.getElementById('menu_' + id).style.display = 'block';
			document.getElementById('menu_icon_' + id).src = TPL_PATH + 'images/icon_help_open.gif';
			document.getElementById('menu_bullet_' + id).src = TPL_PATH + 'images/icon_tree_open.gif';
		}
		
		document.getElementById('menu_' + id).open = !document.getElementById('menu_' + id).open;
	}
}

function goSearch(objForm)
{
	document.location = SITE_ROOT + LANG + '/search/?q=' + encodeURIComponent(objForm.q.value);
	return false;
}

function selectLanguage(obj)
{
    var dropdownIndex = obj.selectedIndex;
    var dropdownValue = obj[dropdownIndex].value;
    
    document.location = SITE_ROOT + dropdownValue + '/';
}


