<!--

function openWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}



function changeSelect(targ,selObj,restore) {
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function showHide(target) 
{
	hideHoverDivs();
	if (document.getElementById(target).style.display == 'none') 
	{
		//document.getElementById(target).style.top =
    	document.getElementById(target).style.display = 'block';
	} 
	else 
	{
    	document.getElementById(target).style.display = 'none';
    }
    
    if (target == 'companySearchDiv') 
    {
    	setContentBgHeight();	
    }
}

function hideHoverDivs() 
{
	var divs = document.getElementsByTagName('div');
	var divNamePart = 'lh_';
	
	for(i=0;i<divs.length;i++) 
	{
		if(divs[i].id.match(divNamePart)) 
		{
			divs[i].style.display = 'none';
		}	
	}
}

function setContentBgHeight() 
{
	var contentDiv = '';
	
	if (document.getElementById('content_wide') && document.getElementById('content_bg_wide'))
	{
		contentDiv = 'content_wide';
		contentBgDiv = 'content_bg_wide';
	} 
	else if (document.getElementById('text') && document.getElementById('content_bg'))
	{
		contentDiv = 'text';
		contentBgDiv = 'content_bg';
	}
	
	if (contentDiv != '')
	{
		var contentHeight = document.getElementById(contentDiv).offsetHeight;
		var bgHeight = document.getElementById(contentBgDiv).offsetHeight;
		var offSet = 150;

		if ((contentHeight+offSet) > bgHeight) 
		{
			document.getElementById(contentBgDiv).style.height = (contentHeight+offSet)+'px';
		}
	}
	
}

function deleteEntry(entry_id, entry_name, lan)
{
	var answer = confirm("Haluatko varmasti poistaa tuotannon "+entry_name+"?")
	if (answer) 
	{
		window.location = "main.php?lan="+lan+"&mode=admin_liukuhihna_del&liukuhihna_id="+entry_id;
	}
}

function setEntryStatus(entry_id, status_to_set, lan)
{
	window.location = "main.php?lan="+lan+"&mode=admin_liukuhihna_set&liukuhihna_id="+entry_id+"&liukuhihna_status="+status_to_set;
}



/****************************************************************************/
// Tuotantoyhtiötietokannan funkkarit

function submitForm()
{
	document.edit.submit();
}

function setAddContact()
{
	document.edit.contact_name.value = '';
	document.edit.contact_title_fi.value = '';
	document.edit.contact_title_en.value = '';
	document.edit.contact_tel.value = '';
	document.edit.contact_gsm.value = '';
	document.edit.contact_email.value = '';
	
	// Näytetään oikea buttoni...
    document.getElementById('addContactButton').style.display = 'block';
    document.getElementById('editContactButton').style.display = 'none';
	
	// Ja näytetään kentät
	document.getElementById('addContactDiv').style.display = 'block';
}

function addContact()
{
	if (document.edit.contact_name.value == '') 
	{
		alert("Yhteyshenkilöllä pitää olla nimi!");
	} 
	else 
	{
		//alert("Ok, voi lisätä yhteyshenkilön.");
		document.edit.company_contacts_edit.value = 0;
		document.edit.company_contacts_add.value = 1;
		submitForm();
	}
}

function setContactEdit(contact_id, contact_name, contact_title_fi, contact_title_en, contact_tel, contact_gsm, contact_email)
{
	//alert(contact_name+' '+contact_title_fi+' '+contact_title_en+' '+contact_tel+' '+contact_gsm+' '+contact_email);
	
	document.edit.contact_name.value = contact_name;
	document.edit.contact_title_fi.value = contact_title_fi;
	document.edit.contact_title_en.value = contact_title_en;
	document.edit.contact_tel.value = contact_tel;
	document.edit.contact_gsm.value = contact_gsm;
	document.edit.contact_email.value = contact_email;

	document.edit.company_contacts_edit_id.value = contact_id;

	// Näytetään oikea buttoni...
    document.getElementById('editContactButton').style.display = 'block';
    document.getElementById('addContactButton').style.display = 'none';


    // Ja näytetään kentät
    document.getElementById('addContactDiv').style.display = 'block';

}

function editContact()
{
	if (document.edit.contact_name.value == '') 
	{
		alert("Yhteyshenkilöllä pitää olla nimi!");
	} 
	else 
	{
		//alert("Ok, voi lisätä yhteyshenkilön.");
		document.edit.company_contacts_add.value = 0;
		document.edit.company_contacts_edit.value = 1;
		submitForm();
	}
}

function deleteContact(contact_id, contact_name)
{
	var answer = confirm("Haluatko varmasti poistaa yhteyshenkilön "+contact_name+"?")
	if (answer) 
	{
		document.edit.company_contacts_add.value = 0;
		document.edit.company_contacts_edit.value = 0;
		document.edit.company_contacts_del.value = contact_id;
		submitForm();
	}
}


function setAddReference()
{
	document.edit.reference_name_fi.value = '';
	document.edit.reference_name_en.value = '';
	document.edit.reference_url.value = '';
	
	// Näytetään oikea buttoni...
    document.getElementById('addReferenceButton').style.display = 'block';
    document.getElementById('editReferenceButton').style.display = 'none';
	
	// Ja näytetään kentät
	document.getElementById('addReferenceDiv').style.display = 'block';
}

function addReference()
{
	if (document.edit.reference_name_fi.value == '') 
	{
		alert("Referenssillä pitää olla suomenkielinen nimi!");
	} 
	else if (document.edit.reference_name_en.value == '') 
	{
		alert("Referenssillä pitää olla englanninkielinen nimi!");
	} 
	else 
	{
		document.edit.company_references_edit.value = 0;
		document.edit.company_references_add.value = 1;
		submitForm();
	}
}


function setReferenceEdit(reference_id, reference_name_fi, reference_name_en, reference_url)
{
	document.edit.reference_name_fi.value = reference_name_fi;
	document.edit.reference_name_en.value = reference_name_en;
	document.edit.reference_url.value = reference_url;

	document.edit.company_references_edit_id.value = reference_id;

	// Näytetään oikea buttoni...
    document.getElementById('editReferenceButton').style.display = 'block';
    document.getElementById('addReferenceButton').style.display = 'none';


    // Ja näytetään kentät
    document.getElementById('addReferenceDiv').style.display = 'block';
}

function editReference()
{
	if (document.edit.reference_name_fi.value == '') 
	{
		alert("Referenssillä pitää olla suomenkielinen nimi!");
	} 
	else if (document.edit.reference_name_en.value == '') 
	{
		alert("Referenssillä pitää olla englanninkielinen nimi!");
	} 
	else 
	{
		document.edit.company_references_add.value = 0;
		document.edit.company_references_edit.value = 1;
		submitForm();
	}
}

function deleteReference(reference_id, reference_name_fi)
{
	var answer = confirm("Haluatko varmasti poistaa referenssin "+reference_name_fi+"?")
	if (answer) 
	{
		document.edit.company_references_add.value = 0;
		document.edit.company_references_edit.value = 0;
		document.edit.company_references_del.value = reference_id;
		submitForm();
	}
}

function deleteCategory(category_id, category_name_fi)
{
	var answer = confirm("Haluatko varmasti poistaa tuotantoyhtiön kategoriasta "+category_name_fi+"?")
	if (answer) 
	{
		document.edit.company_categories_del.value = category_id;
		submitForm();
	}
}


function deleteCompany(company_id, company_name)
{
	var answer = confirm("Haluatko varmasti poistaa tuotantoyhtiön "+company_name+"?")
	if (answer) 
	{
		document.edit.company_name.value = company_name;
		document.edit.company_del.value = company_id;
		submitForm();
	}
}

function editLiukuhihna()
{
	if (document.edit.liukuhihna_nimi.value == '') 
	{
		alert("Työllä pitää olla nimi!");
	} 
	else if (document.edit.liukuhihna_pvm.value == '') 
	{
		alert("Työllä pitää olla päivämäärä!");
	} 
	else if (document.edit.liukuhihna_url.value == '') 
	{
		alert("Työllä pitää olla linkki!");
	} 
	else if (document.edit.liukuhihna_tuotantoyhtio.value == '') 
	{
		alert("Työllä pitää olla tuotantoyhtiö!");
	} 
	else 
	{
		submitForm();
	}
}

function removeImgLiukuhihna()
{
	var answer = confirm("Haluatko varmasti poistaa kuvan?")
	if (answer) 
	{
		document.edit.del_img.value = 1;
		submitForm();
	}
}


function submitLiukuhihna()
{
	if (document.edit.tyon_nimi.value == '') 
	{
		alert("You must give a name to your production!\n\nTyön nimi on pakollinen tieto!");
	} 
	else if (document.edit.tyon_pvm.value == '') 
	{
		alert("You must give a date to your production!\n\nTyön päivämäärä on pakollinen tieto!");
	} 
	else if (document.edit.tyon_url.value == '') 
	{
		alert("You must give an url to your production!\n\nTyön linkki on pakollinen tieto!");
	} 
	else if (document.edit.tuotantoyhtio.value == '') 
	{
		alert("You must give a production company to your production!\n\nTyöllä pitää olla tuotantoyhtiö!");
	} 
	else if (document.edit.sposti.value == '') 
	{
		alert("You must give your email!\n\nSähköpostiosoite on pakollinen tieto!");
	} 
	else 
	{
		submitForm();
	}
}

function submitCompany()
{
	if (document.edit.company_name.value == '') 
	{
		alert("Please fill your company name!\n\nTuotantoyhtiön nimi on pakollinen tieto!");
	} 
	else if (document.edit.company_about_fi.value == '') 
	{
		alert("Please fill company description (FI)!\n\nTuotantoyhtiön kuvaus (FI) on pakollinen tieto!");
	}
	else if (document.edit.company_about_en.value == '') 
	{
		alert("Please fill company description (EN)!\n\nTuotantoyhtiön kuvaus (EN) on pakollinen tieto!");
	}
	else if (document.edit.company_address.value == '') 
	{
		alert("Please fill company address!\n\nTuotantoyhtiön osoite on pakollinen tieto!");
	}
	else if (document.edit.company_zip.value == '') 
	{
		alert("Please fill company zip code!\n\nTuotantoyhtiön postinumero on pakollinen tieto!");
	}
	else if (document.edit.company_city.value == '') 
	{
		alert("Please fill company city!\n\nTuotantoyhtiön postitoimipaikka on pakollinen tieto!");
	}
	else if (document.edit.company_tel.value == '') 
	{
		alert("Please fill company telephone number!\n\nTuotantoyhtiön puhelinnumero on pakollinen tieto!");
	}
	else if (document.edit.company_email.value == '') 
	{
		alert("Please fill company email!\n\nTuotantoyhtiön sähköpostiosoite on pakollinen tieto!");
	}
	else if (document.edit.company_url.value == '') 
	{
		alert("Please fill company URL!\n\nTuotantoyhtiön www-osoite on pakollinen tieto!");
	}
	else if (document.edit.contact_name.value == '') 
	{
		alert("Please fill contact person!\n\nYhteyshenkilö on pakollinen tieto!");
	} 
	else if (document.edit.contact_tel.value == '') 
	{
		alert("Please fill contact person\'s telephone number!\n\nYhteyshenkilön puhelinnumero on pakollinen tieto!");
	} 
	else if (document.edit.contact_gsm.value == '') 
	{
		alert("Please fill contact person\'s mobile number!\n\nYhteyshenkilön gsm-numero on pakollinen tieto!");
	} 
	else if (document.edit.contact_email.value == '') 
	{
		alert("Please fill contact person\'s email!\n\nYhteyshenkilön sähköpostiosoite on pakollinen tieto!");
	}
	else 
	{
		submitForm();
	}
}

/****************************************************************************/

function editVideoLink()
{
	if (document.edit.vl_video_id.value == '') 
	{
		alert("You must give a video id!");
	} 
	else 
	{
		submitForm();
	}
}

function deleteVideoLink(vl_id, vl_name, lan)
{
	var answer = confirm("Haluatko varmasti poistaa videolinkin "+vl_name+"?")
	if (answer) 
	{
		window.location = "main.php?lan="+lan+"&mode=admin_video_links_del&vl_id="+vl_id;
	}
}

function setVideoLinkStatus(vl_id, vl_status)
{
	var answer = confirm("Haluatko varmasti muuttaa videolinkin tilaa?");
	if (answer) 
	{
		window.location = "main.php?mode=admin_video_links_set&vl_id="+vl_id+"&vl_status="+vl_status;
	}
}

//-->
