// AUTENTIFICARE // INREGISTRARE
$.fx.speeds._default = 1000;

$(function() {
	$('#abLogin').dialog({
		autoOpen: false,
		width:560,
		height:331,
		resizable:false,
		draggable: false,
		modal:true
	});
	
	$('#abCreateAccount').dialog({
		autoOpen: false,
		width:560,
		height:335,
		resizable:false,
		draggable: false,
		modal:true
	});
	
	$('#abPriceAlert').dialog({
		autoOpen: false,
		width:560,
		height:480,
		resizable:false,
		draggable: false,
		modal:true
	});
		
	$('#abSendToFriend').dialog({
		autoOpen: false,
		width:560,
		height:475,
		resizable:false,
		draggable: false,
		modal:true
	});

	$('#linkPriceAlert').click(function() {
		$('#abPriceAlert').dialog('open');
	
		return false;
	});
		
	$('#linkSendToFriend').click(function() {
		$('#abSendToFriend').dialog('open');
		return false;
	});
	
	$('#openLogin').click(function() {
		$('#abLogin').dialog('open');
		return false;
	});
	
	$('#openLoginShop').click(function() {
		$('#abLogin').dialog('open');
		return false;
	});
	
	$('#openLoginShop2').click(function() {
		$('#abLogin').dialog('open');
		return false;
	});
	
	$('#openCreateAccount').click(function() {
		$('#abCreateAccount').dialog('open');
		return false;
	});
});


// MENU & HOME
$(document).ready(function(){
		$(".menu_ul").hide();
		$("#top").mouseover(function(){
			$(".menu_ul").hide();
			$(".top_buttons_left_li").css({"background-image":"none"});
			$(".top_buttons_left_li").css({"color":"#cecece"});
		});
		$("#content").mouseover(function(){
			$(".menu_ul").hide();
			$(".top_buttons_left_li").css({"background-image":"none"});
			$(".top_buttons_left_li").css({"color":"#cecece"});
		});
		
		/*Input*/
		$('#searchInput').click(function(){
			if ($('#searchInput').val() == 'Cauti ceva anume?')
				$('#searchInput').attr('value', '');
		});
		$('#searchInput').focusout(function(){
			if ($('#searchInput').val() == "")
				$('#searchInput').attr('value', 'Cauti ceva anume?');
		});
		$('#nameInput').click(function(){
			if ($('#nameInput').val() == 'Nume si prenume: ')
				$('#nameInput').attr('value', '');
		});
		$('#nameInput').focusout(function(){
			if ($('#nameInput').val() == "")
				$('#nameInput').attr('value', 'Nume si prenume: ');
		});
		$('#emailInput').click(function(){
			if ($('#emailInput').val() == 'Adresa de email: ')
			$('#emailInput').attr('value', '');
		});
		$('#emailInput').focusout(function(){
			if ($('#emailInput').val() == "")
				$('#emailInput').attr('value', 'Adresa de email: ');
		});	
		
		$("#cos_dropdown").hide();			
		$(".shoppingCart_box").click(function(){
			$(".shoppingCart_box").css({"background-image":"url('"+SITE_ROOT+"static/image/dropdown_background.jpg')"});
			$("#cos_dropdown").show();
			$(".green").css({"color":"#ffffff"});
		});
		$(".continue_shopping").click(function(){
			$(".shoppingCart_box").css({"background-image":"url('"+SITE_ROOT+"static/image/shoppingCart_background.jpg')"});
			$("#cos_dropdown").hide();
			$(".green").css({"color":"#1db0bc"});
		});	
		$("#top").click(function(){
			$(".shoppingCart_box").css({"background-image":"url('"+SITE_ROOT+"static/image/shoppingCart_background.jpg')"});
			$("#cos_dropdown").hide();
			$(".green").css({"color":"#1db0bc"});
		});
		$("#content").click(function(){
			$(".shoppingCart_box").css({"background-image":"url('"+SITE_ROOT+"static/image/shoppingCart_background.jpg')"});
			$("#cos_dropdown").hide();
			$(".green").css({"color":"#1db0bc"});
		});
		$(".bottom").click(function(){
			$(".shoppingCart_box").css({"background-image":"url('"+SITE_ROOT+"static/image/shoppingCart_background.jpg')"});
			$("#cos_dropdown").hide();
			$(".green").css({"color":"#1db0bc"});
		});
		$("#background_invisible").click(function(){
			$(".shoppingCart_box").css({"background-image":"url('"+SITE_ROOT+"static/image/shoppingCart_background.jpg')"});
			$("#cos_dropdown").hide();
			$(".green").css({"color":"#1db0bc"});
		});
		
		/*$("#cos_dropdown").hide();			
		$(".shoppingCart_box").click(function(){
			$(".shoppingCart_box").css({"background-image":"url('"+SITE_ROOT+"static/image/dropdown_background.jpg')"});
			$("#cos_dropdown").show();
			$(".green").css({"color":"#ffffff"});
			$(".finish_order").show();
			$("a.finish_order").attr("href", "http://www.google.com");
		});
		
		$(".continue_shopping").focusin(function(){
			$(".shoppingCart_box").css({"background-image":"url('"+SITE_ROOT+"static/image/shoppingCart_background.jpg')"});
			$("#cos_dropdown").hide();
			$(".green").css({"color":"#1db0bc"});
		});	*/
	});
function cos_show()
{
	
}
function cos_hide()
{
	$("#cos_dropdown").mouseleave(function(){
		$("body").mousedown(function(){
			$(".shoppingCart_box").css({"background-image":"url('"+SITE_ROOT+"static/image/shoppingCart_background.jpg')"});
			$("#cos_dropdown").hide();
			$(".green").css({"color":"#1db0bc"});
		});
	});	
}
function callback_stop(){
	
}
function show_menu(i)
{	
	$(document).ready(function(){
		$(".menu_ul").hide();
		$(".top_buttons_left_li").css({"background-image":"none"});
		$(".top_buttons_left_li").css({"color":"#cecece"});
		$("#top_buttons_left_li"+i).css({"background-image":"url('"+SITE_ROOT+"static/image/menu_background_top.png')"});
		$("#top_buttons_left_li"+i).css({"color":"#1db0bc"});
		$("#menu_ul"+i).show();
	});
} 
function hide_menu(i)
{
	$(".menu_ul").hide();
	$(".top_buttons_left_li").css({"background-image":"none"});
	$(".top_buttons_left_li").css({"color":"#cecece"});
	$("#menu_ul"+i).hide();
}
	
// PAG LISTARE PRODUS
function product_image_hover_function(i)
{
	$("#product_image_hover_buttons"+i).show();
}
function product_image_out_function(i)
{
	$(".product_image_hover_buttons").hide();
	$("#shoppingCart_add"+i).attr("src", "../image/shoppingCart_add.png");
	$("#see_details"+i).attr("src", "../image/see_details.png");
}
	function shoppingCart_add_hover_function(i)	
{
	$("#shoppingCart_add"+i).attr("src", "../image/shoppingCart_add_hover.png");
}
function shoppingCart_add_out_function(i)	
{
	$("#shoppingCart_add"+i).attr("src", "../image/shoppingCart_add.png");
}
function see_details_hover_function(i)	
{
	$("#see_details"+i).attr("src", "../image/see_details_hover.png");
}
function see_details_out_function(i)	
{
	$("#see_details"+i).attr("src", "../image/see_details.png");
}
function change_image(img)
{
	$(".product_page_image").attr("src", img);
	$("#plusMinus").attr("href", img);
}	


// MY Account
function showPersFizica()
{
	$("#persJuridica").hide("blind");
	$("#showPJuridica").src = SITE_ROOT + 'static/image/ro/persoana_juridica_grey.jpg';
	$("#showPFizica").src = SITE_ROOT + 'static/image/ro/persoana_fizica_green.jpg';
}
function showPersJuridica()
{
	$("#persJuridica").show("blind");
	$("#showPJuridica").src = SITE_ROOT + 'static/image/ro/persoana_juridica_green.jpg';
	$("#showPFizica").src = SITE_ROOT + 'static/image/ro/persoana_fizica_grey.jpg';
}

// AJAX STARTS HERE
// PRODUCTS WISHLIST: ADD TO
function ajax_add_to_wishlist(ADDRESS)
{	
	$.ajax({ 
		url: ADDRESS, 
		success: function(data){
        	if(data=="err1") alert("Eroare!");
        	else alert(data);
      	}});
}

// PRODUCTS WISHLIST: DELETE
function ajax_delete_from_wishlist(DIV, ADDRESS)
{	
	$.ajax({ 
		url: ADDRESS, 
		success: function(data){
        	if(data=="err1") alert("Eroare!");
        	else $("#"+DIV).hide("blind");
      	}});
	return false;
}

// PRODUCTS WISHLIST: UPDATE RATING
function ajax_update_rating_wishlist(ID, RATING, ADDRESS)
{	
	$.ajax({ 
		url: ADDRESS, 
		success: function(data){
        	if(data=="err1") alert("Eroare!");
        	else {
        		var html = "";
		      	for(i=1;i<=RATING;i++)
		      		html += "<img src='" + SITE_ROOT + "static/image/star_red.png" + "' alt='' style='width: 16px; height: 15px;' />";
		      	for(i=1;i<=5-RATING;i++)
		      		html += "<img src='" + SITE_ROOT + "static/image/star_grey.png" + "' alt='' style='width: 16px; height: 15px;' />";
		      	
		      	$("#wishlist_stars_"+ID).html(html);
		      	$("#wishlist_voted_"+ID).html("<small>Ati acordat " + RATING + " stelute!</small>");
        	}
      	}});
	return false;	
}

// PRODUCTS WISHLIST: UPDATE DESCRIPTION
function ajax_update_description_wishlist(INPUT, ADDRESS)
{	
	var text = $("#" + INPUT).val();
	if(text!="")
	{
		$.ajax({ 
			url: ADDRESS + "&description=" + text, 
			success: function(data){
	        	if(data=="err1") alert("Eroare!");
	        	else {};
      	}});
	}
	return false;	
}

// SHOPPING CART: ADD
function ajax_shopcart_add()
{
	var ID 	= $("#idProduct").val();
	var Q 	= $("#quantitySelect").val();
	var V 	= $("#sizeSelect").val();
	
	var ADDRESS = SITE_ROOT + "shopping-cart/?action=add&idProduct="+ID+"&idVersion="+V+"&quantity="+Q;
	
	$.ajax({ 
		url: ADDRESS, 
		success: function(data){
        	if(data=="err1") alert("Stoc insuficient!");
        	else {
        	
				var info = data.split(" ");
				var total = info[1];
				var quantity = info[0];
				var uniqueQ = info[2];
				
				$("#shopBarQ").text(uniqueQ);
				$("#shopBarV").text(formatCurrency(total,2) + " RON");
				$("#slideTotal").text(formatCurrency(total,2));
				
				if(uniqueQ>3) $("#slideOther").html("In cosul tau de cumparaturi mai sunt alte <br />" + (uniqueQ-3) + " produse"); 
				
				// incarca lista de produse pt drop-down (ultimele 3 prod)
				var ADDRESS = SITE_ROOT + "shopping-cart/?printShop="+Q;
				
				$.ajax({ 
					url: ADDRESS, 
					success: function(data){
			        	$("#slidePop").html(data);
			        	
			        	$(".shoppingCart_box").css({"background-image":"url('"+SITE_ROOT+"static/image/dropdown_background.jpg')"});
						$("#cos_dropdown").slideDown();
						$(".green").css({"color":"#ffffff"});
			        }});
        	};
      	}});
}

// SHOPPING CART: CHANGE QUANTITY
function ajax_shopcart_quantity(ID, TYPE, PRICE)
{	
	var q = parseInt($("#shoppingProductQuantity_"+ID).val());
	var err = 0; 
	//var total = 0; var totalFinal = 0; var discount = 0;
	
	if(TYPE=="+")  	q = q+1;
	else 			q = q-1;	
	
	if(q<=0) {
		var ADDRESS = SITE_ROOT + "shopping-cart/?action=delete&idProduct="+ID;
		ajax_shopcart_delete(ADDRESS, ID);
		return;
	}
	else
	{
		var ADDRESS = SITE_ROOT + "shopping-cart/?action=setquantity&idProduct="+ID+"&quantity="+q;
		
		$.ajax({ 
			url: ADDRESS, 
			success: function(data){
        	if(data=="err1") alert("Stoc insuficient!");
        	else {
		    	// get discount value & total value
				var temp = data;
				var info = data.split(" ");
				var total = info[1];
				var discount = info[0];
				var totalFinal = total * (1-discount/100);
				var thisTotal = info[2];
				
				$("#shoppingProductQuantity_"+ID).val(q); 
				$("#shoppingProductTotal_"+ID).text(thisTotal); 
	
				if(discount>0) {
					$("#has_discount").show();
					$("#total_initial").text(formatCurrency(total,2));
					$("#total_discount").text(discount);
				}
				else if(discount==0) $("#has_discount").hide();

				$("#total_value").text(formatCurrency(totalFinal,2));
				
		    }
		  }
		});
	}
}

// SHOPPING CART: DELETE
function ajax_shopcart_delete(ADDRESS, ID)
{	
	$.ajax({ 
			url: ADDRESS, 
			success: function(data){
        	if(data=="err1") alert("Eroare!");
        	else {
				var temp = data;
				var info = data.split(" ");
				var total = info[1];
				var discount = info[0];
				var totalFinal = total * (1-discount/100);
				
				if(discount>0) {
					$("#has_discount").show("blind");
					$("#total_initial").text(formatCurrency(total,2));
					$("#total_discount").text(discount);
				}
				else if(discount==0) $("#has_discount").hide();
				
				$("#total_value").text(formatCurrency(totalFinal,2));
				
				$("#shoppingProductLine_"+ID).hide("blind");
				
				if(total==0) {
					$("#nextStep1").hide("fade");
					$("#nextStep2").hide("fade");
				}	
		    }
		  }
	});
}

// PRODUCTS STAR RATING
function ajax_rate_product(ADDRESS)
{	
	$('#product_rating_message').innerHTML = "<center>Please wait ...</center>";	
	//new Ajax.Updater('product_rating_message', ADDRESS, { method:'get' });*/
	
	$.ajax({ 
			url: ADDRESS, 
			success: function(data){
        	if(data=="err1") alert("Eroare!");
        	else { $("#product_rating_message").text(data); }
        }});
}
// END AJAX

// PRODUCTS PAGE
// show-hide filters menu
if($('#menu_arrow_center_top').length) 
{
	$(document).ready(function() 
	{
		$('#menu_arrow_center_top').click( function(){
			if(filtersHidden==1) {
				new Effect.SlideDown('filter_box');
				$("#menu_arrow_center_top").style.background = "url("+SITE_ROOT+"static/image/menu_arrow_center_2.jpg)";
				$("#menu_arrow_center_top").style.backgroundPosition = "1px";
				filtersHidden = 0;
			}
			else { 
				new Effect.SlideUp('filter_box');
				$("#menu_arrow_center_top").style.background = "url("+SITE_ROOT+"static/image/menu_arrow_center.jpg)";
				$("#menu_arrow_center_top").style.backgroundPosition = "1px";
				filtersHidden = 1;
			}
		});
	
		// filter menu submit
		$('filterPriceInput').blur( function()   {  $("filterForm").submit();  });
		$('filterEdituraInput').blur( function() {  $("filterForm").submit();  });
		$('filterYearInput').blur( function()    {  $("filterForm").submit();  });
		$('filterAuthorInput').blur( function()  {  $("filterForm").submit();  });
	});
}
// END PRODUCTS PAGE

// POOLS - SUBMIT ONE ANSWER
function ajax_submit_pool(ADDRESS, DIV)
{	
	$("#"+DIV).html = "<center>Please wait ...</center>";	
	$.ajax({ 
		url: ADDRESS, 
		success: function(data){
		if(data=="err1") alert("Eroare!");
        else $("#"+DIV).html(data);
        }
       });
}

// POOLS - SUBMIT MULTIPLE ANSWER
function ajax_submit_pool_multiple(ADDRESS, DIV, ID, COUNT)
{	
	var params = "";
	for(var i=0;i<COUNT;i++)
	{
		if($(DIV+"_"+i).checked)
		{
			params += i+"-";
		}
	}

	$(DIV).innerHTML = "<center>Please wait ...</center>";	
	new Ajax.Updater(DIV, ADDRESS+"&idAnswers="+params, { method:'get' });
}

// MENU LEFT SHOW/HIDE
function showMenuCategories()
{
	$('#menuBrands').hide();
	$('#menuCategories').show();
	$('#menuCategories').addClass('.tab_branduri_hover');
	$('#tab_produse').addClass("tab_produse_hover");
	$('#tab_branduri').addClass("tab_branduri");
}
function showMenuBrands()
{
	$('#menuCategories').hide();
	$('#menuBrands').show();
	$('tab_produse').addClass("tab_produse");
	$('tab_branduri').addClass("tab_branduri_hover");
}

function formatCurrency(amount, noDecimals)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(noDecimals!=1){
		if(s.indexOf('.') < 0) { s += '.00'; }
		if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	}
	s = minus + s;
	return s;
}

// WISHLIST CHANGE STARR
function changeStar(id, prod)
{	
	for(i=1;i<=id;i++)
		$('#big_star_'+prod+'_'+i).attr("src", SITE_ROOT + "static/image/star_red.png");
	for(i=5;i>id;i--)
		$('#big_star_'+prod+'_'+i).attr("src", SITE_ROOT + "static/image/star_grey.png");
}

// FUNCTII PAGINA DE PRODUS
function showProdDesc()
{
	$('#product_info_tehnice').hide();
	$('#product_info_comments').hide();
	$('#product_info_video').hide();
	$('#product_info_text').show();
	
	$('#link_info_tech').addClass("tab");
	$('#link_info_comm').addClass("tab");
	$('#link_info_desc').addClass("tab_hover");
	$('#link_info_video').addClass("tab");
}

function showProdTech()
{
	$('#product_info_text').hide();
	$('#product_info_comments').hide();
	$('#product_info_video').hide();
	$('#product_info_tehnice').show();
	
	$('#link_info_tech').addClass("tab_hover");
	$('#link_info_comm').addClass("tab");
	$('#link_info_desc').addClass("tab");
	$('#link_info_video').addClass("tab");
}

function showProdVideo()
{
	$('#product_info_text').hide();
	$('#product_info_comments').hide();
	$('#product_info_video').show();
	$('#product_info_tehnice').hide();
	
	$('#link_info_tech').addClass("tab");
	$('#link_info_comm').addClass("tab");
	$('#link_info_video').addClass("tab_hover");
	$('#link_info_desc').addClass("tab");
}

function showProdComm()
{
	$('#product_info_tehnice').hide();
	$('#product_info_text').hide();
	$('#product_info_video').hide();
	$('#product_info_comments').show();
	
	$('#link_info_tech').addClass("tab");
	$('#link_info_comm').addClass("tab_hover");
	$('#link_info_video').addClass("tab");
	$('#link_info_desc').addClass("tab");
}

function checkSearchBoxInner(searchDefTxt)
{
	if($('#searchInput').val()=="") $('#searchInput').val(searchDefTxt);
}

var SCRIPT_openCloseStatus = new Array();
function SCRIPT_openClose(id)
{
	if(SCRIPT_openCloseStatus[id]=='open') {
		Effect.BlindUp(id);
		SCRIPT_openCloseStatus[id] = "close";
	}
	else {
		Effect.BlindDown(id);
		SCRIPT_openCloseStatus[id] = "open";
	}
	return false;
}

/* TOOLTIP CU POZA */
var offsetxpoint=0; //Customize x offset of tooltip
var offsetypoint=20; //Customize y offset of tooltip
var ie=document.all;
var ns6=document.getElementById && !document.all;
var enabletip=false;
var tipobj;

function getElem(elemID){
	var obj;
	if (document.all){
		obj = document.all(elemID)
	}else if (document.getElementById){
		obj = document.getElementById(elemID)
	}else if (document.layers){
		obj = document.layers[elemID]
	}
	return obj;
}

function initial(){
	if (!tipobj) tipobj = getElem("dhtmltooltip");
}

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

/////////////////////////////////////////////////////////////
function ddrivetip(thetext, thecolor, thewidth){
	initial();
	thetext = '<img src="'+SITE_ROOT+'user/content/'+thetext+'" width="200" />';
	if (ns6||ie){
//		if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px";
//		if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor;
		tipobj.innerHTML=thetext;
		enabletip=true;
		return false;
	}
}

/////////////////////////////////////////////////////////////
function positiontip(e){
	if (enabletip){
		var curX=(ns6)?e.pageX : event.x+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.y+ietruebody().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20;
		var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20;
		
		var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000;
		
		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<tipobj.offsetWidth)
		//move the horizontal position of the menu to the left by it's width
			tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px";
		else if (curX<leftedge)
			tipobj.style.left="5px"
		else
		//position the horizontal position of the menu where the mouse is positioned
			tipobj.style.left=curX+offsetxpoint+"px";
		
		//same concept with the vertical position
		if (bottomedge<tipobj.offsetHeight)
			tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px";

		else
			tipobj.style.top=curY+offsetypoint+"px";
		tipobj.style.visibility="visible";
	}
}

/////////////////////////////////////////////////////////////
function hideddrivetip(){
	if (ns6||ie){
		enabletip=false;
		tipobj.style.visibility="hidden";
		tipobj.style.left="-1000px";
//		tipobj.style.backgroundColor='';
		tipobj.style.width='';
		}
}

document.onmousemove=positiontip

//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, "", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000", "application/x-shockwave-flash"  );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
