var my_mkan=0;
function new_pic(){
	my_mkan = $('#pic_number').val();
	my_mkan ++;
	if ( my_mkan > 5 ){
		alert('حداکثر 5 تصویر میتوانید ارسال نمایید');
	}else{
        gBin = document.createElement('div'); 
        gBin.id = 'new_'+my_mkan; 
        gBin.innerHTML = '<br /> شماره ی '+my_mkan+' : <input type="file" name="my_file_'+my_mkan+'" />';
        $('#pic_list').append(gBin);
		$('#pic_number').val(my_mkan);
	}
}

function add_row(tab,type,name){
	var types = type.split(" ");
	var names = name.split(" ");
	var index = 0;
	my_tab=document.getElementById(tab);
    row=document.createElement("tr");
    while (index < names.length)
    {
    	cell = document.createElement("td");
    	inp = document.createElement("input");
    	inp.setAttribute("type", types[index]);
    	inp.setAttribute("name", names[index]);
    	cell.appendChild(inp);
    	index += 1;
    }
    row.appendChild(cell);
    my_tab.appendChild(row);
}

function copy_lastrow(tab){
	my_tab=document.getElementById(tab);
	tb = my_tab.tBodies[0];
	lastrow = tb.lastChild;
	index = 0;
	var num_rows = $('#'+tab+'_rows').val();
	num_rows ++;
	if (num_rows > 6)
	{
	}else{
		row=document.createElement("tr");
		do
		{
			cell = document.createElement("td");
			cell.innerHTML = lastrow.cells[index].innerHTML;
			row.appendChild(cell);
			index += 1;
		}
		while(typeof(lastrow.cells[index]) != "undefined" );
		tb.appendChild(row);
		$('#'+tab+'_rows').val(num_rows);
	}
}

/*function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
	}
	
function getSubCat(strURL)
{         
     var req = getXMLHTTP(); // fuction to get xmlhttp object
     if (req)
     {
      req.onreadystatechange = function()
     {
      if (req.readyState == 4) { //data is retrieved from server
       if (req.status == 200) { // which reprents ok status                    
         document.getElementById('subcatdiv').innerHTML=req.responseText;
      }
      else
      { 
         alert("There was a problem while using XMLHTTP:\n");
      }
      }            
      }        
    req.open("GET", strURL, true); //open url using get method
    req.send(null);
     }
}*/


var st;
var bt;
var doob   = new Array();
var doien = new Array(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
function doi(obj, index){
	if(doien[index]){
		//var first = obj.find('li:first').html();
		var height = obj.find('li:first').css("height");
		height = '-' + height;
		obj.animate({top: height},1000,'',function() {
			var first = obj.find('li:first').html();
		    obj.find('li:first').remove();
		    obj.css("top","0");
		    obj.append('<li >'+first+'</li>');
		});
	}
}

$(document).ready(function(){
	$(".moving").each(function(index, elm){
		doob[index] = $(elm);
		setInterval('doi(doob['+index+'], '+index+')', 3300);
		$(elm).mouseenter(function(){doien[index] = false;});
		$(elm).mouseleave(function(){doien[index] = true;});
	});
//	at = setInterval('doi($(".moving"))', 3300);
    
});

function atabovr(obj){
	obj= $(obj).parent();
	obj.find('.abot').css("display","block");
	obj.find('.bbot').css("display","none");
	obj.find('.atab').css({
		"border-color":"#99CCFD",
		"border-style":"solid",
		"border-width":"1px 1px 0 1px"
	});
	obj.find('.btab').css({
		"border-bottom":"1px solid #99CCFD",
		"border-left":"none"
	});
}
function btabovr(obj){
	obj= $(obj).parent();
	obj.find('.abot').css("display","none");
	obj.find('.bbot').css("display","block");
	obj.find('.btab').css({
		"border-color":"#FFCE98",
		"border-style":"solid",
		"border-width":"1px 1px 0 1px"
	});
	obj.find('.atab').css({
		"border-bottom":"1px solid #FFCE98",
		"border-right":"none"
	});
}
$(document).ready(function(){
  $('#catbar').mouseenter(function(){$('#catdiv').css("display","block");})
  .mouseleave(function(){$('#catdiv').css("display","none");});
});

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

