
// -- spust po nacteni
var photoHash = getHash().replace('#detailId','');
if (photoHash != ''){
	document.location.href=BASEURL+GALLERY_URL_PREFIX+'/show-image-detail/'+photoHash;
}


 //-----------------------------------------------------------------------------------

// --Sekce Kontakt 
function VyplnDotazFormAction()
{					  
	var FormElement = document.getElementById("PosliEmailForm");
	var email = document.getElementById("email").value;
	var BASEURL = document.getElementById("BASEURL").value;
	
	if (email == '@'){
		alert ('fill your correct email.');
		return false;
	}
	var NahodneCislo = Math.round((Math.random() * 20000)) * 8513; 
	
	if (FormElement != undefined){
		FormElement.action = BASEURL + 'tools/send_to_friend.php?AuthKey=' + NahodneCislo; 	
	}
	
}

 //-----------------------------------------------------------------------------------
 
function VyplnGBFormAction()
{					  
	var FormElement = document.getElementById("PosliEmailForm");
	var BASEURL = document.getElementById("BASEURL").value;
	var NahodneCislo = Math.round((Math.random() * 20000)) * 8513; 
	
	if (FormElement != undefined){
		FormElement.action = BASEURL + 'tools/add_mess.php?AuthKey=' + NahodneCislo; 	
	}
	
}
	//-----------------------------------------------------------------------------------
	 /**
		Otevira a zavira panel o predanem ID.
	 */
	function otevriPanel( divId ){
		
		div = document.getElementById(divId);
		if (div.style.display=='block') {
			$('#'+divId).hide();
		} else {
			$('#'+divId).show('fast');
		}
	}  
 //-----------------------------------------------------------------------------------
 
 
function initializeInputItem( defaultText, elementId ) {
	var value = document.getElementById(elementId).value;
	if (value == defaultText)
		document.getElementById(elementId).value = "";
	else if (value == "")
	    document.getElementById(elementId).value = defaultText;
	return false;    
}  

 //-----------------------------------------------------------------------------------
 
function send(formOrder)
{					  
	var FormElement = document.getElementById( formOrder );
	var paypalForm = document.getElementById( 'paypalForm' );
	var BASEURL = document.getElementById("BASEURL").value;
	var legal = document.getElementById("legal").checked;
	
//	if (email == '@'){
//		alert ('fill your correct email.');
//		return false;
//	}
	var NahodneCislo = Math.round((Math.random() * 20000)) * 8513; 
	
	if (checkFormDataForPayPalButton() == false){
		alert ('Please check the necessary items.');
		return false;
	}
	 
	if (legal) {
		if (FormElement != undefined){
			FormElement.action = BASEURL + 'tools/send_order.php?AuthKey=' + NahodneCislo; 	
			//test
		}
//		if (paypalForm != undefined){
//			paypalForm.action = ''; 	
//			paypalForm.submit();
//		}
//		var options = { 
//	        		dataType: 'xml',
//	        		success: paypalForm.submit(),
//		}; 
//		$('#formOrder').ajaxForm(options); 
		
		$('#formOrder').submit();
		
		return true;
		
	} else {
		document.getElementById("legalpolicy").style.color='red';
		alert ('Please check the legal policy.');
		return false;
	}
}
 //-----------------------------------------------------------------------------------
 
function changeHash(hash) {
	window.location.hash = hash;
}

function getHash() {
	return myHash = window.location.hash;
}

 //-----------------------------------------------------------------------------------
 
 function nactiAjax(id)
 {
 	id = parseInt(id);
//alert(id);
 	// -- NEFUNKCNI V IE :(
 	//------------------------------------------------------------
//	$.ajax({
//	      url: BASEURL+"tools/"+GALLERY_URL_BASE+"/ajax_roller.php?id="+id+"&type=pred",
//	      dataType: "html",	      
//	      type: "GET",
////	      success: function(msg){
////				if (msg == ''){
////					document.getElementById("b-prev").style.visibility='hidden';
////				} else {
////					document.getElementById("b-prev").style.visibility='visible';
////				}
////	      }
//	   }
//	).responseText;
//
//	//------------------------------------------------------------
// 	$.ajax({
//	      url: BASEURL+"tools/"+GALLERY_URL_BASE+"/ajax_roller.php?id="+id+"&type=next",
//	      dataType: "html",
//	      type: "GET",
//	      success: function(msg){
//			if (msg == ''){
//				document.getElementById("b-next").style.visibility='hidden';
//			} else {
//				document.getElementById("b-next").style.visibility='visible';
//			}
//	      }
//		}
//	).responseText;

	//------------------------------------------------------------
 	changeHash('detailId'+id);
	
	$("#AjaxDetail").load(BASEURL+"tools/"+GALLERY_URL_BASE+"/ajax_roller.php?id="+id+"&type=detail");
	$("#AjaxFlash").load(BASEURL+"tools/"+GALLERY_URL_BASE+"/ajax_roller.php?id="+id+"&type=flash");

	$("#AjaxPrev").load(BASEURL+"tools/"+GALLERY_URL_BASE+"/ajax_roller.php?id="+id+"&type=pred");
	$("#AjaxNext").load(BASEURL+"tools/"+GALLERY_URL_BASE+"/ajax_roller.php?id="+id+"&type=next");
	
	$.get(BASEURL+"tools/"+GALLERY_URL_BASE+"/ajax_roller.php?id="+id+"&type=pred",
				function(msg){
					if (msg == ''){
						document.getElementById("b-prev").style.visibility='hidden';
					} else {
						document.getElementById("b-prev").style.visibility='visible';
					}			  		
				}
	);
	
	$.get(BASEURL+"tools/"+GALLERY_URL_BASE+"/ajax_roller.php?id="+id+"&type=next",
				function(msg){
					if (msg == ''){
						document.getElementById("b-next").style.visibility='hidden';
					} else {
						document.getElementById("b-next").style.visibility='visible';
					}	
				}
	);	
	
	$.get(BASEURL+"tools/"+GALLERY_URL_BASE+"/ajax_roller.php?id="+id+"&type=flashX",
				function(msg){
						document.getElementById("AjaxFlash").style.width=msg+'px';
				}
	);	
	
	$.get(BASEURL+"tools/"+GALLERY_URL_BASE+"/ajax_roller.php?id="+id+"&type=flashY",
				function(msg){
						document.getElementById("AjaxFlash").style.height=msg+'px';
				}
	);	
	
	document.getElementById('b-add').href = BASEURL+"tools/"+GALLERY_URL_BASE+'/add_to_cart.php?photoId='+id;
//	$("#b-add").href=BASEURL+"tools/"+GALLERY_URL_BASE+'/add_to_cart.php?photoId='+id;
//	alert($("#b-add").href);
 }
 
 
 //------------------------------------------------------------
 	
 function changePayPalData($valueId, $paypalId)
 {
 	document.getElementById($paypalId).value = document.getElementById($valueId).value;
 }
 
 //------------------------------------------------------------
 	
 function checkFormDataForPayPalButton()
 {
 	adresa = document.getElementById('address').value;
 	jmeno = document.getElementById('name').value;
 	email = document.getElementById('email').value;
 	tel = document.getElementById('phone').value;
 	
 	if (jmeno == '' || email == ''){
 		return false;
 	} else {
		return true;
 	}
 }
 
 //------------------------------------------------------------
 
 function odkaz()
 {
 	
 }
//------------------------------------------------------------
// 
// zakaz praveho tlacitka mysi
    $(document).ready(function() {
        $("#web-container").css('display', 'block');
        $(document).bind('contextmenu', function(e) {
            return false;
        });
    });
//------------------------------------------------------------
 
 
