function Start(page) {
	b = "win_" + String(Math.round(Math.random() * 1000000));
	OpenWin = window.open(page, b, "toolbar=no,menubar=yes,location=no,directories=no, status=no,scrollbars=yes,resizable=yes,width=780,height=600,top=10,left=10");
	return true;
}

function StartSong(xsong) {
	b = "win_" + String(Math.round(Math.random() * 1000000));
	var page="song.asp?song="+xsong
	OpenWin = window.open(page, b, "toolbar=no,menubar=no,location=no,directories=no, status=no,scrollbars=no,resizable=no,width=147,height=117,top=10,left=10");
	return true;
}



//________________________________________________________________________________________________
//_____________________      goSubmM     _____________________________________________________________

function goSubmMy(page,groupCrt,ID){
		document.myform.page.value = page;
		document.myform.sCMD.value = "";
		document.myform.groupCrt.value = groupCrt;
		document.myform.ID.value = ID;
		document.myform.submit();
}


//________________________________________________________________________________________________
//_____________________      goBasketAdd     _____________________________________________________________

function goBasketAdd(ID,Cant_stoc,F5Application){
	var oForm = document.forms.myform;
	var nr = oForm.Quantity.value;

		oForm.sCMD.value = "add";
		oForm.cump.value = "cump";
		oForm.ProductID.value = ID;
		oForm.F5Application.value = F5Application;
		oForm.action = "Cart.asp";
		oForm.submit();
}


//________________________________________________________________________________________________
//_____________________      goDetaliu     _____________________________________________________________

function goDetaliu(ID,F5Application){
	var oForm = document.forms.myform;

	oForm.ID.value = ID;
	oForm.F5Application.value = F5Application;
	oForm.action = "ProdusDetaliu.asp";
	oForm.submit();
}


//________________________________________________________________________________________________
//_____________________      goBasketDel     _____________________________________________________________

function goBasketDel(ID,F5Application){

	if (confirm("Acest produs va fi sters din cosul de cumparatauri! Confirmati !?"))
		{
			document.myform.sCMD.value = "del";
			document.myform.PLU.value = ID;
			document.myform.F5Application.value = F5Application;
			document.myform.action = "Cart.asp";
			document.myform.submit();
		}
}


//________________________________________________________________________________________________
//_____________________      goKeep     _____________________________________________________________

function goKeep() {
		document.myform.action = "magazin.asp";
		document.myform.submit();
}


//________________________________________________________________________________________________
//_____________________      goEmail     _____________________________________________________________

function goEmail() {  
	var oForm = document.forms.myform;

	for (counter = 0; counter < oForm.Quantity.length; counter++){
		if (!(isWhitespace(oForm.Quantity[counter].value))) {
			if (isNumber1(oForm.Quantity[counter].value)==false) {
				oForm.Quantity[counter].focus();
				return false;
			}
		}
	}
	document.myform.q.value = 9;

	document.myform.action = "Cart.asp";
	document.myform.submit();
}


//________________________________________________________________________________________________
//_____________________      goEmailc     _____________________________________________________________

function goEmailc() {  
	var oForm = document.forms.myform;

	for (counter = 0; counter < oForm.Quantity.length; counter++){
		if (!(isWhitespace(oForm.Quantity[counter].value))) {
			if (isNumber1(oForm.Quantity[counter].value)==false) {
				oForm.Quantity[counter].focus();
				return false;
			}
		}
	}
	document.myform.q.value = 7;

	document.myform.action = "Cart.asp";
	document.myform.submit();
}


//________________________________________________________________________________________________
//_____________________      goAct     _____________________________________________________________

function goAct() {  
	var oForm = document.forms.myform;

 	if (isInt(oForm.Quantity.length)==true) {
		for (counter = 0; counter < oForm.Quantity.length; counter++){
			if (!(isWhitespace(oForm.Quantity[counter].value))) {
				if (isNumber1(oForm.Quantity[counter].value)==false) {
					oForm.Quantity[counter].focus();
					return false;
				}
			}
		}
	}
	else {
		if (!(isWhitespace(oForm.Quantity.value))) {
			if (isNumber1(oForm.Quantity.value)==false) {
				oForm.Quantity.focus();
				return false;
			}
		}
	}
	
		
		
    document.myform.q.value = 5;

	oForm.action = "Cart.asp";
	oForm.submit();
}


//________________________________________________________________________________________________
//_____________________      goActu     _____________________________________________________________

function goActu() {  
	var oForm = document.forms.myform;

 	if (isInt(oForm.Quantity.length)==true) {
		for (counter = 0; counter < oForm.Quantity.length; counter++){
			if (!(isWhitespace(oForm.Quantity[counter].value))) {
				if (isNumber1(oForm.Quantity[counter].value)==false) {
					oForm.Quantity[counter].focus();
					return false;
				}
			}
		}
	}
	else {
		if (!(isWhitespace(oForm.Quantity.value))) {
			if (isNumber1(oForm.Quantity.value)==false) {
				oForm.Quantity.focus();
				return false;
			}
		}
	}
	oForm.action = "ShoppingCart.asp";
	oForm.submit();
}

//________________________________________________________________________________________________
//_____________________      goBasketDell     _____________________________________________________________

function goBasketDell(ID,F5Application){

	if (confirm("Acest produs va fi sters din cosul de cumparatauri! Confirmati !?"))
		{
			document.myform.sCMD.value = "del";
			document.myform.PLU.value = ID;
			document.myform.F5Application.value = F5Application;
			document.myform.action = "ShoppingCart.asp";
			document.myform.submit();
		}
}

//________________________________________________________________________________________________
//_____________________      ValidBilling     _____________________________________________________________

function ValidBilling() {

	var oForm = document.forms.frmOrder;

	if (isWhitespace(oForm.BillingFirstName.value)) 
	{
			alert("Introduceti numele si prenumele dvs.!");
			oForm.BillingFirstName.focus();
			return false;
	}

	if (isWhitespace(oForm.BillingLastName.value)) 
	{
			alert("Introduceti numele si prenumele dvs.!");
			oForm.BillingLastName.focus();
			return false;
	}
	if (isWhitespace(oForm.BillingAddress.value)) 
	{
			alert("Introduceti adresa dvs.!");
			oForm.BillingAddress.focus();
			return false;
	}
	if (isWhitespace(oForm.BillingCity.value)) 
	{
			alert("Introduceti localitatea! ");
			oForm.BillingCity.focus();
			return false;
	}
	if (isWhitespace(oForm.BillingPhoneNo.value)) 
	{
			alert("Introduceti telefonul! ");
			oForm.BillingPhoneNo.focus();
			return false;
	 }

	if (oForm.BillingEmail.value.replace( / /g, "") == "")
	{
		alert("Introduceti adresa de Email! ");
		oForm.BillingEmail.focus();
		return false;
	}	if (oForm.BillingEmail.value.replace( / /g, "") != "")
	{
		var myEmail = NonSpace(oForm.BillingEmail.value);
		if (isEmail(myEmail)==false) {
			alert("Introduceti adresa de Email valida! ex: name@companyname.com ");
			oForm.BillingEmail.focus();
			return false;
		}  
	}	
	

	if ((oForm.SameD.checked)==false) { 
		if (isWhitespace(oForm.BillingFirstName.value)) 
		{
				alert("Introduceti numele si prenumele dvs.!");
				oForm.BillingFirstName.focus();
				return false;
		}

		if (isWhitespace(oForm.BillingLastName.value)) 
		{
				alert("Introduceti numele si prenumele dvs.!");
				oForm.BillingLastName.focus();
				return false;
		}
		if (isWhitespace(oForm.BillingAddress.value)) 
		{
				alert("Introduceti adresa dvs.!");
				oForm.BillingAddress.focus();
				return false;
		}
		if (isWhitespace(oForm.BillingCity.value)) 
		{
				alert("Introduceti localitatea! ");
				oForm.BillingCity.focus();
				return false;
		}
	}
	oForm.sCMD.value = "upd";
	return true;
}


//________________________________________________________________________________________________
//_____________________      ValidPrice     _____________________________________________________________

function ValidPrice() {
	var oForm = document.forms.myform;

	for (counter = 0; counter < oForm.Quantity.length; counter++){
		if (!(isWhitespace(oForm.Quantity[counter].value))) {
			if (isNumber1(oForm.Quantity[counter].value)==false) {
				oForm.Quantity[counter].focus();
				return false;
			}
		}
	}
}


//________________________________________________________________________________________________
//_____________________      goCaut     _____________________________________________________________

function goCaut() {
	var oForm = document.forms.frmSearch;

	if (isWhitespace(oForm.search.value) || (oForm.search.value=="... cautare")) 
	{
			alert("Introduceti produsul cautat!");
			oForm.search.focus();
			return false;
	}

	oForm.action = "Search.asp";

	oForm.submit();
}


//________________________________________________________________________________________________
//_____________________      goCautare     _____________________________________________________________

function goCautare() {
	var oForm = document.forms.myfrmSearch;

	if (isWhitespace(oForm.cod.value) && isWhitespace(oForm.produs.value) && ((oForm.categoria.value=="0" || oForm.categoria.value=="")) ) 
	{
			alert("Introduceti o cheie de cautare!");
			oForm.produs.focus();
			return false;
	}

}


//________________________________________________________________________________________________
//_____________________      goNewsletter     _____________________________________________________________

function goNewsletter() {
	var oForm = document.forms.frmEmail;

	if (isWhitespace(oForm.email.value) || (oForm.email.value=="... adresa de email")) 
	{
			alert("Introduceti adresa de email!");
			oForm.email.focus();
			return false;
	}
	if (oForm.email.value.replace( / /g, "") != "")
	{
		var myEmail = NonSpace(oForm.email.value);
		if (isEmail(myEmail)==false) {
			alert("Introduceti adresa de Email valida! ex: name@companyname.com ");
			oForm.email.focus();
			return false;
		}  
	}		
	oForm.action = "Newsletter.asp";
	oForm.submit();
}


//________________________________________________________________________________________________
//_____________________      BasketAddProd     _____________________________________________________________

function BasketAddProd(){
	var oForm = document.forms.myform;
	
	if (isWhitespace(oForm.Quantity.value)) 
	{
	     alert("Introduceti cantitatea!");
	     oForm.Quantity.focus();
	     return false;
	} 
	if (isNumber(oForm.Quantity.value)==false) {
		oForm.Quantity.focus();
		return false;
	}	
	if (isWhitespace(oForm.Cant_stoc.value)) 
	{
	     alert("Stocul este 0!");
	     oForm.Cant_stoc.focus();
	     return false;
	} 
	if (oForm.Quantity.value > oForm.Cant_stoc.value   ) 
	{
	     alert("Nu puteti cumpara o cantitate mai mare decat stocul!");
	     oForm.Quantity.focus();
	     return false;
	} 
	
	
    return true;
}



function isNum(chr)            // is character a number?
  {
  if (chr < "0" || chr > "9")  // nope
    return false;
  else                         // yep
    return true;
  }



function isNumber(InString)  {
        RefString="0123456789";

        for (Count=0; Count < InString.length; Count++)  {
            TempChar= InString.substring (Count, Count+1);
            if (RefString.indexOf (TempChar, 0)==-1) { 
				alert("Introduceti numai cifre: 0 - 9! ");
				return false;
			}
		}
        return true;
}



//________________________________________________________________________________________________
//_____________________      NonSpace     _____________________________________________________________

function NonSpace(field) {

	var xpos =0;
	var xlen =field.length;
	var xpos1 =0;
	var xpos2 =xlen;

	for (var i=0; i < xlen; i++) {
		temp = "" + field.substring(i, i+1);
		if (temp == " ") {xpos++;}
		else {var xpos1=xpos;break;  }
	}
	field = field.substring(xpos1, xlen)
	var xlen1 = field.length;

	for (var i=0; i < xlen1; i++) {
		temp = "" + field.substring(i, i+1);
		if (temp != " ") {xpos1++;}
		else {xpos2=i;break;  }
	}
	field = field.substring(0, xpos2)
	return field;
}



//________________________________________________________________________________________________
//_____________________      isEmail     _____________________________________________________________

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;
}


//____________________________________________________________________________________
//_____________     isWhitespace      ________________________________________________

var reWhitespace = /^\s+$/
// warnEmpty (theField, s)             Notify user that required field theField is empty.


// Notify user that required field theField is empty.
// String s describes expected contents of theField.value.
// Put focus in theField and return false.

function warnEmpty (theField, s)
{   theField.focus()
    alert(mPrefix + s + mSuffix)
    return false
}



// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}



// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s)

{   // Is s empty?
//    return (isEmpty(s));
    return (isEmpty(s) || reWhitespace.test(s));
}

function isInt(chr)           
{
	if (isNaN(chr))
	{return false; }
	else
	  {
		if (chr>0)
		{ return true;	}
		else
		  { return false; }	  
	   }
}

function isNumber1(InString)  {
        RefString="0123456789";

        for (Count=0; Count < InString.length; Count++)  {
            TempChar= InString.substring (Count, Count+1);
            if (RefString.indexOf (TempChar, 0)==-1) { 
				alert("Introduceti numai cifre: 0 - 9 ");
				return false;
			}
		}
        return true;
}
