
// 08.06.2011 - david Leschnik
// BEGIN job_template functions

function addSchool(t){

	var target=$(t).up('table');
	

	var zahl = target.getElementsByTagName("tr").length;
	var tr = target.insertRow(zahl);
	var td1 = document.createElement('td');
	var td2 = document.createElement('td');
	var td3 = document.createElement('td');
	var td4 = document.createElement('td');
	var td5 = document.createElement('td');
	
	var inp1=document.createElement('input');
	inp1.setAttribute('type','text');
	inp1.setAttribute('name','pSchulName[]');
	inp1.setAttribute('class','inp160');
	inp1.className='inp160';
	var inp2=document.createElement('input');
	inp2.setAttribute('type','text');
	inp2.setAttribute('name','pSchulZeit[]');
	inp2.setAttribute('class','inp100');
	inp2.className='inp100';
	var inp3=document.createElement('input');
	inp3.setAttribute('type','text');
	inp3.setAttribute('name','pSchulNote[]');
	inp3.setAttribute('class','inp100');
	inp3.className='inp100';
	
	var delBtn=document.createElement('a');
	delBtn.innerHTML='-';
	delBtn.href='javascript:void(0);';
	delBtn.onclick=new Function('removeEntry(this);');
	delBtn.setAttribute('class','minus_btn');
	delBtn.className='minus_btn';
	
	td1.appendChild(inp1);
	td2.appendChild(inp2);
	td3.appendChild(inp3);
	td4.innerHTML = '&nbsp;'
	td5.appendChild(delBtn);

	tr.appendChild(td1);
	tr.appendChild(td2);
	tr.appendChild(td3);
	tr.appendChild(td4);
	tr.appendChild(td5);

}

function addPraktika(t){
	var target=$(t).up('table');

	var zahl = target.getElementsByTagName("tr").length;
	var tr = target.insertRow(zahl);
	
	var td1 = document.createElement('td');
	var td2 = document.createElement('td');
	var td3 = document.createElement('td');
	var td4 = document.createElement('td');
	var td5 = document.createElement('td');
	
	var inp1=document.createElement('input');
	inp1.setAttribute('type','text');
	inp1.setAttribute('name','pPraktikaBezeichnung[]');
	inp1.setAttribute('class','inp160');
	inp1.className='inp160';
	var inp2=document.createElement('input');
	inp2.setAttribute('type','text');
	inp2.setAttribute('name','pPraktikaArbeitgeber[]');
	inp2.setAttribute('class','inp100');
	inp2.className='inp100';
	var inp3=document.createElement('input');
	inp3.setAttribute('type','text');
	inp3.setAttribute('name','pPraktikaZeitraum[]');
	inp3.setAttribute('class','inp100');
	inp3.className='inp100';
	var inp4=document.createElement('input');
	inp4.setAttribute('type','text');
	inp4.setAttribute('name','pPraktikaAbschluss[]');
	inp4.setAttribute('class','inp100');
	inp4.className='inp100';
	
	var delBtn=document.createElement('a');
	delBtn.innerHTML='-';
	delBtn.href='javascript:void(0);';
	delBtn.onclick=new Function('removeEntry(this);');
	delBtn.setAttribute('class','minus_btn');
	delBtn.className = 'minus_btn';
	
	td1.appendChild(inp1);
	td2.appendChild(inp2);
	td3.appendChild(inp3);
	td4.appendChild(inp4);
	td5.appendChild(delBtn);
	
	tr.appendChild(td1);
	tr.appendChild(td2);
	tr.appendChild(td3);
	tr.appendChild(td4);
	tr.appendChild(td5);

}

function addTaetigkeit(t){
	var target=$(t).up('table');

	var zahl = target.getElementsByTagName("tr").length;
	var tr = target.insertRow(zahl);

	var td1 = document.createElement('td');
	var td2 = document.createElement('td');
	var td3 = document.createElement('td');
	var td4 = document.createElement('td');
	var td5 = document.createElement('td');
	td1.setAttribute('valign','top');
	td2.setAttribute('valign','top');
	td3.setAttribute('valign','top');
	td4.setAttribute('valign','top');
	td5.setAttribute('valign','top');

	var inp1=document.createElement('input');
	inp1.setAttribute('type','text');
	inp1.setAttribute('name','pJobTaetigkeit[]');
	inp1.setAttribute('class','inp160');
	inp1.className='inp160';
	var inp2=document.createElement('input');
	inp2.setAttribute('type','text');
	inp2.setAttribute('name','pJobArbeitgeber[]');
	inp2.setAttribute('class','inp100');
	inp2.className='inp100';
	var inp3=document.createElement('input');
	inp3.setAttribute('type','text');
	inp3.setAttribute('name','pJobZeitraum[]');
	inp3.setAttribute('class','inp100');
	inp3.className='inp100';
	var inp4=document.createElement('textarea');
	inp4.setAttribute('rows','3');
	inp4.setAttribute('name','pJobTaetigkeitsbeschreibung[]');
	inp4.setAttribute('class','inp120');
	inp4.className='inp120';
	
	var delBtn=document.createElement('a');
	delBtn.innerHTML='-';
	delBtn.href='javascript:void(0);';
	delBtn.onclick=new Function('removeEntry(this);');
	delBtn.setAttribute('class','minus_btn');
	delBtn.className = 'minus_btn';
	
	td1.appendChild(inp1);
	td2.appendChild(inp2);
	td3.appendChild(inp3);
	td4.appendChild(inp4);
	td5.appendChild(delBtn);
	
	tr.appendChild(td1);
	tr.appendChild(td2);
	tr.appendChild(td3);
	tr.appendChild(td4);
	tr.appendChild(td5);

}
var file=0;

function addFile(t){
	var target=$(t).up('table');

	var zahl = target.getElementsByTagName("tr").length;
	if(zahl<=5){
	var tr = target.insertRow(zahl);

	var td1=document.createElement('td');
	var td2=document.createElement('td');
	inp1=document.createElement('input');
	inp1.setAttribute('type','file');
	inp1.setAttribute('name','pFile['+file+']');
	inp1.setAttribute('id','pFile['+file+']');
	inp1.setAttribute('class','inp260');
	inp1.className='inp260';
	
	var delBtn=document.createElement('a');
	delBtn.innerHTML='-';
	delBtn.href='javascript:void(0);';
	delBtn.onclick=new Function('removeEntry(this);');
	delBtn.setAttribute('class','minus_btn');
	delBtn.className = 'minus_btn';
	
	td1.appendChild(inp1);
	td2.appendChild(delBtn);
	tr.appendChild(td1);
	tr.appendChild(td2);
	
	
	file++;
	}
	
}

// END job_template functions



// BEGIN short_spezifications template functions

var electicTablesCount=1;

function addElectricTable(t){

	var target= $(t).up('table');
	var zahl = target.getElementsByTagName("tr").length;
	var tr = target.insertRow(zahl);

	var td1 = document.createElement('td');
	var td2 = document.createElement('td');
	var td3 = document.createElement('td');
	var td4 = document.createElement('td');
	var td5 = document.createElement('td');
	var td6 = document.createElement('td');

	var inp1=document.createElement('input');
	inp1.setAttribute('type','text');
	inp1.setAttribute('class','inp100');
	inp1.className='inp100';
	inp1.setAttribute('name','pElectrWege['+electicTablesCount+']');
	var inp2=document.createElement('input');
	inp2.setAttribute('type','text');
	inp2.setAttribute('class','inp160');
	inp2.className='inp160';
	inp2.setAttribute('name','pElectrVerwendung['+electicTablesCount+']');
	var inp3=document.createElement('input');
	inp3.setAttribute('type','text');
	inp3.setAttribute('class','inp100');
	inp3.className='inp100';
	inp3.setAttribute('name','pElectrSpannung['+electicTablesCount+']');
	var inp4=document.createElement('input');
	inp4.setAttribute('type','text');
	inp4.setAttribute('class','inp100');
	inp4.className='inp100';
	inp4.setAttribute('name','pElectrStrom['+electicTablesCount+']');
	var inp5=document.createElement('input');
	inp5.setAttribute('type','text');
	inp5.setAttribute('class','inp100');
	inp5.className='inp100';
	inp5.setAttribute('name','pElectrFrequenz['+electicTablesCount+']');
	

	var delBtn=document.createElement('a');
	delBtn.innerHTML='-';
	delBtn.href='javascript:void(0);';
	delBtn.onclick=new Function('removeEntry(this);');
	delBtn.setAttribute('class','minus_btn');
	delBtn.className = 'minus_btn';


	td1.appendChild(inp1);
	td2.appendChild(inp2);
	td3.appendChild(inp3);
	td4.appendChild(inp4);
	td5.appendChild(inp5);
	td6.appendChild(delBtn);

	tr.appendChild(td1);
	tr.appendChild(td2);
	tr.appendChild(td3);
	tr.appendChild(td4);
	tr.appendChild(td5);
	tr.appendChild(td6);

	
	electicTablesCount++;

}

var medienTablesCount=1;

function addMedienTable(t){
	var target= $(t).up('table');
	var zahl = target.getElementsByTagName("tr").length;
	var tr = target.insertRow(zahl);

	var td1 = document.createElement('td');
	var td2 = document.createElement('td');
	var td3 = document.createElement('td');
	var td4 = document.createElement('td');
	var td5 = document.createElement('td');
	var td6 = document.createElement('td');

	var inp1=document.createElement('input');
	inp1.setAttribute('type','text');
	inp1.setAttribute('class','inp100');
	inp1.className='inp100';
	inp1.setAttribute('name','pMedienWege['+medienTablesCount+']');
	var inp2=document.createElement('input');
	inp2.setAttribute('type','text');
	inp2.setAttribute('class','inp160');
	inp2.className='inp160';
	inp2.setAttribute('name','pMedienMedium['+medienTablesCount+']');
	var inp3=document.createElement('input');
	inp3.setAttribute('type','text');
	inp3.setAttribute('class','inp100');
	inp3.className='inp100';
	inp3.setAttribute('name','pMedienDruck['+medienTablesCount+']');
	var inp4=document.createElement('input');
	inp4.setAttribute('type','text');
	inp4.setAttribute('class','inp100');
	inp4.className='inp100';
	inp4.setAttribute('name','pMedienQuerschnitt['+medienTablesCount+']');
	

	var delBtn=document.createElement('a');
	delBtn.innerHTML='-';
	delBtn.href='javascript:void(0);';
	delBtn.onclick=new Function('removeEntry(this);');
	delBtn.setAttribute('class','minus_btn');
	delBtn.className = 'minus_btn';


	td1.appendChild(inp1);
	td2.appendChild(inp2);
	td3.appendChild(inp3);
	td4.appendChild(inp4);
	td5.innerHTML = '&nbsp;';
	td6.appendChild(delBtn);

	tr.appendChild(td1);
	tr.appendChild(td2);
	tr.appendChild(td3);
	tr.appendChild(td4);
	tr.appendChild(td5);
	tr.appendChild(td6);

	medienTablesCount++;
}

var opticTablesCount=1;

function addOpticTable(t){
	var target= $(t).up('table');
	var zahl = target.getElementsByTagName("tr").length;
	var tr = target.insertRow(zahl);

	var td1 = document.createElement('td');
	var td2 = document.createElement('td');
	var td3 = document.createElement('td');
	var td4 = document.createElement('td');
	var td5 = document.createElement('td');
	var td6 = document.createElement('td');

	var inp1=document.createElement('input');
	inp1.setAttribute('type','text');
	inp1.setAttribute('class','inp100');
	inp1.className='inp100';
	inp1.setAttribute('name','pOpticKanaele['+opticTablesCount+']');
	var inp2=document.createElement('input');
	inp2.setAttribute('type','text');
	inp2.setAttribute('class','inp160');
	inp2.className='inp160';
	inp2.setAttribute('name','pOpticWellenlaenge['+opticTablesCount+']');
	var inp3=document.createElement('input');
	inp3.setAttribute('type','text');
	inp3.setAttribute('class','inp100');
	inp3.className='inp100';
	inp3.setAttribute('name','pOpticTyp['+opticTablesCount+']');
	var inp4=document.createElement('input');
	inp4.setAttribute('type','text');
	inp4.setAttribute('class','inp100');
	inp4.className='inp100';
	inp4.setAttribute('name','pOpticMode['+opticTablesCount+']');
	

	var delBtn=document.createElement('a');
	delBtn.innerHTML='-';
	delBtn.href='javascript:void(0);';
	delBtn.onclick=new Function('removeEntry(this);');
	delBtn.setAttribute('class','minus_btn');
	delBtn.className = 'minus_btn';


	td1.appendChild(inp1);
	td2.appendChild(inp2);
	td3.appendChild(inp3);
	td4.appendChild(inp4);
	td5.innerHTML = '&nbsp;'
	td6.appendChild(delBtn);

	tr.appendChild(td1);
	tr.appendChild(td2);
	tr.appendChild(td3);
	tr.appendChild(td4);
	tr.appendChild(td5);
	tr.appendChild(td6);
	
	opticTablesCount++;	
}

// END short_spezifications template functions



function removeEntry(t){
	$(t).up('tr').remove();
}


function showSalesDetails(id,region){
	jQuery.get('/inc/ajax.getSalesDetails.php?lang=10&id='+id+'&region='+region, function(data) {
		
		jQuery('#salesDetailsContainer').removeShadow();
		
		jQuery('#salesDetailsContainer').width(jQuery('#salesDetailsContainer').css("min-width"));
		jQuery('#salesDetailsContainer').html(data).show();
							
  		/*
  		if(jQuery('#salesDetailsContainer > table').width() > jQuery('#salesDetailsContainer').width())
  			jQuery('#salesDetailsContainer').width(jQuery('#salesDetailsContainer > table').width());
  		*/
  		
  		jQuery('#salesDetailsContainer').dropShadow({top: 5, left: 5, blur: 4,opacity: 0.7});
  		jQuery('#salesDetailsContainer').dropShadow({top: -1, left: -1, blur: 3,opacity: 0.5});	
  			
  		/* bck praktikum04 09/08/2011	*/
  		/*jQuery('#salesDetailsContainer').removeShadow();	
  		jQuery('#salesDetailsContainer').html(data).show().dropShadow({top: 5, left: 5, blur: 4,opacity: 0.7});
  		jQuery('#salesDetailsContainer').html(data).show().dropShadow({top: -1, left: -1, blur: 3,opacity: 0.5});*/
  		
	});	
}

function showSalesDetails2(id){

	if( typeof id == 'object'){
		id = jQuery(id).val();
	}
	jQuery.get('/inc/ajax.getSalesDetails.php?lang=10&id='+id, function(data) {
		jQuery('#salesDetailsContainer').html(data).show();
	});	
}


function hideSalesDetails(){
	jQuery('#salesDetailsContainer').hide();
}

function toggleShowHide(id){
	var obj = id;
    if ($(id).style.display == 'none'){
   		$(id).show();
   	}
   	else {
   		$(id).hide();
   	} 

}


function get_url_param( name )
{
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");

	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );

	if ( results == null ){
		return "";
	}else{
		return results[1];
	}
}

function popUpPrintview(pop_width, pop_height){
		if  (get_url_param('n')=='')
			var URL = (document.location + "?print=true");
		else
			var URL = (document.location + "&print=true");

	eval("WIN = window.open(URL, '','toolbar=0,scrollbars=1,locationbar=0,statusbar=0,menubar=0,resizable=1,width="+pop_width+",height="+pop_height+",left=100,top=100');");


}


/**
	* return array with mouse positions relative to id="body"
	* body element need width declaration in css
	*
	* @since 2009-07-08
	* @author effective-world
	* @copyrigth effective GmbH
	*
	*/
	function getRelativeMousePoints(ereignis) {

		var windowWidth = window.innerWidth;
		if(windowWidth == undefined) {
			windowWidth = document.documentElement.clientWidth;
		}

		var body = $('body');
		var bodyWidth = $('body').offsetWidth;
		var bodyHeight = $('body').offsetHeight;
		//var offsetX = (windowWidth - bodyWidth) / 2; //site align center
		var offsetX = 0; //site align left
		var offsetY = window.pageYOffset;

                //ie
		if(offsetY == undefined) {
			offsetY = document.body.scrollTop;
		}


		var relMouseX = ereignis.clientX - offsetX;
		var relMouseY = ereignis.clientY + offsetY;

		var points = new Array;
		points['x'] = relMouseX;
		points['y'] = relMouseY;

		return points;
	}


function reportAjaxError(request){
	alert('AJAX Error!');
}


function getEventList(id,what){
	var placeIn = $(what);

	var placeIn = $(what);
	var url = '/inc/ajax.getEventList.php';
	var myAjax = new Ajax.Updater(
	{success: placeIn},
	url,
	{
		method: 'get',
		parameters: {id:id,what:what},
		onFailure:reportAjaxError,
		evalScripts:true
	}
	);

}


function getSalesPartners(id,what){
var placeIn = $(what);

	var placeIn = $(what);
	var url = '/inc/ajax.getSalesPartner.php';
	var myAjax = new Ajax.Updater(
	{success: placeIn},
	url,
	{
		method: 'get',
		parameters: {id:id,what:what},
		onFailure:reportAjaxError,
		evalScripts:true
	}
	);

}


function getTeamDetails(id,what)	{

	var placeIn = $(what);
	var url = '/inc/ajax.teamDetails.php';
	var myAjax = new Ajax.Updater(
	{success: placeIn},
	url,
	{
		method: 'get',
		parameters: {teamId:id,what:what},
		onFailure:reportAjaxError,
		evalScripts:true
	}
	);

}



function addEffectiveTrackingClass(class_name)
	{
		var l=document.getElementsByTagName("a").length;

		for(var i=0;i < l; i++){
			var cn=document.getElementsByTagName("a")[i].getAttribute('class');
			if(cn != null && cn != ''){
				document.getElementsByTagName("a")[i].setAttribute('class',cn+" "+class_name);
			}
			else
			{
				document.getElementsByTagName("a")[i].setAttribute('class',class_name);
			}
		}
		for(i=0;i < l;i++){
			//alert(i+" - "+document.getElementsByTagName("a")[i].getAttribute('class'));
		}
	}

	function addTrackingClass2Links(value)
	{
		elements = document.getElementsByTagName("a");
		for (x=0;x < elements.length;x++)
		{
			if (!elements[x].className)
			{
				elements[x].className = value;
			}
			else
			{
				elements[x].className = elements[x].className+" "+value;
			}
		}
	}

	function sh_sub(container){

		//alle bereits göffneten sub Punkte schließen
		var subpoints = document.getElementsByClassName('topNaviSub');
		for(i = 0;i < subpoints.length;i++)
			subpoints[i].style.display = 'none';

		if($('topNaviSub_' + container) == null)
			return 0;

		//Position Links ermitteln und an Ergebniss setzen
		var new_x = $('top_nav' + container).offsetLeft;
		$('topNaviSub_' + container).style.left = new_x + 'px';


		//Display Style ermitteln
		var dis = $('topNaviSub_' + container).style.display;
		if(dis == 'none')
		$('topNaviSub_' + container).style.display = 'inline';
	}

	function Track(site,user,customer)
	{
			var Amp=unescape("%26");
			var Ref="";
			var TrackSrc="http://track.effective-tracking.de/Tracking/tracker.php?";
			var Cur=escape(window.location.href);
			site=escape(site);
			customer=escape(customer);
			user=escape(user);
			var param=escape("Seite="+site+Amp+"Kunde="+customer+Amp+"Benutzer="+user);
			var Img;

			try { Ref = escape(parent.document.referrer); }
			catch(e) {}

			TrackSrc+="pParam="+param;
			TrackSrc+=Amp+"pHome="+Cur;
			TrackSrc+=Amp+"pReferer="+Ref;


			Img = new Image();
			Img.src = TrackSrc;
	}

	



