/** Function buyos toolbox admin **/
$(document).ready(function(){
	$(".buyos_toolbox").hide();
	$(".buyos_content").hover(
		function () { /*$(this).children(".buyos_toolbox").show("fast");*/ }
	  , function () { $(this).children(".buyos_toolbox").hide(); }
	);
	$(".buyos_content > img").click(
		function () { $(this).parent().children(".buyos_toolbox").toggle("fast"); }
	);
	$(".buyos_add_section_toolbox").hide();
	$(".buyos_add_section > img").click(
		function () { $(this).parent().children(".buyos_add_section_toolbox").toggle("fast"); }
	);
});		
/** End **/

/** Function to fix IE6 menu dropdown **/
$(function() {  
	if ($.browser.msie && parseInt($.browser.version)< 7) {  
		$("#tabs li").hover(  
			function() {  
				$(this).addClass("sf");  
		},  
		function() {  
		$(this).removeClass("sf");  
		});  
	}  
}); 
/** End **/

/** Functii creeaza cont  **/


/** other functions date 

function writeDay(){
	for (var i=1;i<=31;i++) {
		document.write('<option value="'+i+'">'+i+'</option>')
	}
}

function writeMonth(){
	var months = new Array("Luna", "Ianuarie", "Februarie", "Martie", "Aprilie", "Mai", "Iunie", "Iulie", "August", "Septembrie", "Octombrie", "Noiembrie", "Decembrie");
	for (var m=1;m<=12;m++) {
		document.write('<option '+ (month1==m ? ' selected="selected" value="'+m+'" ' : 'value="'+m+'"') +'>'+months[m]+'</option>');
	}
}

function writeYear(){
	for (var y=1940;y<=2000;y++) {
		document.write('<option value="'+y+'">'+y+'</option>')
	}
}

**/

function validate_required(field,alerttxt) {
	field.value = (field.value).replace(/^\s*|\s*$/g,'');
	with (field) {
		if (value==null||value=="") {
			alert(alerttxt);
			return false;
		}
		else {
			return true;
		}
	}
}

function validate_email_creeaza(field,alerttxt) {
	with (field) {
		var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
	    if (document.accountForm._account_email.value.search(emailRegEx) == -1) {
			alert(alerttxt);
			return false;
	    }
		else {
			return true;
		}
	}
}

function validate_passwd(field,alerttxt,alerttxt2) {
	with (field) {
		if (document.accountForm._account_password.value.length < 6 ) {
			alert(alerttxt);
			return false;
	    }
		else if (document.accountForm._account_password.value !== document.accountForm._account_password2.value ){
			alert(alerttxt2);
			return false;
		}
		else {
			return true;
		}
	}
}

function validate_check(field,alerttxt,alerttxt2) {
	with (field) {
		if (document.accountForm._approve.checked == false) {
			alert(alerttxt);
			return false;
		}
		else if (document.accountForm._over_18.checked == false){
			alert(alerttxt2);
			return false;
		}
		else {
			return true;
		}
	}
}

function validate_form_creeaza(thisform) {
	with (thisform) {
		if (validate_required(_account_username,"Va rugam sa introduceti numele de utilizator!")==false) {
			_account_username.focus();
			return false;
		}
		if (validate_required(_account_password,"Va rugam sa introduceti parola!")==false) {
			_account_password.focus();
			return false;
		}
		if (validate_required(_account_password2,"Va rugam sa confirmati parola!")==false) {
			_account_password2.focus();
			return false;
		}
		if (validate_passwd(_account_password,"Parola trebuie sa aiba minim 6 caractere!","Confirmarea parolei nu este buna!")==false) {
			_account_password.focus();
			return false;
		}
		if (validate_required(_account_email,"Va rugam sa va introduceti adresa de e-mail!")==false) {
			_account_email.focus();
			return false;
		}
		if (validate_email_creeaza(_account_email,"Adresa de e-mail nu este valida!")==false) {
			_account_email.focus();
			return false;
		}
		if (validate_required(_account_firstname,"Va rugam sa introduceti numele!")==false) {
			_account_firstname.focus();
			return false;
		}
		if (validate_required(_account_lastname,"Va rugam sa introduceti prenumele!")==false) {
			_account_lastname.focus();
			return false;
		}
		if (validate_required(_account_day,"Va rugam selectati ziua!")==false) {
			_account_day.focus();
			return false;
		}
		if (validate_required(_account_month,"Va rugam selectati luna!")==false) {
			_account_month.focus();
			return false;
		}
		if (validate_required(_account_year,"Va rugam selectati anul!")==false) {
			_account_year.focus();
			return false;
		}
		if (validate_required(_account_cnp,"Va rugam sa introduceti Codul Numeric Personal!")==false) {
			_account_cnp.focus();
			return false;
		}
		if (validate_required(_account_identity_card_number,"Va rugam sa introduceti serie si numar CI!")==false) {
			_account_identity_card_number.focus();
			return false;
		}
			

		if (validate_required(_account_company_name,"Va rugam sa introduceti numele companiei!")==false) {
			_account_company_name.focus();
			return false;
		}
		if (validate_required(_account_address1,"Va rugam sa introduceti adresa completa!")==false) {
			_account_address1.focus();
			return false;
		}
		if (validate_required(_account_town,"Va rugam sa introduceti orasul!")==false) {
			_account_town.focus();
			return false;
		}	
		if (validate_required(_account_region,"Va rugam sa selectati judetul!")==false) {
			_account_region.focus();
			return false;
		}
		if (validate_required(_account_zip,"Va rugam sa introduceti codul postal!")==false) {
			_account_zip.focus();
			return false;
		}
		if (validate_required(_account_telephone,"Va rugam sa introduceti numarul de telefon!")==false) {
			_account_telephone.focus();
			return false;
		}

		
		if (validate_required(_account_registration_nr,"Va rugam sa introduceti numarul Registrul Comertului!")==false) {
			_account_registration_nr.focus();
			return false;
		}
		if (validate_required(_account_cui,"Va rugam sa introduceti Codul Unic Inregistrare!")==false) {
			_account_cui.focus();
			return false;
		}
		if (validate_required(_account_bank,"Va rugam sa introduceti numele bancii!")==false) {
			_account_bank.focus();
			return false;
		}
		if (validate_required(_account_bank_account,"Va rugam sa introduceti codul IBAN!")==false) {
			_account_bank_account.focus();
			return false;
		}		
		
		
		if(!verify('check'))
		{
			alert('Campurile marcate cu \' * \' sunt obligatorii!');
			return false;
		}
		if (validate_check(_approve,"Trebuie sa fiti de acord cu termenii si conditiile BuyOS.ro","Trebuie sa confirmati varsta de minim 18 ani!")==false) {
			_approve.focus();
			return false;
		}
	}
}

function verify(checkid){
var send = true;
var mesaj = '';
var focus;
var checkedElements = $('*', document.getElementById(checkid));

	for(i=0; i<checkedElements.length; i++)
	{
	
		if (checkedElements[i].tagName.toLowerCase() == 'input') 
		{ 
			if(checkedElements[i].getAttribute('rel'))
			{					
				if (checkedElements[i].getAttribute('rel').toLowerCase().indexOf("notblank") != -1)
				{	if(checkedElements[i].value == '')
					{	
						checkedElements[i].className="borderRosu";
						if(send) focus = checkedElements[i];
						send = false;
					}
				}
			}
		}
	}
	return send;
}

function checkAge()
{
	
	var now = new Date();

	var day=document.getElementById('_account_day').value;
	var month=document.getElementById('_account_month').value;
	var year=document.getElementById('_account_year').value;
	var birthdate=day+'/'+month+'/'+year;
	var birthdate2=month+'/'+day+'/'+year;
	
	document.getElementById('_acc_date_div').innerHTML = '<input type="hidden" name="_account_birth_date" id="_account_birth_date" value='+birthdate2+' />';
	
	var date_comp = birthdate.split('/');
	var birthday = new Date(date_comp[2],date_comp[1],date_comp[0]);
	
	if(Math.floor((now.getTime()-birthday.getTime())/(365*24*3600*1000)) < 18)
	{
	alert("Data introdusa nu corespunde\nTrebuie sa aveti 18 ani pentru a va crea cont");
	document.getElementById('over_18').checked=false;
	return false;
	}
}

function changeToOn(){
	if(document.getElementById('account_newsletter').value == 0) {
		document.getElementById('account_newsletter').value="on";
	} else {
		document.getElementById('account_newsletter').value = 0;
	}
}
/** End **/

/** Function to print order details   **/
function printContent(id){
str=document.getElementById(id).innerHTML
newwin=window.open('','printwin','scrollbars=1,left=100,top=100,width=620,height=500')
newwin.document.write('<html>\n<head>\n')
newwin.document.write('<title>Print Page</title>\n')
newwin.document.write('<link type="text/css" rel="stylesheet" href="/Buyos_Themes/Buyos_STORE/css/class.css" />\n')
newwin.document.write('<script>\n')
newwin.document.write('function chkstate(){\n')
newwin.document.write('if(document.readyState=="complete"){\n')
newwin.document.write('window.close()\n')
newwin.document.write('}\n')
newwin.document.write('else{\n')
newwin.document.write('setTimeout("chkstate()",2000)\n')
newwin.document.write('}\n')
newwin.document.write('}\n')
newwin.document.write('function print_win(){\n')
newwin.document.write('window.print();\n')
newwin.document.write('chkstate();\n')
newwin.document.write('}\n')
newwin.document.write('<\/script>\n')
newwin.document.write('</HEAD>\n')
newwin.document.write('<body onload="print_win()" style="background-color:#ffffff;">\n')
newwin.document.write(str)
newwin.document.write('</body>\n')
newwin.document.write('</html>\n')
newwin.document.close()
}
/** End **/

/** Functions noutati stiri **/
function articleDate(str){
	var finalDate = str.substr(0,10)
	document.write(finalDate);
}
/** End **/

/** Functions cart **/
function itemUpdate(x) {
	var id=document.getElementById('itemid_'+x).value;
	var q=document.getElementById('itemnr_'+x).value;
	document.getElementById('_cart_action').value="Update";
	document.getElementById('_cart_item_id').value=id;
	document.getElementById('_cart_item_nr').value=q;
	document.getElementById('_cart_item_index').value=x;
	document.getElementById('cartForm').submit();
}

function itemUpdateTaxa(x) {
	var id=document.getElementById('itemid_'+x).value;
	var q=document.getElementById('itemnr_'+x).value;
	document.getElementById('_cart_action').value="Update";
	document.getElementById('_cart_item_id').value=id;
	document.getElementById('_cart_item_nr').value=q;
	document.getElementById('_cart_item_index').value=x;
	document.getElementById('cartForm').action="/cart.aspx";	
	document.getElementById('cartForm').submit();
}

function itemDelete(x) {
	var id=document.getElementById('itemid_'+x).value;
	document.getElementById('_cart_action').value="Delete";
	document.getElementById('_cart_item_id').value=id;
	document.getElementById('_cart_item_index').value=x;
	document.getElementById('cartForm').submit();
}

function itemDeleteMultiple(idx,id_pachet,idx2,id_taxa) {
	var temp=idx+','+id_pachet+','+idx2+','+id_taxa;
	document.getElementById('_cart_action').value="DeleteMultiple";
	document.getElementById('_string_pid_q').value=temp;
	document.getElementById('cartForm').submit();
}

function UpdateTotalSum() {
	document.getElementById('_cart_action').value="UpdateTotal";
	document.getElementById('cartForm').submit();
}

function verifyRadio(checkid){
  	var checkedElements = document.getElementById(checkid).getElementsByTagName('input');
  	var ischecked=false;
  	for(i=0; i<checkedElements.length; i++)
	{
  		if((checkedElements[i].type=="radio") &&  checkedElements[i].checked)
  		ischecked=true;		
  	}
  	return ischecked; 	
}

function checkoutClick(msg1) {
	if(document.getElementById("_is_demo").value == "true"){
		if(document.getElementById("_payment_method_type").value == "Demo"){
			document.getElementById('cartForm').action='/creeaza_demo.aspx';
			document.getElementById('cartForm').submit();
			return true;
		}
	}
	else {

		var sw=0;	
		if((!verifyRadio("box_payment")) && (sw==0)){
			alert(msg1);
			sw=1;
		}
		if(sw==0){	
			var checkedElements = document.getElementById("box_payment").getElementsByTagName('input');
			var payment_type = "";
			for(i=0; i<checkedElements.length; i++)
			{
				if((checkedElements[i].type=="radio") &&  checkedElements[i].checked)
					payment_type = checkedElements[i].value;
			}
			
			if(payment_type == "OnlinePayment") document.getElementById('cartForm').action='/creeaza_site.aspx';
			else  document.getElementById('cartForm').action='/creeaza_site_transfer_bancar.aspx';
			document.getElementById('cartForm').submit();

			return true;
		}
	}
}
function checkoutClickWithoutAction(msg1) {
	var sw=0;	
	if((!verifyRadio("box_payment")) && (sw==0)){
		alert(msg1);
		sw=1;
	}
	if(sw==0){	
		var checkedElements = document.getElementById("box_payment").getElementsByTagName('input');
		var payment_type = "";
		for(i=0; i<checkedElements.length; i++)
		{
			if((checkedElements[i].type=="radio") &&  checkedElements[i].checked)
				payment_type = checkedElements[i].value;
		}
			
		document.getElementById('cartForm').submit();

		return true;
	}
}

/** End **/

/** Functions domenii **/
function getBuyosDomain() {
	var domain = document.getElementById('domain_buyos_name').value;
	if (domain !== "") {
		var tmp = domain + '.buyos.ro';
		document.getElementById('_current_buyos_domain').value = tmp;
		return true;
	}
	return false;
}

function buyosDomainClick() {
	var sw = 0;
	document.getElementById('domain_buyos_name').value = (document.getElementById('domain_buyos_name').value).replace(/^\s*|\s*$/g,'');
	if ((document.getElementById('domain_buyos_name').value.length == 0)&&(sw==0) || document.getElementById('domain_buyos_name').value == "nume domeniu") {
		alert('Va rugam introduceti domeniul dorit! \n');
		document.getElementById('domain_buyos_name').focus();
		sw=1;
	}
	if (sw==0) {
		submitDomainForm();
	}
}

function buyosDomainHitEnter(e) {
	var keynum;
	if(window.event) // IE
	{
		keynum = e.keyCode;
	} else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}
	if (keynum == 13) {
		getBuyosDomain();
		buyosDomainClick();
		return false;
	}
	return true;
}   

function getDomain() {
	var domain = document.getElementById('domain_hostway_name').value;

	if (domain !== "") {
	
		var tmp = domain + document.getElementById('dom_select')[document.getElementById('dom_select').selectedIndex].value;
		document.getElementById('_current_domain').value = tmp;
		return true;
	}
	return false;
}

function domainClick() {
	var sw = 0;
	
	document.getElementById('mydomain_name1').value = "";
	document.getElementById('mydomain_name2').value = "";
	document.getElementById('mydomain_name3').value = "";

	document.getElementById('domain_hostway_name').value = (document.getElementById('domain_hostway_name').value).replace(/^\s*|\s*$/g,'');
	if ((document.getElementById('domain_hostway_name').value.length == 0)&&(sw==0) || document.getElementById('domain_hostway_name').value == "nume domeniu") {
		alert('Va rugam introduceti domeniul dorit! \n');
		document.getElementById('domain_hostway_name').focus();
		sw=1;
	}
	if (sw==0) {
		submitDomainForm();
	}
}

function newDomainHitEnter(e) {
	var keynum;
	if(window.event) // IE
	{
		keynum = e.keyCode;
	} else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}
	if (keynum == 13) {
		getDomain();
		domainClick();
		return false;
	}
	return true;
}  

function myDomainClick() {
	document.getElementById('_current_domain').value = "clear";
	
	submitDomainForm();
}

function myDomainHitEnter(e) {
	var keynum;
	if(window.event) // IE
	{
		keynum = e.keyCode;
	} else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}
	if (keynum == 13) {
		myDomainClick();
		return false;
	}
	return true;
}  

function anuleazaClick() {
	document.getElementById('_current_domain').value = "clear";
	document.getElementById('mydomain_name1').value = "";
	document.getElementById('mydomain_name2').value = "";
	document.getElementById('mydomain_name3').value = "";

	submitDomainForm();
	
	return true;
}

function submitDomainForm(){
	document.getElementById('buyosDomainFrom').action="/domenii.aspx";
	document.getElementById('buyosDomainFrom').submit();
}

function addToCartClick(products) {
	if(products.length <= 0) {
		alert("Trebuie sa adaugati minim un produs");
		return;
	}
	
	document.getElementById('cart_pid').value=products;
	document.getElementById('buyosDomainFrom').action="/cart.aspx";
	document.getElementById('buyosDomainFrom').submit();
}

$(document).ready(function(){
	/* cumpara domeniu */
	$("#buy_domain").click(function () {
		$("#casute").slideToggle("fast");
		var temp=document.getElementById('casute').style.display;
		if(temp=='block') {
			$("#casuta_buy").toggle("slow");
		}
	});

	/* am domeniu */
	$("#has_domain").click(function () {
		$("#casute").slideToggle("fast");
		var temp=document.getElementById('casute').style.display;
		if(temp=='block') {
			$("#casuta_has").toggle("slow");
		}
	});

});

/** End **/

/** Functions promovare.aspx si module_aditionale.aspx **/
 function limitStr(str,limitNum){
	var end=' ...'
	document.write(str.substr(0,limitNum) + end);
 }
 
function onCheckModule(x){
	if (document.getElementById('check_'+x).value == 0) {
		document.getElementById('check_'+x).value = 1+']'+x+','+1;
	} else {
		document.getElementById('check_'+x).value = 0;
	}
}

/** End **/

/** Functions preturi.aspx **/
function isInteger(s) {
	var i;
	if (isEmpty(s))
	if (isInteger.arguments.length == 1) return 0;
	else return (isInteger.arguments[1] == true);
	for (i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if (!isDigit(c) || (i==0 && c=="0")) return false;
	}
	return true;
}
function isEmpty(s) {
	return ((s == null) || (s.length == 0))
}
function isDigit (c) {
	return ((c >= "0") && (c <= "9"))
}
function validateIntPachete(pid) {	
	document.getElementById('cart_pid_q').value=pid;
	document.getElementById('cartForm').action="/cart.aspx";
	document.getElementById('cartForm').submit();
}
/** End **/

/** Functions buyos_edit_account.aspx **/

function validate_email(field,alerttxt) {
	with (field) {
		var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
	    if (document.accountForm._account_email.value.search(emailRegEx) == -1) {
			alert(alerttxt);
			return false;
	    }
		else {
			return true;
		}
	}
}

function validate_form_edit_account(thisform) {
	with (thisform) {
		if(document.getElementById('_account_password').value!="" || document.getElementById('_account_password').value!="" && document.getElementById('_account_old_password').value!="") {
			if (validate_required(_account_old_password,"Va rugam sa introduceti parola curenta!")==false) {
				_account_old_password.focus();
				return false;
			}
			if (validate_required(_account_password,"Va rugam sa introduceti parola!")==false) {
				_account_password.focus();
				return false;
			}
			if (validate_required(_account_password2,"Va rugam sa confirmati parola!")==false) {
				_account_password2.focus();
				return false;
			}
			if (validate_passwd(_account_password,"Parola trebuie sa aiba minim 6 caractere!","Confirmarea parolei nu este buna!")==false) {
				_account_password.focus();
				return false;
			}
		}
		if (validate_required(_account_email,"Va rugam sa va introduceti adresa de e-mail!")==false) {
			_account_email.focus();
			return false;
		}
		if (validate_email(_account_email,"Adresa de e-mail nu este valida!")==false) {
			_account_email.focus();
			return false;
		}
		if (validate_required(_account_firstname,"Va rugam sa introduceti numele!")==false) {
			_account_firstname.focus();
			return false;
		}
		if (validate_required(_account_lastname,"Va rugam sa introduceti prenumele!")==false) {
			_account_lastname.focus();
			return false;
		}
		if (validate_required(_account_day,"Va rugam selectati ziua!")==false) {
			_account_day.focus();
			return false;
		}
		if (validate_required(_account_month,"Va rugam selectati luna!")==false) {
			_account_month.focus();
			return false;
		}
		if (validate_required(_account_year,"Va rugam selectati anul!")==false) {
			_account_year.focus();
			return false;
		}
		if (validate_required(_account_cnp,"Va rugam sa introduceti Codul Numeric Personal!")==false) {
			_account_cnp.focus();
			return false;
		}
		if (validate_required(_account_identity_card_number,"Va rugam sa introduceti serie si numar CI!")==false) {
			_account_identity_card_number.focus();
			return false;
		}
		if (validate_required(_account_company_name,"Va rugam sa introduceti numele companiei!")==false) {
			_account_company_name.focus();
			return false;
		}
		if (validate_required(_account_address1,"Va rugam sa introduceti adresa completa!")==false) {
			_account_address1.focus();
			return false;
		}
		if (validate_required(_account_town,"Va rugam sa introduceti orasul!")==false) {
			_account_town.focus();
			return false;
		}	
		if (validate_required(_account_region,"Va rugam sa selectati judetul!")==false) {
			_account_region.focus();
			return false;
		}
		if (validate_required(_account_zip,"Va rugam sa introduceti codul postal!")==false) {
			_account_zip.focus();
			return false;
		}
		if (validate_required(_account_telephone,"Va rugam sa introduceti numarul de telefon!")==false) {
			_account_telephone.focus();
			return false;
		}
		if (validate_required(_account_registration_nr,"Va rugam sa introduceti numarul Registrul Comertului!")==false) {
			_account_registration_nr.focus();
			return false;
		}
		if (validate_required(_account_cui,"Va rugam sa introduceti Codul Unic Inregistrare!")==false) {
			_account_cui.focus();
			return false;
		}
		if (validate_required(_account_bank,"Va rugam sa introduceti numele bancii!")==false) {
			_account_bank.focus();
			return false;
		}
		if (validate_required(_account_bank_account,"Va rugam sa introduceti codul IBAN!")==false) {
			_account_bank_account.focus();
			return false;
		}		
		if(!verify('check'))
		{
			alert('Campurile marcate cu \' * \' sunt obligatorii!');
			return false;
		}
		if (validate_check(_approve,"Trebuie sa fiti de acord cu termenii si conditiile BuyOS.ro","Trebuie sa confirmati varsta de minim 18 ani!")==false) {
			_approve.focus();
			return false;
		}
	}
}



function windowTerms() {
mywindow = window.open ("/termeni_si_conditii.aspx","mywindow","location=0,status=0,scrollbars=1");
mywindow.moveTo(0,0);
} 
/** End **/

/** Functions functionalitati.aspx **/
function getDiv(str)
{

var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
var x = document.getElementById('prod_'+str).childNodes;


	for (var i = 0; i < x.length; i++) 
	{
		if ( x[i].nodeType==1 ) {
		//alert (x[5].value);
			if ((browser == "Microsoft Internet Explorer") && (version>=4)) {
				document.getElementById('_titleA').innerHTML = x[0].value 
				document.getElementById('descriptionDiv').innerHTML = x[2].value 
			}
		    else {
				document.getElementById('_titleA').innerHTML = x[1].value 
				document.getElementById('descriptionDiv').innerHTML = x[3].value 
			}
		
		}
	}
}

function getDivContent(txt)
{
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
var y = document.getElementById(txt).childNodes;
	for (var j = 0; j < y.length; j++) 
	{
		if ( y[j].nodeType==1 ) {
		//alert (x[5].value);
			if ((browser == "Microsoft Internet Explorer") && (version>=4)) {
				document.getElementById('divContentA').innerHTML = y[4].value
			}
		    else {
				document.getElementById('divContentA').innerHTML = y[5].value
			}
		
		}
	}
}

/** End **/

/** Functions user_login.aspx **/
function validate_required_login(field,alerttxt) {
	field.value = (field.value).replace(/^\s*|\s*$/g,'');
	with (field) {
		if (value==null||value=="") {
			alert(alerttxt);
			return false;
		}
		else {
			document.getElementById('actType').value="forgotPass";	
			return true;
		}
	}
}

function validate_form_login(thisform) {
	with (thisform) {
		if (validate_required_login(_username,"Va rugam sa va introduceti userul!")==false) {
			_username.focus();
			return false;
		} 
		if (validate_required_login(_password,"Va rugam sa va introduceti parola!")==false) {
			_password.focus();
			return false;
		} 
	}	
}

function doLogin() {
	document.getElementById('actType').value="login";
	document.getElementById('loginForm').submit();
}

function doLogout() {	
	document.getElementById('actType').value="logout";
	document.getElementById('loginForm').submit();	
}

function isEmail(string)
{
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
	return true;
	else
	return false;
}

function doForgotPass() {
	if(isEmail(document.getElementById('emailForgotPass').value)){
	document.getElementById('actType').value="forgotPass";	
	document.getElementById('loginForm').action='/am_uitat_parola.aspx';
	document.getElementById('loginForm').submit();	
} else {
	alert('Va rugam sa introduceti o adresa de email valida!');
	return false;	
	}
}

$(document).ready(function(){
	$("#button_hide").click(function () {
		$("#mainLogDiv").slideToggle("fast");
		var temp=document.getElementById('mainLogDiv').style.display;
		if(temp=='block') {
			$("#mainForgotDiv").toggle("fast");
		}
	});
});

$(document).ready(function(){
	$("#button_hide2").click(function () {
		$("#mainForgotDiv").hide();
		var temp=document.getElementById('mainLogDiv').style.display;
		if(temp=='none') {
			$("#mainLogDiv").toggle("slow");
		}
	});
});

/** End **/

/** Functions product_detail.aspx **/
function validateIntMod(pid){	
	document.getElementById('cart_pid_q').value = pid;
	document.getElementById('demoForm').action="/cart.aspx";
	document.getElementById('demoForm').submit();
}
/** End **/

/** Functions design.aspx **/
function validateIntDesign(pid)
{	
	var o = document.getElementById('_cart_nr');
	switch (isInteger(o.value)) {
		case true:
				if(pid > '0')
				{
					document.getElementById('cart_pid').value=pid;
					document.getElementById('cartForm').action="/cart.aspx";
					document.getElementById('cartForm').submit();

				}
			break;
		case false:
			document.getElementById('cartForm').action="/design.aspx";
			alert("Trebuie sa adaugati minim un produs")
	}
}
/** End **/

/** Functions contact forms **/
function doHitEnter(e) {
	var keynum;
	if(window.event) { // IE
	keynum = e.keyCode;
} else if(e.which) { // Netscape/Firefox/Opera
	keynum = e.which;
}
if (keynum == 13){
	return false;
}
	return true;
}

function contact_form() { 
	var sw=0;
	
	if ((document.getElementById('_ask_name').value.length == 0))
	{
		alert('Va rugam introduceti numele! \n');
		document.getElementById('_ask_name').focus();
		sw=1;
		return false;
	}
	if (isEmail(document.getElementById('_ask_email').value) == false && (sw==0)) {
		alert('Va rugam introduceti o adresa de e-mail valida! \n');
		document.getElementById('_ask_email').focus();
		sw=1;
		return false;
	}
	if ((document.getElementById('_ask_subject').value.length == 0))
	{
		alert('Va rugam introduceti subiectul! \n');
		document.getElementById('_ask_subject').focus();
		sw=1;
		return false;
	}
	if ((document.getElementById('_ask_issue').value.length == 0))
	{
		alert('Va rugam sa selecati ce fel de utilizator sunteti! \n');
		document.getElementById('_ask_issue').focus();
		sw=1;
		return false;
	}
	if ((document.getElementById('_ask_message').value.length == 0)&&(sw==0)) {
		alert('Va rugam introduceti mesajul! \n');
		document.getElementById('_ask_message').focus();
		sw=1;
		return false;
	}
		
	if (sw==0) {
		document.getElementById('askForm').submit();

	}
	else {
		alert('Error!');
	}
}

function contact_form_report_bug() { 
	var sw=0;
	
	if ((document.getElementById('_report_name').value.length == 0))
	{
		alert('Va rugam introduceti numele! \n');
		document.getElementById('_report_name').focus();
		sw=1;
		return false;
	}
	if (isEmail(document.getElementById('_report_email').value) == false && (sw==0)) {
		alert('Va rugam introduceti o adresa de e-mail valida! \n');
		document.getElementById('_report_email').focus();
		sw=1;
		return false;
	}
	if ((document.getElementById('_report_subject').value.length == 0))
	{
		alert('Va rugam introduceti subiectul! \n');
		document.getElementById('_report_subject').focus();
		sw=1;
		return false;
	}
	if ((document.getElementById('_report_issue').value.length == 0))
	{
		alert('Va rugam sa selecati ce fel de utilizator sunteti! \n');
		document.getElementById('_report_issue').focus();
		sw=1;
		return false;
	}
	if ((document.getElementById('_report_message').value.length == 0)&&(sw==0)) {
		alert('Va rugam introduceti mesajul! \n');
		document.getElementById('_report_message').focus();
		sw=1;
		return false;
	}
	if ((document.getElementById('_report_bug').value.length == 0)&&(sw==0)) {
		alert('Va rugam faceti upload la poza cu eroare! \n');
		document.getElementById('_report_bug').focus();
		sw=1;
		return false;
	}
		
	if (sw==0) {
		document.getElementById('askForm').submit();

	}
	else {
		alert('Error!');
	}
}

function contact_form_general() { 
	var sw=0;
	
	if ((document.getElementById('_name_form').value.length == 0))
	{
		alert('Va rugam introduceti numele! \n');
		document.getElementById('_name_form').focus();
		sw=1;
		return false;
	}
	if (isEmail(document.getElementById('_email_form').value) == false && (sw==0)) {
		alert('Va rugam introduceti o adresa de e-mail valida! \n');
		document.getElementById('_email_form').focus();
		sw=1;
		return false;
	}
	if ((document.getElementById('_subject_form').value.length == 0))
	{
		alert('Va rugam introduceti subiectul! \n');
		document.getElementById('_subject_form').focus();
		sw=1;
		return false;
	}
	if ((document.getElementById('_message_form').value.length == 0)&&(sw==0)) {
		alert('Va rugam introduceti mesajul! \n');
		document.getElementById('_message_form').focus();
		sw=1;
		return false;
	}
		
	if (sw==0) {
		document.getElementById('_send_form_contact').submit();

	}
	else {
		alert('Error!');
	}
}
/** End **/

/** Functions newsletter **/

function bug(){
	if((document.getElementById('_username')!=null) && (document.getElementById('_username').value=="username")){
		document.getElementById('_username').value="";
	 	document.getElementById('_password').value="";
	}
}

function newsletter(exists)
	{ 
		bug();
		var sw=0;

		if (document.getElementById('subscription_email').value.length == 0)
		{
			alert('Va rugam sa va introduceti adresa de e-mail! \n');
			document.getElementById('subscription_email').focus();
			sw=1;
		} 
		if ((document.getElementById('subscription_email').value == 'adresa de e-mail')&&(sw==0))
		{
			alert('Va rugam sa va introduceti adresa de e-mail! \n');
			document.getElementById('subscription_email').focus();
			sw=1;
		} 		 
		if ((isEmail(document.getElementById('subscription_email').value) == false)&&(sw==0))
		{
			alert('Va rugam sa introduceti o adresa de e-mail valida! \n');
			document.getElementById('subscription_email').focus();
			sw=1;
		}
	if (sw==0)
	{
		document.getElementById('newsletter').submit();
	}
}

function doNewsHitEnter(e)
{
 var keynum;

 if(window.event) // IE
 {
 keynum = e.keyCode;
 }
 else if(e.which) // Netscape/Firefox/Opera
 {
 keynum = e.which;
 }
 if (keynum == 13){
	newsletter();
 return false;
 }
 return true;
}
/** End **/


