$(document).ready(function(){

	$('#logo').flash({
		src: 'catalog/view/theme/default/media/logo.swf',
		width: 550,
		height: 87,
		wmode: 'transparent'
	});

	// Datepicker
	$('.datepicker').datepicker({
		dateFormat: 'dd-mm-yy'
	});
	
	$('a#login').click(function() {
		$('#login_box').show();
	});
	
	$(document).bind('click', function(e) {
		var $clicked = $(e.target); // get the element clicked                              
        
		if ( ! ( $clicked.is('#login') || $clicked.parents().is('#login') || $clicked.is('#login_box') || $clicked.parents().is('#login_box') ) )
		{
			$('#login_box').hide();
        }
    });
	
	
	
});



var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{  jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

$(document).ready(function()
{  $('#jsddm > li').bind('mouseover', jsddm_open)
   $('#jsddm > li').bind('mouseout',  jsddm_timer)});

document.onclick = jsddm_close;


function AfiseazaModel2(deunde)
{
  	if (deunde.id == "twomodel")
	{
	   $("#model2").show();
	}
	else
	   $("#model2").hide();
}

/**
 *
 * @access public
 * @return void
 **/
function AscundeMetodaPlata()
{
  var metoda = $('#pMethod').val();
	if (metoda == 1)
	{
	   	//alert("Metoda ="+metoda);
	   	$('#pay_method').hide();
	   	$('#bank_info').show();
	   	$('#account').show();
	   	$('#bank_name').show();
	   	$('#bank_country').show();
	   	$('#bank_city').show();
	   	$('#swift_code').show();
	}
	else
	  {
	    $('#pay_method').show();
	    $('#bank_info').hide();
	    $('#account').hide();
	   	$('#bank_name').hide();
	   	$('#bank_country').hide();
	   	$('#bank_city').hide();
	   	$('#swift_code').hide();
	  }
}

function afiseazaImag(model_id, imagine)
{
   var pars     = "model_id="+model_id+"&imagine="+imagine;
   var target   = $("#bigPicture");

   $.ajax({
	  	  type: 'POST',
		  url : 'ajax/afisImagine.php',
		  data: pars,
		  success: function(data)
		  {
			 target.html(data);
		  }
		});
}


function ParolaNoua(tip, id_cont)
{
   var pars     = "tip="+tip+"&id_cont="+id_cont;
   var target   = $("#");

   $.ajax({
	  	  type: 'POST',
		  url : 'ajax/ajax.php',
		  data: pars,
		  success: function(data)
		  {
			 target.html(data);
		  }
		});
}

function SetOffline(id_cont)
{
   var pars     = "actiune=setoffline&id_cont="+id_cont;
   var target   = $("#rezultat");

   $.ajax({
	  	  type: 'POST',
		  url : 'common/setoffline',
		  data: pars,
		  async: false,
		  success: function(data)
		  {
			 target.html(data);
		  }
		});
}

function SetPrivate(id_cont)
{
   var pars     = "actiune=setprivate&id_cont="+id_cont;
   var target   = $("#rezultat");

   $.ajax({
	  	  type: 'POST',
		  url : 'common/setprivate',
		  data: pars,
		  async: false,
		  success: function(data)
		  {
			 target.html(data);
		  }
		});
}

function seteazacookie()
{
   var pars     = "actiune=seteazacookie";
  
  
  /*
  if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  
  
   xmlhttp.open("GET","http://www.privatexcams.com/ajax/ajax.php?" + pars,true);
   xmlhttp.send();
    
	xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   		$('#dialog-modal').dialog('close');
    }
  }
	*/
	
   
	$.ajax({
	  	  type: 'POST',
		  url : 'http://www.privatexcams.com/ajax/ajax.php',
		  data: pars,
		  async: true,
		  cache: false,
		  success: function(data) {	
			 $('#dialog-modal').dialog('close');
		  }
	});
}


  $(function() {
		$("#datepicker").datepicker({
		dateFormat: 'yy-mm-dd'
	});
	});

$(function() {
		$('#customer_birthdate, #model_birthdate').datepicker({
			changeMonth: true,
			changeYear: true,
			dateFormat: 'dd-mm-yy',
			yearRange: '1900:2010'

		});
	});

function afiseaza_thumb(model_id)  // studio la click pe model live
{
    $(function() {

		$("#model_"+model_id).dialog({
		    autoOpen: false,
			resizable: false,
            //modal : true,
			width: 380,
			height: 360
		});
	});

   $("#model_"+model_id).dialog("open");
}

/**
 *
 * @access public
 * @return void
 **/
function afiseazaDialogContBlocat(){

   $(function() {
		$("#dialog-cont-blocat").dialog({
		    autoOpen: false,
			resizable: false,
            modal : true,
			width: 370,
			height: 410,
            buttons: {
				Close: function() {
					$(this).dialog('close');
				}
			}
		});
	});

   $("#dialog-cont-blocat").dialog("open");

}

function afisareProgramari(){

   $(function() {
		$("#dialog-programari").dialog({
		    autoOpen: false,
			resizable: false,
            modal : true,
			width: 370,
			height: 410,
            buttons: {
				Close: function() {
					$(this).dialog('close');
				}
			}
		});
	});

   $("#dialog-programari").dialog("open");

}
 
function getDateModel()
{
  var link = "http://www.privatexcams.com/index.php?route=information/information/loadInfo&create_contract=20";
  
  
  if ($("#tip_cont").val() == "studio") {
          var numestudio = $("#company_name").val();
		  var birthdate  = "not required for studio account"; 
		  var data_semnare = $("#data_semnare").val();	
          link+="&fullname="+numestudio+"&birthdate="+birthdate+"&data_semnare="+data_semnare;
  }
  else {
		  var fullname = $("#fullname").val();
		  var bday     = $("#birth_date_day").val();
		  var bmonth   = $("#birth_date_month").val();
		  var byear    = $("#birth_date_year").val();
		  var data_semnare = $("#data_semnare").val();
          var adresa   = $("#address").val();
          var oras     = $("#city").val();
          var tip_act  = $("#id_type option:selected").text();
		  var id_number = $("#id_number").val();
	 	  
          link+="&fullname="+fullname+"&birthdate="+bday+"/"+bmonth+"/"+byear+"&data_semnare="+data_semnare+"&adresa="+adresa+"&oras="+oras+"&tip_act="+tip_act+"&act_numar="+id_number;
  }
  $("#activare_cont").attr("href",link);
}

function actualizareImagContract() 
{
  $("#stare_contract").attr("src","catalog/view/theme/pxc2/image/contract_ok.png");
}

function AfisAscundeStele(model_id, operatie)
{
  switch(operatie)
  {
    case 1: // afisez
			$("#sus_"+model_id).show();
            break;	
	
	case 0: // ascund
            $("#sus_"+model_id).hide();
            break;			
  } 
}

