// Premesteno u Web.config u folderu gde se nalazi administracija
/*
var Q_Delete = 'Da li ste sigurni da želite da obrišete?';
var Q_Save = 'Da li ste sigurni da želite da zapamtite izmene?';
var ADMIN_FOLDER = "CMSAdmin/";
*/

function AdminFolder() {
	var adminFolder = ADMIN_FOLDER.toLowerCase();

	if( document.URL.toLowerCase().indexOf( adminFolder + "catalog/")>0 )
		return "../";
	else if( document.URL.toLowerCase().indexOf(adminFolder + "bancaintesa/")>0 )
		return "../";
	else if( document.URL.toLowerCase().indexOf(adminFolder)>0 )
		return "";
	else
		return ADMIN_FOLDER;
}

var editorsDisabled = false;

function DisableOtherEditors(){
	editorsDisabled = true;
}

function EnableOtherEditors(){
	try 
	{
		if( window.opener != null && window.opener.editorsDisabled != null)
			window.opener.editorsDisabled = false;
	} 
	catch (error) 
	{
	}
}

function GetLeftStartPosition(popupWidth){
	var left = (window.self.screen.width - popupWidth) / 2;
	return left;
}

function GetTopStartPosition(popupHeight){
	var top = (window.self.screen.height - popupHeight) / 2;
	return top;
}

function OpenEditorWindow(pageLocation,top,left,width,height){
		var newWnd = window.open( AdminFolder() + pageLocation, '_blank', 
			'menubar=no, titlebar=no, resizable=yes, status=no, scrollbars=yes, location=no, toolbar=no, top=' 
			+ top + ', left=' + left + ', width=' + (width+15) + ', height=' + (height+15) );
		/* ZA DEBUG */
//		var newWnd = window.open(pageLocation, '_blank');

		newWnd.focus();
			
		return false;
}

function OpenResizableEditorWindow(pageLocation,top,left,width,height){
		var newWnd = window.open( AdminFolder() + pageLocation, '_blank', 
			'menubar=no, titlebar=no, resizable=yes, status=no, scrollbars=yes, location=no,toolbar=no, top=' +	top + ', left=' + left + ', width=' + width + ',	height=' + height );
						
		newWnd.focus();
			
		return false;
}

//Akcija koja se pokrece na OK dugme
function OnAcceptButton(){
	//forsiraj parent prozor da osvezi svoj sadrzaj 
	try
	{
		if(window.opener != null){
//				window.opener.document.location.reload();	
			var w = window.opener;
			var theform;
			if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
				theform = w.document.forms["Form1"];
			}
			else {
				theform = w.document.Form1;
			}
			if( theform == null )
				w.document.location.reload();
			else
				theform.submit();
		}
	}
	catch(ex)
	{
		//alert(ex);
	}
	finally
	{
		window.close();
	}
}

//Akcija koja se izvrsava na Cancel dugme
function OnCancelButton(){
	window.close();
}

//Akcija prilikom zatvaranja editorskog
//prozora iz bilo kog razloga
function OnClosingEditor(){
	EnableOtherEditors()
}


//Funkcija se poziva nakon ucitavanja svih editorskih prozora
//Ako se konstatuje da je korisnik pritisnuo OK dugme
//okida se skript za osvezavanje prozora koji je pokrenuo
//editor, da bi se izmene unete u editoru reflektovale na originalni prozor
function OnEditorWindowLoad() {		
	var dialogResult = document.getElementById("dialogResult");
	if(dialogResult != null){	
		if(dialogResult.value == "OK"){			
			OnAcceptButton();
		}	
	}
//	document.title = "Kameleon CMS::" +	document.title;		
}

function confirmDelete() {
	var agree=confirm(Q_Delete);
	return agree;
}

function confirmUpdate() {
	var agree=confirm(Q_Save);
	return agree;
}

function disableButton ()
{
	var y=document.getElementById("lblCekaj")
	var z=document.getElementById("saveButton")
 
	y.style.display='block';
	z.style.display='none';
}

function CloseEditorAndSetOpener(openerLoc){	
	window.opener.document.location = openerLoc + '&reload=' + 1;	
	window.close();
}

// used by editors

function __myDoPostBack(eventTarget, eventArgument) {
	var theform;
	if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
		theform = document.forms["Form1"];
	}
	else {
		theform = document.Form1;
	}

	//Ako forma ima definisana hidden polja za postback 
	if(theform.__EVENTTARGET != null && theform.__EVENTARGUMENT){
		theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
		theform.__EVENTARGUMENT.value = eventArgument;
	}
	theform.submit();
}

//---- specificne funkcije

function OpenImageEditor(elementId,pageId,imageId)
{
	if(!editorsDisabled){
		var editorPage =  'ImageEditor.aspx';
		if(elementId != null){
			editorPage = editorPage + '?elementId=' + elementId;
		}
		if(pageId != null){
			editorPage = editorPage + '&pageId=' + pageId;
		}
		if(imageId != null){
			editorPage = editorPage + '&imageId=' + imageId;
		}
		
		var height = 550;
		var width = 800;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);			
		OpenEditorWindow(editorPage,top,left,width,height);
	}		
	return false;	
}

function OpenUploadImageGallery(){
	if(!editorsDisabled){
		var editorPage = 'UploadImage.aspx'
		var height = 280;
		var width = 510;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);
		OpenEditorWindow(editorPage,top,left,width,height);
	}
	return false;
}

function OpenImageEditorForLanguage(elementId,pageId,imageId)
{
	if(!editorsDisabled){
		var editorPage =  'ImageEditorForLanguage.aspx';
		if(elementId != null){
			editorPage = editorPage + '?elementId=' + elementId;
		}
		if(pageId != null){
			editorPage = editorPage + '&pageId=' + pageId;
		}
		if(imageId != null){
			editorPage = editorPage + '&imageId=' + imageId;
		}
		
		var height = 550;
		var width = 800;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);			
		OpenEditorWindow(editorPage,top,left,width,height);		
	}		
	return false;	
}

function OpenMenuEditor(topMenu,elementId,menuId,pageId,itemType){
		
	if(!editorsDisabled){
		event.cancelBubble  = true;
		var editorPage =  'MenuEditor.aspx?elementId=' + elementId + '&' + 'menuId=' + menuId + '&' + 'pageId=' +				pageId;		
		if(itemType != null){
			editorPage += '&itemType=' + itemType;
		}
		var height = 385;
		var width = 750;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);
		OpenEditorWindow(editorPage,top,left,width,height);
	}
	return false;
}

function OpenTextEditor(textId, pageId, elementId, callerInfo, noReloadCaller, type){	
	if(!editorsDisabled){
	var editorPage

 	    editorPage = 'TextEditor.aspx?';	 

		if(pageId != null && pageId != ""){
			editorPage = editorPage + 'pageId=' + pageId;
		}
		else{
			editorPage = editorPage + 'pageId=' + '-1';
		}		
		
		if(textId > 0){
			editorPage = editorPage + '&textId=' + textId;
		}
		if(elementId != null && elementId > 0){
			editorPage = editorPage + '&elementId=' + elementId;
		}
		if(callerInfo != null){
			editorPage = editorPage + '&caller=' + callerInfo;
		}
		
		if(noReloadCaller != null){		
			editorPage = editorPage + '&noReloadCaller=' + noReloadCaller;
		}
		
		if(type != null){		
			editorPage = editorPage + '&type=' + type;
		}

		var height = 480;
		var width = 780;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);
		OpenEditorWindow(editorPage,top,left,width,height);
	}
	return false;
}

function OpenContactEditor(pageId,elementId,contactId){
	if(!editorsDisabled){
		var editorPage = 'ContactEditor.aspx?pageId=' + pageId;
			editorPage = editorPage + '&elementId=' + elementId;
			editorPage = editorPage + '&contactId=' + contactId;
		
		var height = 285;
		var width = 590;
		OpenEditorWindow(editorPage,GetTopStartPosition(height),GetLeftStartPosition(width),width,height);
	}
	return false;	
}

function OpenSubmitEditor(pageId,elementId,submitId){
	if(!editorsDisabled){
		var editorPage = 'SubmitEditor.aspx?pageId=' + pageId;
			editorPage = editorPage + '&elementId=' + elementId;
			editorPage = editorPage + '&submitId=' + submitId;
		var height = 80;
		var width = 360;
		OpenEditorWindow(editorPage,GetTopStartPosition(height),GetLeftStartPosition(width),width,height);
	}
	return false;	
}

function OpenNewsEditor(){
	if(!editorsDisabled){
		var editor = 'NewsEditor.aspx';		
		var height = 440;
		var width = 795;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);		
		OpenEditorWindow(editor,top,left,width,height);
	}
	return false;
}

function OpenImageViewer(src,mOver,hiRes){
	
	if(!editorsDisabled){
		var editor = 'ImageViewer.aspx';
		if(src != null){
			editor = editor + '?imageUrl=' + src;
		}
		else{
			alert('Image not defined!');
			return false;
		}
		
		if(mOver != null && mOver != ''){
			editor = editor + "&mOverUrl=" + mOver;			
		}
		
		if(hiRes != null && hiRes != ''){
			editor = editor + "&hiResUrl=" + hiRes;			
		}
		
		var height = 500;
		var width = 500;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);
		OpenResizableEditorWindow(editor,top,left,width,height);
	}
	return false;
}

function OpenSearchEditor(pageId,elementId,searchId){
	if(!editorsDisabled){
		var editorPage = 'SearchEditor.aspx?';
		
		if(pageId != null && pageId != ""){
			editorPage = editorPage + 'pageId=' + pageId;
		}
		else{
			editorPage = editorPage + 'pageId=' + '-1';
		}
		
		if(elementId != null){
			editorPage = editorPage + '&amp;elementId=' + elementId;
		}
		
		if(searchId != null){
			editorPage = editorPage + '&amp;searchId=' + searchId;
		}
		
		var height = 216;
		var width = 520;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);
		OpenEditorWindow(editorPage,top,left,width,height);
	}
	return false;
}

function OpenSearchResultEditor(pageId,elementId,searchId){
	if(!editorsDisabled){
		var editorPage = 'SearchResultEditor.aspx?';
		
		if(pageId != null && pageId != ""){
			editorPage = editorPage + 'pageId=' + pageId;
		}
		else{
			editorPage = editorPage + 'pageId=' + '-1';
		}
		
		if(elementId != null){
			editorPage = editorPage + '&amp;elementId=' + elementId;
		}
		
		if(searchId != null){
			editorPage = editorPage + '&amp;searchResultId=' + searchId;
		}
		
		var height = 150;
		var width = 480;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);
		OpenEditorWindow(editorPage,top,left,width,height);
	}
	return false;
}

//----- BUILD LINK ------

function OpenBuildLink( url )
{	
	var height = 260;
	var width = 520;
	var left = GetLeftStartPosition(width);
	var top = GetTopStartPosition(height);
	OpenEditorWindow(url, top, left, width, height);
	return true;
}

function OpenLinkEditor()
{	
	return OpenBuildLink( 'BuildLink.aspx' );
}

function OpenLinkEditor(linkControl,isPopupCtrl){	

	if(!editorsDisabled){
		var editor = 'BuildLink.aspx';	
		var currentLink = null;
		
		if(linkControl != null){
			if( linkControl.tagName == "INPUT" )
				currentLink = linkControl.value;
			else if( linkControl.tagName == "A" )
				currentLink = linkControl.href;
			else
				currentLink = linkControl.innerText;
		}
		
		if(currentLink != null){
			editor = editor + '?link=' + currentLink;
		}
		
		if(isPopupCtrl == null)
		{
			editor = editor + '&isPopup=false';
		}
		else
		{
			var isPopup = isPopupCtrl.checked;
			editor = editor + '&isPopup=' + isPopup;
		}
		
		return OpenBuildLink( editor );
	}
	return false;
}

function OpenLinkUrlEditor(linkUrl,isPopupCtrl){	

	if(!editorsDisabled){
		var editor = 'BuildLink.aspx';	
		var currentLink = null;
		
		if(linkUrl == null)
			return false;
		else
		{
			editor = editor + '?link=' + linkUrl;
		}
		
		if(isPopupCtrl == null)
		{
			editor = editor + '&isPopup=false';
		}
		else
		{
			var isPopup = isPopupCtrl.checked;
			editor = editor + '&isPopup=' + isPopup;
		}
		
		return OpenBuildLink( editor );
	}
	return false;
}

function OpenLinkElementEditorWithPrevent(pageId,elementId,linkId,type){
	if(!editorsDisabled){
		return OpenLinkElementEditor(pageId,elementId,linkId,type);
	}
	return false;
}

function OpenLinkElementEditor(pageId,elementId,linkId,type){
	var editorPage = 'BuildLink.aspx';	
	
	if(elementId != null){
		editorPage = editorPage + '?elementId=' + elementId;
	}
	if(pageId != null){
		editorPage = editorPage + '&pageId=' + pageId;
	}
	if(linkId != null){
		editorPage = editorPage + '&linkId=' + linkId;
	}
	
	if(type != null){
		editorPage = editorPage + '&type=' + type;
	}
	
	return OpenBuildLink( editorPage );
}

///Otvara link editor ciji je cilj da napravi
///link objekat koji je deo nekog slozenijeg objekta
/// parameter LinkControlTypeEnum type 

function OpenDependentLink(linkId,type){
	var editorPage = 'BuildLink.aspx';	
	
	if(linkId != null){
		editorPage = editorPage + '?linkId=' + linkId;
	}
	
	if(type != null){
		editorPage = editorPage + '&type=' + type;
	}
	
	return OpenBuildLink( editorPage );
	return false;
}

function OpenUploadFlash(flashId, langId, guid)
{
	if (!editorsDisabled)
	{
		var editorPage = 'UploadFlash.aspx'
		if (flashId != null)
		{
			editorPage += "?flashId=" + flashId;
		}
		if (langId != null)
		{
			editorPage += "&languageId=" + langId;
		}
		if (guid != null)
		{
			editorPage += "&guid=" + guid;
		}
		var height = 110;
		var width = 470;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);
		OpenEditorWindow(editorPage, top, left, width, height);
	}
	return false;
}

function OpenFlashParameterEditor(flashId, langId, parameterId, type, guid, name, value)
{
	if (!editorsDisabled)
	{
		var editorPage = 'FlashParameterEdit.aspx'
		if (flashId != null)
		{
			editorPage += "?flashId=" + flashId;
		}
		if (langId != null)
		{
			editorPage += "&langId=" + langId;
		}
		if (parameterId != null)
		{
			editorPage += "&parameterId=" + parameterId;
		}
		if (type != null)
		{
			editorPage += "&type=" + type;
		}
		if (guid != null)
		{
			editorPage += "&guid=" + guid;
		}
		if (name != null)
		{
			editorPage += "&name=" + name;
		}
		if (value != null)
		{
			editorPage += "&value=" + value;
		}
		var height = 90;
		var width = 540;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);
		OpenEditorWindow(editorPage, top, left, width, height);
	}
	return false;
}

function OpenImageBrowser()
{	
	if (!editorsDisabled)
	{
		var editor = 'ImageBrowser.aspx';	
		var height = 556;
		var width = 406;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);
		OpenEditorWindow(editor, top, left, width, height);
	}
	return false;
}

function OpenInputEditor(pageId, elementId, inputId)
{
	if(!editorsDisabled)
	{
		var editorPage =  'InputEditor.aspx';
		if(elementId != null)
		{
			editorPage = editorPage + '?elementId=' + elementId;
		}
		if(pageId != null)
		{
			editorPage = editorPage + '&pageId=' + pageId;
		}
		if(inputId != null)
		{
			editorPage = editorPage + '&inputId=' + inputId;
		}
		
		var height = 185;
		var width = 458;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);			
		OpenEditorWindow(editorPage, top, left, width, height);
	}
	return false;	
}

function OpenShopEditor(ShopId)
{
	if(!editorsDisabled)
	{
		var editorPage = 'Catalog/ShopEditor.aspx';
		if (ShopId == null)
			ShopId = -1;
		editorPage = editorPage + '?ShopId=' + ShopId;
		var height = 175;
		var width = 585;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);			
		OpenEditorWindow(editorPage, top, left, width, height);
	}
	return false;
}

function OpenPriceRangeEditor(PriceRangeId, CatalogId)
{
	if(!editorsDisabled)
	{
		var editorPage = 'Catalog/PriceRangeEditor.aspx';
		if (PriceRangeId == null)
			PriceRangeId = -1;
		if (CatalogId == null)
			CatalogId = -1;
		editorPage = editorPage + '?PriceRangeId=' + PriceRangeId;
		editorPage = editorPage + '&CatalogId=' + CatalogId;
		var height = 130;
		var width = 515;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);			
		OpenEditorWindow(editorPage, top, left, width, height);
	}
	return false;
}

function OpenItemWithoutImages()
{
	var editorPage = 'Catalog/ItemsWithoutImages.aspx';
	var height = 690;
	var width = 820;
	var left = GetLeftStartPosition(width);
	var top = GetTopStartPosition(height);			
	OpenEditorWindow(editorPage, top, left, width, height);
	return false;
}

function OpenCloneVersionEditor(){
		var editor = 'CloneVersion.aspx';		
		var height = 130;
		var width = 310;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);
		OpenEditorWindow(editor,top,left,width,height);	
}

function OpenAddPageEditor(pageId){
		var editor = 'CreatePage.aspx';
		if(pageId != null){
			editor += '?originalPageId=' + pageId;
		}
		var height = 160;
		var width = 440;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);
		OpenEditorWindow(editor,top,left,width,height);	
}

function OpenClonePageEditor(){
		
		var pageList = document.getElementById("pageList");
		if(pageList.selectedIndex > - 1){		 
			var pageId = pageList.options[pageList.selectedIndex].value;		
			OpenAddPageEditor(pageId);
		}
}

function OpenRegisteredUsers()
{
	var editorPage = 'Catalog/RegisteredUsersEditor.aspx';
	var height = 530;
	var width = 600;
	var left = GetLeftStartPosition(width);
	var top = GetTopStartPosition(height);			
	OpenEditorWindow(editorPage, top, left, width, height);
	return false;
}

function OpenRegisteredUsersFromUserEditor(UserId)
{
	var editorPage;
	if (UserId == null)
	{
		editorPage = '../Catalog/RegisteredUsersEditor.aspx';
	}
	else
	{
		editorPage = '../Catalog/RegisteredUsersEditor.aspx?UserId=' + UserId;
	}
	var height = 530;
	var width = 600;
	var left = GetLeftStartPosition(width);
	var top = GetTopStartPosition(height);			
	OpenEditorWindow(editorPage, top, left, width, height);
	return false;
}

function OpenUserEditorFromRegisteredUsers(UserId)
{
	var editorPage;
	if (UserId == null)
	{
		editorPage = 'UserAdministration/UserEditor.aspx';
	}
	else
	{
		editorPage = 'UserAdministration/UserEditor.aspx?UserId=' + UserId;
	}
	var height = 300;
	var width = 535;
	var left = GetLeftStartPosition(width);
	var top = GetTopStartPosition(height);			
	OpenEditorWindow(editorPage, top, left, width, height);
	return false;
}

function ShowControlMenu(LayerName)
{
	if (LayerName == null)
		return false;
		
	x = event.clientX + document.body.scrollLeft;
	y = event.clientY + document.body.scrollTop;
	var obj = document.getElementById(LayerName);
	if (obj != null)
	{
		obj.style.display = "block";
		obj.style.left = x;
		obj.style.top = y;
	}
}

function HideControlMenu(LayerName)
{
	if (LayerName == null)
		return false;
	
	var obj = document.getElementById(LayerName);
	if (obj != null)
	{
		obj.style.display= "none";
	}
}

function OpenFnFromMenu(LayerName, FnName)
{
	HideControlMenu(LayerName);
	eval(FnName);
	return false;
}

function OpenFlashEditor(elementId, pageId, flashId, defualtParameters)
{
	if (!editorsDisabled)
	{
		var editorPage =  'FlashEditorNew.aspx';
		if(elementId != null)
		{
			editorPage = editorPage + '?elementId=' + elementId;
		}
		if(pageId != null)
		{
			editorPage = editorPage + '&pageId=' + pageId;
		}
		if(flashId != null)
		{
			editorPage = editorPage + '&flashId=' + flashId;
		}
		if (defualtParameters != null)
		{
			editorPage = editorPage + '&defaultParameters=' + defualtParameters;
		}
		
		var height = 350;
		var width = 503;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);			
		OpenEditorWindow(editorPage,top,left,width,height);
	}		
	return false;	
}

function OpenSendMessage()
{
	var editorPage = 'SendMessage.aspx';
	var height = 300;
	var width = 700;
	var left = GetLeftStartPosition(width);
	var top = GetTopStartPosition(height);			
	OpenEditorWindow(editorPage, top, left, width, height);
	return false;
}

function OpenRegisteredUserOptionEditor(guid)
{
	var editorPage = 'Catalog/RegisteredUserOptionEditor.aspx';
	if (guid != null)
		editorPage = editorPage + '?guid=' + guid;
	var height = 300;
	var width = 500;
	var left = GetLeftStartPosition(width);
	var top = GetTopStartPosition(height);			
	OpenEditorWindow(editorPage, top, left, width, height);
	return false;
}

function OpenSurveyEditor(PageElementId, guid)
{
	if (!editorsDisabled)
	{
		var editorPage = 'SurveyEditor.aspx';
		if (PageElementId != null)
			editorPage = editorPage + '?elementId=' + PageElementId;
		
		if (guid != null)
			editorPage = editorPage + '&guid=' + guid;
		
		var height = 500;
		var width = 700;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);			
		OpenEditorWindow(editorPage, top, left, width, height);
	}
	return false;
}

function OpenTextEditorNew(textId, pageId, elementId, callerInfo, noReloadCaller, Type)
{	
	if (!editorsDisabled)
	{
		var editorPage = 'TextEditor.aspx?';	 

		if (pageId != null && pageId != "")
			editorPage = editorPage + 'pageId=' + pageId;
		else
			editorPage = editorPage + 'pageId=-1';
		
		if (textId > 0)
			editorPage = editorPage + '&textId=' + textId;
		
		if (elementId != null && elementId > 0)
			editorPage = editorPage + '&elementId=' + elementId;
		
		if (callerInfo != null)
			editorPage = editorPage + '&caller=' + callerInfo;
		
		if (noReloadCaller != null)
			editorPage = editorPage + '&noReloadCaller=' + noReloadCaller;
			
		if (Type != null)
			editorPage = editorPage + '&Type=' + Type;
		
		var height = 480;
		var width = 780;
		var left = GetLeftStartPosition(width);
		var top = GetTopStartPosition(height);
		OpenEditorWindow(editorPage, top, left, width, height);
	}
	return false;
}

/*
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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];}
}
*/
