function showCard(cardId)
{
	$('ul#karty-vyber li#karta-' + cardId).css('z-index', '190');
	$('#holka-detail span#kkarta-7').css('display', 'none');
	$('#holka-detail span#kkarta-' + cardId).css('display', 'block');
	
}

function hideCard(cardId)
{
	$('ul#karty-vyber li#karta-' + cardId).css('z-index', cardId);
	$('#holka-detail span#kkarta-' + cardId).css('display', 'none');
	$('#holka-detail span#kkarta-7').css('display', 'block');
}

function showDialog(width, height, ovClose)
{

	if(ovClose == undefined)
		ovClose = true;

	$('#modal-window').css('width', width);
	$('#modal-window').css('height', height);

	$('#modal-window').modal({
		maxWidth: width,
		maxHeight: height,
		minWidth: width,
		minHeight: height,
		overlayClose: ovClose,
		overlayCss: {
			backgroundColor: '#000'
		}
	});
}

function checkVIP(escortcode)
{
	var dataString = "vipcode=" + $('#vipcode-text').val() + "&escortcode=" + escortcode;
	
	$.ajax({
	   type: 'POST',
	   url: baseUrl + 'ajax/checkvip',
	   dataType: "html",
	   data: dataString,
	   cache: false,
	   async: true,
	   success: function(j){
			if(j != "done")
			{
				$('#vipcode').html(j);
			}
		}
	 });
}

function checkPhotoVIP(photo)
{
	var dataString = "vipcode=" + $('#photocode-text').val() + "&photocode=" + photo;
	
	$.ajax({
	   type: 'POST',
	   url: baseUrl + 'ajax/checkphotovip',
	   dataType: "json",
	   data: dataString,
	   cache: false,
	   async: true,
	   success: function(j){
			if(j.message !== undefined){
				$('#photo-title-text').html(j.message);
			}
			else
			{
				if(j.url !== undefined)
					top.location = j.url;
			}
		}
	 });
}

function checkAccount()
{
	$.ajax({
	   type: 'POST',
	   url: baseUrl + 'ajax/checkaccount',
	   dataType: "json",
	   cache: false,
	   async: true,
	   success: function(j){
		  //alert(j);
			if(j.userOk == 0)
			{
				alert('Uživatel s tímto ID neexistuje!');
			}
			else if(j.userOk == 2)
			{
				alert('Nemáte dostatečné množství kreditů!');
			}
			
			if(j.userOk != 1)
			{
				top.location = 'http://www.srdcovadama.cz/hlavni/chat';
			}
		}
	 });
}

function checkChatCode(cid)
{
	var dataString = "vipcode=" + $('#vipcode-text').val() + "&cid=" + cid + "&smscode=" + $('#smscode-text').val();
	
	$('#code-error').html('Kódy se ověřují...');
	
	$.ajax({
	   type: 'POST',
	   url: baseUrl + 'ajax/checkchatcode',
	   dataType: "json",
	   data: dataString,
	   cache: false,
	   async: true,
	   success: function(j){

		   if(j.chatOk == 1)
		   {
			   top.location = 'http://www.srdcovadama.cz/hlavni/chat_on';
	       }
	       else if(j.vipOk == 3)
	       {
			  $('#code-error').html('Platnost VIP kódu vypršela!');
		   }
		   else if(j.vipOk == 4)
	       {
			  $('#code-error').html('VIP a SMS kód musí být ze stejného čísla!');
		   }
		   else if(j.smsOk == 0)
	       {
			  $('#code-error').html('Zadaný SMS kód neexistuje!');
		   }
		   else if(j.smsOk == 2)
	       {
			  $('#code-error').html('Platnost kódu již vypršela!');
		   }
		   
		}
	 });
}

function checkFreeAccess()
{
	var dataString = "vipcode=" + $('#vipcode-text').val();
	
	$('#code-error').html('Kód se ověřuje...');
	
	$.ajax({
	   type: 'POST',
	   url: baseUrl + 'ajax/checkfreeaccess',
	   dataType: "json",
	   data: dataString,
	   cache: false,
	   async: true,
	   success: function(j){

		   if(j.chatOk == 1)
		   {
			   top.location = 'http://www.srdcovadama.cz/hlavni/chat_on';
	       }
	       else if(j.vipOk == 0)
	       {
			  $('#code-error').html('Zadaný VIP kód neexistuje!');
		   }
	       else if(j.vipOk == 3)
	       {
			  $('#code-error').html('Platnost VIP kódu vypršela!');
		   }
		   else if(j.vipOk == 2)
	       {
			  $('#code-error').html('Tento VIP kód už byl pro vstup zdarma využit!');
		   }		   
		}
	 });
}

function showSurvey()
{
	$.ajax({
	   type: 'POST',
	   url: baseUrl + 'ajax/getsurveycode',
	   dataType: "html",
	   cache: false,
	   async: true,
	   success: function(j){
			if(j != "done")
			{
				$.modal.close();
				$('#modal-window').html(j);
				showDialog(350, 380);
			}
		}
	 });
}

function showNews()
{
	$.ajax({
	   type: 'POST',
	   url: baseUrl + 'ajax/getnewscode',
	   dataType: "html",
	   cache: false,
	   async: true,
	   success: function(j){
			if(j != "done")
			{
				$.modal.close();
				$('#modal-window').html(j);
				showDialog(350, 380, false);
			}
		}
	 });
}

function showHelp()
{
	$.ajax({
	   type: 'POST',
	   url: baseUrl + 'ajax/gethelpcode',
	   dataType: "html",
	   cache: false,
	   async: true,
	   success: function(j){
			if(j != "done")
			{
				$.modal.close();
				$('#modal-window').html(j);
				showDialog(550, 450);
			}
		}
	 });
}

function showChatInfo(ident)
{
	var dataString = 'chid=' + ident;
	
	$.ajax({
	   type: 'POST',
	   url: baseUrl + 'ajax/getchatinfo',
	   dataType: "html",
	   data: dataString,
	   cache: false,
	   async: true,
	   success: function(j){
			if(j != "done")
			{
				$.modal.close();
				$('#modal-window').html(j);
				showDialog(450, 480);
			}
		}
	 });
}


function showPhoto(ident)
{
	$.ajax({
	   type: 'POST',
	   url: baseUrl + 'ajax/getphoto',
	   dataType: "html",
	   cache: false,
	   async: true,
	   success: function(j){
			if(j != "done")
			{
				$.modal.close();
				$('#modal-window').html(j);
				$('#modal-window span.code').html(ident);
				showDialog(350, 280);
			}
		}
	 });
}

function showPhotoNew(ident)
{
	$.ajax({
	   type: 'POST',
	   url: baseUrl + 'ajax/getphotonew',
	   dataType: "html",
	   cache: false,
	   async: true,
	   success: function(j){
			if(j != "done")
			{
				$.modal.close();
				$('#modal-window').html(j);
				$('#modal-window span.code').html(ident);

				$('#modal-window #photocode-submit').live('click', function(){
					
					var dataString = "vipcode=" + $('#photocode-text').val() + "&photocode=" + ident;
	
					$.ajax({
					   type: 'POST',
					   url: baseUrl + 'ajax/checkphotovip',
					   dataType: "json",
					   data: dataString,
					   cache: false,
					   async: true,
					   success: function(j){
							if(j.message !== undefined){
								$('#photo-title-text').html(j.message);
							}
							else
							{
								if(j.url !== undefined)
									top.location = j.url;
							}
						}
					 });
				});

				showDialog(400, 400);
			}
		}
	 });
}


function showPhotoBg(ident, safecode, width, height)
{
	if(width < 1) {
		width = 700;
	}
	
	if(height < 1) {
		height = 525;
	}
	b_url = 'http://www.srdcovadama.cz/';
	
	$.ajax({
	   type: 'POST',
	   url: baseUrl + 'ajax/getphotonew',
	   dataType: "html",
	   cache: false,
	   async: true,
	   success: function(j){
			if(j != "done")
			{
				$.modal.close();
				$('#modal-window').html(j);
				$('#modal-window span.code').html(ident);

				$('#modal-window #photocode-submit').live('click', function(){
					
					var dataString = "vipcode=" + $('#photocode-text').val() + "&photocode=" + ident;
	
					$.ajax({
					   type: 'POST',
					   url: baseUrl + 'ajax/checkphotovip',
					   dataType: "json",
					   data: dataString,
					   cache: false,
					   async: true,
					   success: function(j){
							if(j.message !== undefined){
								$('#photo-title-text').html(j.message);
							}
							else
							{
								if(j.url !== undefined)
									top.location = j.url;
							}
						}
					 });
				});


				showDialog(width - 20, height - 20);
				$('#modal-window').css('background-image', 'url("' + b_url + 'safelinks/bg_downloads/' + safecode + '")');   
				$('.simplemodal-wrap').css('overflow', 'hidden');   
				$('.simplemodal-data').css('width', width - 50);   
				$('.simplemodal-data').css('height', height - 50);   
				
				$('#modal-window p.padded').css('font-size', '13px');    
				$('#modal-window p.padded small').css('font-size', '12px');   
				//alert(b_url + 'safelinks/bg_downloads/' + safecode);
			}
		}
	 });
}

function showPhotoBonus(girl, type)
{
	if(type == 1) {
		width = 525;
		height = 700;
	}
	else {
		width = 700;
		height = 525;
	}
	
	b_url = 'http://www.srdcovadama.cz/';
	
	$.modal.close();
	showDialog(width - 20, height - 20);
	$('#modal-window').css('background-image', 'url("' + b_url + 'css/images/bonus/' + girl + '.jpg")');   
	$('.simplemodal-wrap').css('overflow', 'hidden');   
	$('.simplemodal-data').css('width', width - 50);   
	$('.simplemodal-data').css('height', height - 50);   

}



function showEscort(ident)
{
	var dataString = 'eid=' + ident;
	
	$.ajax({
	   type: 'POST',
	   url: baseUrl + 'ajax/getescort/',
	   dataType: "html",
	   cache: false,
	   data: dataString,
	   async: true,
	   success: function(j){
			if(j != "done")
			{
				$.modal.close();
				$('#modal-window').html(j);
				showDialog(350, 300);
			}
		}
	 });
}

function showVIP()
{
	$.ajax({
	   type: 'POST',
	   url: baseUrl + 'ajax/getvip',
	   dataType: "html",
	   beforeSend: preloadDialog(),
	   cache: false,
	   async: true,
	   success: function(j){
			if(j != "done")
			{
				$.modal.close();
				$('#modal-window').html(j);
				showDialog(440, 380, false);
			}
		}
	 });
}

function showTerms()
{
	$.ajax({
	   type: 'POST',
	   url: baseUrl + 'ajax/gettermscode',
	   dataType: "html",
	   beforeSend: preloadDialog(),

	   cache: false,
	   async: true,
	   success: function(j){
			if(j != "done")
			{
				$.modal.close();
				$('#modal-window').html(j);
				showDialog(440, 500);
			}
		}
	 });
}

function preloadDialog()
{
	
	$('#modal-window').html('<p align="center">načítám...</p>');
	showDialog(100, 10);
}

function setSurvey()
{
	var dataString = "eroticke_servery=" + $("#modal-window input[name='eroticke_servery']:checked").val() + 
					 "&escorty=" + $("#modal-window input[name='escorty']:checked").val() + 
					 "&kluby=" + $("#modal-window input[name='kluby']:checked").val() + 
					 "&inspirace=" + $("#modal-window input[name='inspirace']:checked").val() +
					 "&autoerotika=" + $("#modal-window input[name='autoerotika']:checked").val() +
					 "&stahovani=" + $("#modal-window input[name='stahovani']:checked").val();
					 	
	$.ajax({
	   type: 'POST',
	   url: baseUrl + 'ajax/setsurvey',
	   dataType: "html",
	   data: dataString,
	   beforeSend: preloadDialog(),
	   cache: false,
	   async: true,
	   success: function(j){
			if(j != "done")
			{
				$.modal.close();
				$('#modal-window').html(j);
				showDialog(400,390, false);
			}
		}
	 });
}
