//javascript functions used in project

/* font resize */
/*FONT RESIZE*/
var min=11;
var max=16;
function increaseFontSize() {
   var p = document.getElementById('contentLay');
   var s = parseInt(p.style.fontSize.replace("px",""));
   if(s!=max)
   	s = s+1;
      
   p.style.fontSize = s+"px"
   
}
function decreaseFontSize() {
  var p = document.getElementById('contentLay');
   var s = parseInt(p.style.fontSize.replace("px",""));

   if(s!=min)
   	s = s-1;

     p.style.fontSize = s+"px"

}

/*FORM DEFAULT TEXT EFFECTS*/
function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}

function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}

/*playing with divs*/
function showDiv(divID) {
	var div = document.getElementById(divID);
	div.style.visibility = "visible";
}

function hideDiv(divID) {
	var div = document.getElementById(divID);
	div.style.visibility = "hidden";
}

function clearBox(box) {
	if(box.value==box.defaultValue) {
		box.value = "";
	}
}

function bookmarksite(title, link){
	if(!title)
		title = document.title;
	if(!link)
		link = location.href;
	
	if (document.all)
		window.external.AddFavorite(link, title);
	else if (window.sidebar)
		window.sidebar.addPanel(title, link, "");
	else if(window.opera && window.print)
		return true;
}

/* ajax */
var xmlHttp=null;
function GetXmlHttpObject() {
	try {
		xmlHttp=new XMLHttpRequest();	// Firefox, Opera 8.0+, Safari
	} catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	return xmlHttp;
}

function showSubMenu(id) {
//	changeWindowHtml('<div style="text-align: center; padding: 14px;"><img src="loading.gif" /></div>');
	ajax.get('ajax/sub_menu.php?id='+id,changeSubMenuHtml);
}
function changeSubMenuHtml(text) {
	document.getElementById("subMenu").innerHTML = text;
}

function showCalendar(monthCount) {
	ajax.get('ajax/calendar.php?monthCount='+monthCount, changeCalendarHtml);
}
function changeCalendarHtml(text) {
	document.getElementById("calendar").innerHTML = text;
}


function showBaloon(div) {
	$('#house_'+div).show("fast"); 
}
function hideBaloon(div) {
	$('#house_'+div).hide("fast"); 
}

function showHideDiv(divID) {
	$(divID).slideToggle("fast");
}

function newsletterPrijava() {
	email = $('#nl_email').val();
	$.get("newsletter.php?type=prijava&email="+email, function(data) {
		$('#newsletter_result').html(data);
	});
}
function newsletterOdjava() {
	email = $('#nl_email').val();
	$.get("newsletter.php?type=odjava&email="+email, function(data) {
		$('#newsletter_result').html(data);
	});
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function openWindow(url,height,width){
	window.open(url,'','scrollbars=no,menubar=no,width='+width+',height='+height+',resizable=no,toolbar=no,location=no,status=no');
}

function search_textbox_keypress(e)
{
	var e = window.event || e;
	var keyunicode = e.charCode || e.keyCode;
	if (keyunicode == 13) search();
}
function search_textbox_focus(textbox)
{
	if (textbox.value == "Vpiši iskalni niz domene")
		textbox.value = "";
}
function search_textbox_blur(textbox)
{
	if (textbox.value == "")
		textbox.value = "Vpiši iskalni niz domene";
}

function changeLogin(id) {
	$("#login").hide();
	$("#newpass").hide();
	$("#register").hide();
	
	$("#"+id).show();
}

function search() {
	string = $("#search_textbox").val();
	$("#innerContent").load("search.php?s="+string, {}, function() {});
}

function changeOrder(ordby, ord) {
	if ($("#search_textbox").val() == "Vpiši iskalni niz domene")
		string = "";
	else
		string = $("#search_textbox").val();
		
	$("#innerContent").load("search.php?s="+string+"&ordby="+ordby+"&ord="+ord, {}, function() {});
}

function changeUserOrder(ordby, ord) {		
	$("#userDomains").load("user_items.php?ordby="+ordby+"&ord="+ord, {}, function() {});
}

function registerUser() {
	email = $('#reg_email').val();
	$("#registerText").load("register.php?email="+email, {}, function() {});
}

function sendNewPassword() {
	email = $('#newpass_email').val();
	$("#newPassText").load("newpass.php?email="+email, {}, function() {});
}
function addDomain() {
	nocheck = '0';
	domain = $('#domain_title').val();
	if($('#no_email_check').is(':checked'))
		nocheck = '1';
	$.ajax({
		url: 'check_domain.php?domain='+domain+'&nocheck='+nocheck,
		success: function(data) {
			if(data == "true")
				$('#domainform').submit();
			else
				$('#addDomainText').html(data);
		}
	});
	return false;
}

function loadPagerank(id, domain) {
	setTimeout('loadPagerank1('+id+', \''+domain+'\')', 100);
}
function loadPagerank1(id, domain) {
	$("#domainpr_"+id).load("pagerank.php?url="+domain, {}, function() {});
}

function login_email_textbox_focus(textbox)
{
	if (textbox.value == "E-Mail")
		textbox.value = "";
}
function login_email_textbox_blur(textbox)
{
	if (textbox.value == "")
		textbox.value = "E-Mail";
}
function login_pass_textbox_focus(textbox)
{
	if (textbox.value == "Geslo")
		textbox.value = "";
}
function login_pass_textbox_blur(textbox)
{
	if (textbox.value == "")
		textbox.value = "Geslo";
}

function showWhois(id) {
	var src = "http://www.poisci.si/whois.php?id="+id;
	$.modal('<iframe src="' + src + '" height="450" width="830" style="border:0">', {
		closeHTML:"",
		containerCss:{
			backgroundColor:"#fff",
			borderColor:"#fff",
			height:450,
			padding:0,
			width:830
		},
		overlayClose:true
	});
}

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=700,left = 100,top = 100');");
}

function addOffer(domainID) {
	offerPriceID = $("#offer_price_"+domainID).val();
	if(domainID && offerPriceID) {
		document.location = "/si/ponudbe/"+domainID+"-oddaj.html?opid="+offerPriceID;
	}
}

$(document).ready(function(){
    $("#price").numeric(",");
});
