var START ;
var LIMIT;
var ACTUAL_COLL_NAME;
var ACTUAL_COLL_ARR;
var ACTUAL_PAGE = 1;
var THUMB_PER_PAGE = 9;

var MyBio = '';
var MyResume = '';
var MyContact = '';
var search_result;

var LAST_MENU = "";
var CURRENT_MENU = "";

var zoomedImage;

var all_colections = [
			"illustration"
			,"fashion_illustration"
			,"thesis"
			,"graphic_design"
			,"drawing_and_painting"
			,"photography"
			,"bio"
			,"resume"
			,"contact"
			,"search"
			];
			

var illustration = [	
			"a_row"
			,"untitled"
			,"sketchbook_project_3"		
			,"in_the_air"
			,"sketchbook_project_2"	
			,"leaf_face"
			,"rare_finds"
			,"sketchbook_project_1"
			,"the_writer"
			,"rubber_bubble"
			,"short_trips_long_phone_calls"
			,"the_tattoo"
			,"man_and_his_machine"
			,"canada_day"
			,"sketchbook_project_5"
			,"memories"
			,"here_we_go"
			,"a_beast"
			,"pop"
			,"black_card"
			,"blood_diamond"
			,"chance_dance"
			,"chicken"
			,"choose_an_intensity"		
			,"cuba"
			,"deconstruction_with_apples"
			,"dia_de_los_muertos"
			,"faceboo"
			,"faster_better_better_faster"
			,"fill_me_in"	
			,"fridge_salsa_party"
			,"giraffes"	
			,"in_my_head"
			,"latest_and_greatest"
			,"leg_room"
			,"listeria_scandal"
			,"love"	
			,"luggage_delivery"
			,"maybe"
			,"media_hunger"
			,"meditation"
			,"my_luck"
			,"night_life"
			,"orangina_ad"
			,"overflow"
			,"paradise"
			,"power_what_it_takes"
			,"recession"
			,"seeds"	
			,"stamp_design"
			,"summer_salsa"
			,"survival_of_the_kindest"	
			,"what_he_really_wanted_to_be_is"
			];

var fashion_illustration = [
			"walk_on"
			,"fashion_warriors"
			,"these_are_the_people"
			,"fashion_illustration"
			,"stilettos_bite"
			,"best_thing_about_summer"
			,"breathing_gold"
			,"city_is_my_catwalk"
			,"flying_lights"
			,"how_much_do_i_you_we_reveal"
			,"love_life_tshirt"
			,"spine"
			,"wear_it"			
			];

var thesis = [
		"info"
		,"diamond_lullaby"
		,"where_did_i_put_myself"
		,"i_am_in_an_important_meeting"
		,"ruby_high"
		,"no_longer_listed_in_a_relationship"
		,"all_that_is_left_is_all_that_i_need"
		,"my_financial_nightmare"
		,"mind_under_matter"
		,"looking_good_never_hurt_so_bad"
		,"it_was_everywhere"
		,"unravelling"
		,"serenity_prayer"
		];			
			
var graphic_design = [
			"koza_sculpture_card"
			,"menus"
			,"brand_logo"
			,"brand_story"
			,"brand_application"
			,"DSantos_logo_2"
			,"sunita_kossta_business_card_design"
			,"old_warriors_logo"
			,"mazouka_dance_logos"
			,"cd_cover_design"
			,"city_guide_editorial_design"
			,"fresh_moo_packaging_design"
			,"so_society_packaging_design"
			,"sarahs_cupcake_kingdom"
			,"latin_lounge_cd_cover"
			,"embrace_logo"
			,"toronto_salsa_dance"
			,"almas_logo"
			,"brian_naud_ad"
			,"communities_map"
			,"do_the_roo_logo"
			,"dolls_poster"
			,"DSantos_identity"
			,"HP_website"
			,"le_chateau_tags"
			,"esther_paul_book_cover"
			,"salsa411"
			,"vida_toronto"
			,"yearbook_cover"
			];			
			
					
var drawing_and_painting = [
			"shelter_1"
			,"shelter_2"
			,"Sunita_With_Harp"
			,"snap"
			,"male_study"
			,"and_so_it_follows"
			,"blue_expressionism"
			,"body_study"
			,"boot_still_life"
			,"charcoal_study"
			,"danger_in_seduction"
			,"dark_folk_story"
			,"expressions"
			,"garbage_bag"
			,"i_know"
			,"in_the_moment"
			,"maracas"
			,"model_study"
			,"murder_alley"
			,"my_grandmother"
			,"nude_study"
			,"nude_seated"
			,"portrait_study"
			,"portait_study(2)"
			,"spanish_dancer"
			,"studies"
			,"xtina"
			];
/*	
var photography = [
			"new_skin_dance_group"
			,"moved"
			,"double_trouble"
			,"daze"
			,"ana_with_flour"
			,"fouzia"
			,"lights_play"
			,"mirror_mirror_on_the_floor"
			,"the_aura"
			,"a_cold_alley"
			,"ana"
			,"ana_red_dress"
			,"dream_on"
			,"drowning_in_fall_rain"
			,"fashion"
			,"ghost_of_christmas"
			,"leon"
			,"old_havana"
			,"peace"
			,"pink_romance"
			,"silence"
			,"split"
			,"staples_and_opportunities"
			,"wasaga_beach"
		]
*/
//=================================================================================================================

	
function loadAllMenu(){
	bottomContentStr = '<div id="bcs">';
	for(i=0;i<all_colections.length;i++){
		if(all_colections[i] == "illustration"){
			loadThis(all_colections[i]);
		}
		if(all_colections[i] == "bio"){bottomContentStr += '<br />';}	
		
		if(all_colections[i] == "contact"){
			bottomContentStr += '<br /><span style="color:#000;cursor:pointer;" class="mymenu_bottom" id="'+all_colections[i]+'" onclick="loadThis(this.id)">'+all_colections[i].replace(/_/ig," ")+'</span>';
		}else{
			if(all_colections[i] != "search"){
				bottomContentStr += '<br /><span style="cursor:pointer;" class="mymenu_bottom"  id="'+all_colections[i]+'" onclick="loadThis(this.id)">'+all_colections[i].replace(/_/ig," ")+'</span>';
			}else{
				bottomContentStr += '&nbsp;&nbsp;&nbsp;<a href="http://www.facebook.com/pages/ViaLavinia/10962259807?ref=ts" target="_blank"><img style="border:none;vertical-align:middle;" src="./img/fb.jpg" /></a>&nbsp;<a href="https://twitter.com/vialavinia" target="_blank"><img style="border:none;vertical-align:middle;" src="./img/tw.jpg" /></a>';
				bottomContentStr += '</br><br /><span style="cursor:pointer;" class="mymenu_bottom"  id="'+all_colections[i]+'" onclick="loadThis(this.id)">search by title</span>';
			}
			
		}
		
	}
	bottomContentStr += '</div>';
	
	document.getElementById("left_bottom").innerHTML = bottomContentStr;
	document.getElementById("illustration").style.color = "#F81E8C";
}



function loadThis(coll){
	//alert(coll);
	hightlightlink(coll);
	
	START = 0;
	LIMIT = THUMB_PER_PAGE;
	ACTUAL_PAGE = 1;
	switch(coll){
		case "photography":
				loadPhoto();
		break;
		case "bio":
			loadBio();
		break;
		case "resume":
			loadResume();	
		break;
		case "":
				
		break;
		case "contact":
			loadContact();	
		break;
		case "search":
			loadSearch();	
		break
		default:
			ACTUAL_COLL_NAME = coll;
			ACTUAL_COLL_ARR = eval(coll);
			document.getElementById("thumbs").innerHTML = "";
			loadPics();
		break;	
	}
}
	
function loadPhoto(){
	//alert("go there");
	window.open('http://www.photosvialavinia.com/','_newtab'); 
}

function loadBio(){
	//alert("Load bio");
	document.getElementById("right_container").innerHTML = MyBio;
	document.getElementById("left_search").style.visibility = "hidden";
	}
	
function loadResume(){
	//alert("Load resume");
	document.getElementById("right_container").innerHTML = MyResume;
	document.getElementById("left_search").style.visibility = "hidden";
	}
	
function loadContact(){
	//alert("Load contact");
	document.getElementById("right_container").innerHTML = MyContact;
	document.getElementById("left_search").style.visibility = "hidden";
	}	

function loadSearch(){
	//alert("load search");
	searchStr = 'Search for: <input type="text" id="searchtext" name="imgname" /><button type="button" onclick="searchFor()">Search</button>';
	document.getElementById("left_search").innerHTML = searchStr;
	document.getElementById("left_search").style.visibility = "visible";
	document.getElementById("searchtext").focus();
}

function hightlightlink(coll){
	CURRENT_MENU = coll;
	if(CURRENT_MENU != LAST_MENU){
		if(document.getElementById(CURRENT_MENU)){document.getElementById(CURRENT_MENU).style.color = "#F81E8C";}
		if(document.getElementById(LAST_MENU)){document.getElementById(LAST_MENU).style.color = "#000";}
		LAST_MENU = CURRENT_MENU;
	} 
}

function searchFor(){
	keyword = document.getElementById("searchtext").value;
	//alert(keyword);
	//document.getElementById("left_search").style.visibility = "hidden";
	search_result = new Array();
	var searchIndex = 0;
	
	for(j=0; j<all_colections.length-4; j++){
		//alert(all_colections[j]);
		if(all_colections[j].indexOf('photography') < 0){
		
			theColectionArray = eval(all_colections[j]);
			//alert(all_colections[j]+"\n"+theColectionArray.length);
			for(k=0; k<theColectionArray.length; k++){
				//alert(theColectionArray[k]);
				loKeyW = keyword.toLowerCase().replace(/_/gi," ");
				loImgTitle = theColectionArray[k].toLowerCase().replace(/_/gi," ");
				//alert(loKeyW+"\n"+loImgTitle);
				if(loImgTitle.search(loKeyW) >= 0){
					search_result[searchIndex++] = all_colections[j]+"/"+theColectionArray[k];
				}
			}
		}	
	}
	
	var xxx = "";
	for(ii=0; ii<search_result.length; ii++){
		xxx += search_result[ii]+"\n";
	}
	
	//alert(xxx);
	loadThis("search_result");
	
	if(search_result.length > 0){
		document.getElementById("left_search").style.visibility = "hidden";
	}else{
		document.getElementById("left_search").style.visibility = "visible";
	}
	
}


function loadPics(){
	document.getElementById("thumbs").innerHTML = "";
	
	if((ACTUAL_COLL_ARR.length - START) < THUMB_PER_PAGE){ LIMIT = ACTUAL_COLL_ARR.length - START;}
	a = new Array();	
	var index_a = 0;
	for(ii=START; ii<(START + LIMIT);ii++) {
	    if(ACTUAL_COLL_NAME == "search_result"){
	    	a[index_a++] = ACTUAL_COLL_ARR[ii]+"_th.jpg";
	    }else{
	    	a[index_a++] = ACTUAL_COLL_NAME+"/"+ACTUAL_COLL_ARR[ii]+"_th.jpg";
	    }
	}
	
	var res = "";
	for(j=0;j<a.length;j++){
		//res += a[j]+"\n";
		//res += a[j]+"<br>";
		loadThumb(a[j]);
		document.getElementById("thumbs").innerHTML += loadThumb(a[j]);
		if(j == 0){
			loadFullImg("./collections/"+a[j].replace("_th.","."));
		}
	}
	//alert("XoXo: "+a.length);
	
	if(a.length == 0){
		document.getElementById("thumbs").innerHTML = "Sorry, your key words did not match any titles."
		//document.getElementById("right_container").innerHTML = '<img style="padding-top:5px;" src="./img/noresults.jpg" />';
		}
	//topContentStr = '<div style="width:160px;float:left;font-style:oblique;font-size:11px;color:#F81E8C">'+ACTUAL_COLL_NAME.replace(/_/ig," ")+'</div>';
	topContentStr = '';
	
	switch(ACTUAL_PAGE){
		case 1:
			if(getTotalCollPages(ACTUAL_COLL_ARR.length) == 1){
			topContentStr += '<div id="pageText">';
			topContentStr += '&nbsp;&nbsp;&nbsp;&nbsp;<span class="changePage" style="padding-right:5px;">'+ACTUAL_PAGE+'/'+getTotalCollPages(ACTUAL_COLL_ARR.length)+'</span>';
			topContentStr += '</div>';			
			}else{
			topContentStr += '<div id="pageText">';
			topContentStr += '&nbsp;&nbsp;<span id=">" style="cursor:pointer;background:#fff;" onclick="nextPage(this.id)">></span>&nbsp;&nbsp;<span class="changePage" style="padding-right:5px;">'+ACTUAL_PAGE+'/'+getTotalCollPages(ACTUAL_COLL_ARR.length)+'</span>';
			topContentStr += '</div>';			
			}
		
		break;
		
		case getTotalCollPages(ACTUAL_COLL_ARR.length):
			topContentStr += '<div id="pageText">';
			topContentStr += '<span id="<" style="cursor:pointer;background:#fff;" onclick="nextPage(this.id)"><</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="changePage" style="padding-right:5px;">'+ACTUAL_PAGE+'/'+getTotalCollPages(ACTUAL_COLL_ARR.length)+'</span>';
			topContentStr += '</div>';		
		break;
		
		default:
			topContentStr += '<div id="pageText">';
			topContentStr += '<span id="<" style="cursor:pointer;background:#fff;" onclick="nextPage(this.id)"><</span>&nbsp;&nbsp;<span id=">" style="cursor:pointer;background:#fff;" onclick="nextPage(this.id)">></span>&nbsp;&nbsp;<span class="changePage" style="padding-right:5px;">'+ACTUAL_PAGE+'/'+getTotalCollPages(ACTUAL_COLL_ARR.length)+'</span>';
			topContentStr += '</div>';
		break;
	
	}
	
	document.getElementById("page").innerHTML = topContentStr;
	if(ACTUAL_COLL_NAME != "search"){
		document.getElementById("left_search").style.visibility = "hidden";
	}
	//document.getElementById("page").innerHTML = '<div style="width:100px;">'+ACTUAL_COLL_NAME+'</div>';
}
			
function nextPage(ds){	
	switch(ds){
		case ">":
			START=START+THUMB_PER_PAGE;
			if(ACTUAL_PAGE < getTotalCollPages(ACTUAL_COLL_ARR.length)){ACTUAL_PAGE++};
			if(ACTUAL_PAGE == getTotalCollPages(ACTUAL_COLL_ARR.length)){document.getElementById(">").visibility = "hidden";}
			
		break;
		case "<":
			START=START-THUMB_PER_PAGE;
			LIMIT = THUMB_PER_PAGE;
			if(ACTUAL_PAGE > 1){ACTUAL_PAGE--};
			if(ACTUAL_PAGE == 1){document.getElementById("<").visibility = "hidden";}
			
		break;
	}
	loadPics();
}

function loadThumb(picName){
	picPath = "./collections/"+picName;
	fullImgNamePath = picPath.replace("_th.",".");
	//alert(picPath+"\n"+fullImgNamePath);
	return '<img style="padding:5px;cursor:pointer;" id="'+picName+'" width="60" height="60" src="'+picPath+'" onclick="loadFullImg('+'\''+encodeURI(fullImgNamePath) +'\''+')" title="'+getPicUpCaseName2(picName)+'" />';
	
}

function loadFullImg(picName){
	picPath = "./collections/"+picName;
	picPath = decodeURI(picName);
	picPath2 = picPath.replace(/.jpg/ig,"_full.jpg");
	//alert(picPath2);
	document.getElementById("right_container").innerHTML = '<img style="padding-top:5px;" src="'+picPath+'" id="baseID" /><div><span class="changePage">'+getPicUpCaseName(picName)+'</span></div>';
	pp = encodeURI(picPath2);
	//alert(pp);
	var loader = new ImageLoader(pp);
	loader.loadEvent = function(url, image){loadMagnifier('right_container', pp, image, 0)}
	loader.load();
	
}

function getTotalCollPages(arrLength){
	var res=0;
	if((arrLength % THUMB_PER_PAGE) != 0){
		return Math.floor(arrLength/THUMB_PER_PAGE)+1;
	}else{
		return Math.floor(arrLength/THUMB_PER_PAGE);
	}
}

function getPicUpCaseName(pn){
	//alert(pn);
	lastSlash = pn.lastIndexOf("/")+1;
	//alert(lastSlash);
	thisImgName = pn.substring(lastSlash);
	thisImgName = thisImgName.replace(/.jpg/ig,"");
	upperCaseName = thisImgName.toUpperCase();
	return upperCaseName.replace(/_/ig," ");
}

function getPicUpCaseName2(pn){
	//alert(pn);
	lastSlash = pn.lastIndexOf("/")+1;
	//alert(lastSlash);
	thisImgName = pn.substring(lastSlash);
	thisImgName = thisImgName.replace(/_th.jpg/ig,"");
	upperCaseName = thisImgName.toUpperCase();
	return upperCaseName.replace(/_/ig," ");
}

function timedMsg(){
    var t=setTimeout("alert('Welcome to dotnetheaven.com')",1000)
  }

function doNothing(){

	//alert("doNothing");

}


//=========================================================================================================================

MyBio += '<div style="width:500px;text-align:justify">';
MyBio += '<b> <span style="color:#F81E8C">Pens, markers, paints and inks: this is the media through which she thinks...</span></b>';

MyBio += '<p>Lavinia Ungureanu is a graphic artist currently based in Toronto. Having graduated with a Bachelor of Design from the Illustration program at OCAD University, she now works as a freelance artist in the illustration, graphic design, fine art and photography fields. </p>';
MyBio += '<p>Originally born in Bucharest, Romania, she moved to Canada in 2001. Back home she was accepted in the Nicolae Tonitza Art School at age 11 and studied visual arts intensively for 2 and a half years.</p>';
MyBio += '<p>In Canada, she participated in local art competitions in Ottawa and has won numerous art awards throughout high school. After graduating high school with an Arts Certificate, she enrolled at the University of Ottawa where she studied communications and visual arts for 2 years.</p>';
MyBio += '<p>She is also interested in fashion, creative make-up, writing, dancing and music. Her inspiration comes from beautiful and tragic moments, opposites, details, fashion, the emotional spectrum, words, and deadlines.</p>';
MyBio += '</div>';


MyResume += '<div style="width:500px;text-align:justify">';
MyResume += '<span style="color:#F81E8C;"><b>Bachelor of Design - Illustration</b></span><br /><br />';
MyResume += '<span>OCAD - Ontario College of Art and Design, Toronto, ON</span>';
MyResume += '<br />';
MyResume += '<br />';
MyResume += '<b style="color:#F81E8C">Artistic Achievements:</b>';

MyResume += '<p>Received 6 awards at Young At Art (2002-2004), including \"Jury\'s Choice\" and \"Best in Mixed Media\", as well as second place in the Student Showcase 2003, art category.</p>';
MyResume += '<p>Won 2nd place in the Ottawa University Walk of Arts 2007 competition.</p>';
MyResume += '<p>Submitted weekly comics for the Ottawa University\'s newspaper - The Fulcrum.</p>';
MyResume += '<p>Published illustration in MUSI magazine and Untitled Magazine.</p>';
MyResume += '<p>Participated in the Orangina Originals ad competition and was selected as part of the Top 10 best entries.</p>';
MyResume += '<p>Published photography in Ellements Magazine (Issue #1).</p>';

MyResume += '<p>Participated in the following group shows:</p>';

MyResume += 'Monosaic at Labspace Studios, Toronto 2009<br />';
MyResume += 'Whodunit? at OCAD U, Toronto 2009<br />';
MyResume += 'Rock n\' Roll Show at My Place, a Canadian Pub, Toronto 2010<br />';
MyResume += 'Imaginary Friends at Chuck Akudu Gallery, Toronto 2010<br />';
MyResume += 'Whodunit? at OCAD U, Toronto 2010<br />';
MyResume += 'Art by the Pound at Sleeping Giant Gallery, Toronto 2010<br />';
MyResume += 'A Canadian Show at 36 Chambers Studio, Toronto 2011<br />';
MyResume += 'The Show Off, OCAD U 96th graduation exhibition, Toronto 2011<br />';

MyResume += '<p><b style="color:#F81E8C">Clients:</b></p>';
MyResume += '<p>Brian Naud, Esther Paul, DSantos Dance, Home Painters Toronto, TheSalsa411, TheDance411, Toronto Salsa Dance Dance Dance, Jill and Stacey Do The Roo, Sarah\'s Cupcake Kingdom, Sunita Kossta Consulting Services, Old Warriors, MaZouka Dance.</p>';

MyResume += '</div>';


MyContact += '<div style="width:500px;text-align:justify">';
MyContact += '<b style="color:#F81E8C">LAVINIA UNGUREANU</b>';
MyContact += '</div>';
MyContact += '<br /><br />';
MyContact += '<a href="MAILTO:lavinia@vialavinia.ca">Lavinia@ViaLavinia.ca</a>';
MyContact += '<br /><br />';
MyContact += 'Tel: 416-839-4927';
MyContact += '<br /><br /><br />';
MyContact += '<span style="padding-bottom:10px;"><b>Got Facebook?</b> Check out Via Lavinia\'s Fan Page:&nbsp;&nbsp;</span><a href="http://www.facebook.com/pages/ViaLavinia/10962259807?ref=ts" target="_blank"><img style="border:none;vertical-align:middle;" src="./img/fb.jpg" /></a>';
MyContact += '<br /><span style="padding-bottom:10px;"><b>On Twitter?</b> Follow my tweets at:&nbsp;&nbsp;</span><a href="https://twitter.com/vialavinia" target="_blank"><img style="border:none;vertical-align:middle;" src="./img/tw.jpg" /></a>';
MyContact += '</div>';


